PreparePyramid.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:mlstudy_week7 作者: ByungKeon-Ko 项目源码 文件源码
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)

# -----------------------------------------
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号