def save_pyramid () :
global temp_line
global pyramids
global patchNum
global total_patch
global total_pyramid
org_img = Image.open("%s/../fddb/%s.jpg" %(base_path, temp_line), 'r' )
org_img_name = "%s " %(temp_line) # original image name
pyramids = list( pyramid_gaussian(org_img, downscale=math.sqrt(2) ) )
for i in range(len(pyramids) ):
if min( pyramids[i].shape[0], pyramids[i].shape[1] ) < MinFace :
del pyramids[i:]
break
for i in range( len (pyramids) ) :
row = pyramids[i].shape[0]
col = pyramids[i].shape[1]
im_matrix = np.zeros([row, col, 3]).astype('uint8')
for k in range(row):
for j in range(col):
im_matrix[k,j] = pyramids[i][k,j] * 255
new_img = Image.fromarray(im_matrix)
new_img.save("%s/pyramid-%s.jpg" %(ns_path, i+total_pyramid) )
# new_img.show()
patchNum[i] = (row-MinFace+1) * (col-MinFace+1) # the number of patches
total_pyramid = total_pyramid + len(pyramids)
total_patch = total_patch + sum(patchNum)
# -----------------------------------------
评论列表
文章目录