''' Created on Apr 29, 2017 likely actually created April 2014, redate is from creation of separate module @author: Brett Paufler (c) Brett Paufler This is DEAD CODE cv2 not imported did not work when moved here packed to graveyard on 6-7-17 ''' ################################################################## import cv2 import numpy from cv2 import hog, exposure #a guess, to resolve errors from skimage import io nFL=(0,0,0) #dummy variable, have no idea what should be, used much #THESE VALUES LIKELY WRONG (imports, dummy variable, etc ################################################################### def hogTestCellParts(img, c=50, nH=8, b = 1, parts=False): '''takes a grey_scale image (img) and saves a standard hog (Histogram of Gradients) image c = pixels_per_cell = (c,c) b = cells_per_block = (b,b) no known effect by me nH = orientations = numberHistograms = nH some positive integer with decreasing rates of return after 16 or so if parts=True, individual images are saved of each cell fd Histogram component explored under hogFdTest ''' print "runnin HogTestCellParts" fd, iO = hog(img.copy(), orientations=nH, pixels_per_cell=(c,c), cells_per_block=(b, b), visualise=True) iO = exposure.rescale_intensity(iO, in_range=(0, 0.02)) sN = "./butterfly/PNG/GIF/ufoTravels_hogTest_c%s_b%s_h%s.png" % (nFL(c), nFL(b), nFL(nH)) io.imsave(sN, iO) print "Shape=%s Max=%f Min=%f Mean=%f" % (str(iO.shape), numpy.amax(iO),numpy.amin(iO),numpy.mean(iO)) #print iO[:25,:25] cvImg = cv2.imread(sN,0) imgText = "c=%d b=%d, h=%d" % (c, b, nH) cv2.putText(cvImg, imgText, (5,25), cv2.FONT_HERSHEY_PLAIN, fontScale=2, color=(255,255,255), thickness=2) cv2.imwrite(sN,cvImg) #watermark removed #pil_filter_effects.watermark_inplace(sN, waterMark="./watermark/pauflerNet100.png", x=390, y=10) #This part of the function saves individual cell images #As a starting place for playing with the histogram values (fd) if parts: width, height = img.shape sC = [(x,y) for x in range(0,width,c) for y in range(0,height,c)] xy = {} for x,y in sC: s = img[x:(x+c),y:(y+c)] fd, iO = hog(s, orientations=nH, pixels_per_cell=(c,c), cells_per_block=(b, b), visualise=True) iO = exposure.rescale_intensity(iO, in_range=(0, 0.02)) sN = "./butterfly/PNG/GIF/ufoTravels_hogTest_c%s_b%s_h%s__%s_%s.png" % (nFL(c), nFL(b), nFL(nH), nFL(x), nFL(y)) io.imsave(sN, iO) print "Shape=%s Max=%f Min=%f Mean=%f" % (str(iO.shape), numpy.amax(iO),numpy.amin(iO),numpy.mean(iO)) cvImg = cv2.imread(sN,0) partText = "%d-%d:%d-%d" % (x, (x+c), y, (y+c) ) cv2.putText(cvImg, partText, (5,45), cv2.FONT_HERSHEY_PLAIN, fontScale=0.5, color=(255,255,255), thickness=1) cbhText = "%d-%d-%d" % (c, b, nH) cv2.putText(cvImg, cbhText, (35,22), cv2.FONT_HERSHEY_PLAIN, fontScale=1, color=(255,255,255), thickness=1) cv2.imwrite(sN,cvImg) #Watermark killed #pil_filter_effects.watermark_inplace(sN, waterMark="./watermark/pauflerNet25.png", x=5, y=5) print "Finished Hog Test" ''' #code for hogTestCellParts chb = [(c,h,b,p) for c in [50] for h in [3] for b in [1] for p in [False] ] for C,H,B,P in chb: sN = "./butterfly/png/UFO-500x500.jpg" hogTestCellParts(io.imread(sN, as_grey=True),c=C, nH=H, b=B, parts=P) ''' ############## END FIRST PASTE