Skip to content

Instantly share code, notes, and snippets.

@arc279
Created May 18, 2017 06:41
Show Gist options
  • Save arc279/8aae1d275e6c4fe5aa753bb5c36975f1 to your computer and use it in GitHub Desktop.
Save arc279/8aae1d275e6c4fe5aa753bb5c36975f1 to your computer and use it in GitHub Desktop.
hog特徴量を抽出して描画
import cv2
import matplotlib.pyplot as plt
from skimage.feature import hog
from skimage import color, exposure
img = cv2.imread('test2.png')
image = color.rgb2gray(img)
fd, hog_image = hog(image, orientations=9, pixels_per_cell=(8, 8),
cells_per_block=(3, 3), visualise=True)
hog_image_rescaled = exposure.rescale_intensity(hog_image, in_range=(0, 0.1))
plt.axis('off')
plt.imshow(image, cmap=plt.cm.gray)
plt.show()
plt.axis('off')
plt.imshow(hog_image_rescaled, cmap=plt.cm.gray)
plt.savefig("test3.png")
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment