【问题标题】:Why I am getting typeerror for Histogram of Oriented Gradient (HOG) feature in scikit-image?为什么我在 scikit-image 中出现定向梯度直方图 (HOG) 特征的类型错误?
【发布时间】:2018-05-03 04:20:57
【问题描述】:

我正在尝试生成幅度直方图。我在文档中看到以下示例的错误。

File "/Users/air/Projects/cs512-f17-project/SIFT/hog.py", line 10, in <module>
    cells_per_block=(1, 1), visualize=True)
TypeError: hog() got an unexpected keyword argument 'visualize'

http://scikit-image.org/docs/dev/auto_examples/features_detection/plot_hog.html

import matplotlib.pyplot as plt

from skimage.feature import hog
from skimage import data, color, exposure


image = color.rgb2gray(data.astronaut())

fd, hog_image = hog(image, orientations=8, pixels_per_cell=(32, 32),
                    cells_per_block=(1, 1), visualize=True)

fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4), sharex=True, sharey=True)

ax1.axis('off')
ax1.imshow(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.show()

【问题讨论】:

    标签: python scikit-learn scikit-image


    【解决方案1】:

    visualize 参数在scikit-image=0.14dev 中引入,旨在替代旧参数visualise。在scikit-image=0.13.x 中没有参数visualize (http://scikit-image.org/docs/0.13.x/api/skimage.feature.html?highlight=hog#skimage.feature.hog)。请确保您查看的是 stable 版本的文档。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-19
      • 2014-04-04
      • 2014-10-25
      • 2011-08-01
      • 1970-01-01
      • 2020-12-16
      相关资源
      最近更新 更多