# Created with scikit-image in python.
<ol><li>compute the HOG descriptor and display a visualisation.</li></ol><p>import matplotlib.pyplot as plt
from skimage.feature import hog
from skimage import data, exposure, io
</p><p>image = io.imread("330px-2018-03-12_Unterzeichnung_des_Koalitionsvertrages_der_19._Wahlperiode_des_Bundestages_by_Sandro_Halank–027.jpg")
</p><p>fd, hog_image = hog(image, orientations=8, pixels_per_cell=(16, 16),
</p>
<pre>                   cells_per_block=(1, 1), visualize=True, multichannel=True)
</pre>
<p>fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(8, 4), sharex=True, sharey=True)
</p><p>ax1.axis('off')
ax1.imshow(image, cmap=plt.cm.gray)
ax1.set_title('Input image')
</p>
<ol><li>Rescale histogram for better display</li></ol><p>hog_image_rescaled = exposure.rescale_intensity(hog_image, in_range=(0, 10))
</p><p>ax2.axis('off')
ax2.imshow(hog_image_rescaled, cmap=plt.cm.gray)
ax2.set_title('Histogram of Oriented Gradients')
</p>
plt.show()
<a href="//commons.wikimedia.org/wiki/User:MTheiler" title="User:MTheiler">MTheiler</a>
CC BY-SA 4.0
2018-03-12_Unterzeichnung_des_Koalitionsvertrages_der_19._Wahlperiode_des_Bundestages_by_Sandro_Halank–027.jpg