Created
August 29, 2019 07:56
-
-
Save aishwarya-singh25/d14d2dacf69f6602d8491faba42fccdc to your computer and use it in GitHub Desktop.
HOG feature Descriptor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#creating hog features | |
fd, hog_image = hog(resized_img, orientations=9, pixels_per_cell=(8, 8), | |
cells_per_block=(2, 2), visualize=True, multichannel=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fd.shape |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#importing required libraries | |
from skimage.io import imread, imshow | |
from skimage.transform import resize | |
from skimage.feature import hog | |
from skimage import exposure | |
import matplotlib.pyplot as plt | |
%matplotlib inline | |
#reading the image | |
img = imread('puppy.jpeg') | |
imshow(img) | |
print(img.shape) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#resizing image | |
resized_img = resize(img, (128,64)) | |
imshow(resized_img) | |
print(resized_img.shape) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(16, 8), sharex=True, sharey=True) | |
ax1.imshow(resized_img, cmap=plt.cm.gray) | |
ax1.set_title('Input image') | |
# Rescale histogram for better display | |
hog_image_rescaled = exposure.rescale_intensity(hog_image, in_range=(0, 10)) | |
ax2.imshow(hog_image_rescaled, cmap=plt.cm.gray) | |
ax2.set_title('Histogram of Oriented Gradients') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment