preprocessing.py 文件源码

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

项目:Sign-Language-Recognition 作者: achyudhk 项目源码 文件源码
def save_hog_image_comparison(filename):
    input_image = io.imread(filename)
    gray_image = color.rgb2gray(input_image)
    out_filename = "hog/" + filename

    # 87% for orientations=8, pixels_per_cell=(4, 4), cells_per_block=(1, 1)
    fd, hog_image = hog(gray_image, orientations=8, pixels_per_cell=(4, 4),
                        cells_per_block=(1, 1), visualise=True)
    # io.imsave("hog/" + filename, hog_image)
    fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4), sharex=True, sharey=True)

    ax1.axis('off')
    ax1.imshow(gray_image, cmap=plt.cm.gray)
    ax1.set_title('Input image')
    ax1.set_adjustable('box-forced')

    # Rescale histogram for better display
    hog_image_rescaled = exposure.rescale_intensity(hog_image, in_range=(0, 0.02))
    ax2.axis('off')
    ax2.imshow(hog_image_rescaled, cmap=plt.cm.gray)
    ax2.set_title('Histogram of Oriented Gradients')
    ax1.set_adjustable('box-forced')
    plt.savefig(out_filename)
    plt.close()

    return hog_image
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号