Apress / practical-computer-vision-applications

Source Code for 'Practical Computer Vision Applications Using Deep Learning with CNNs' by Ahmed Fawzy Mohamed Gad
42 stars 21 forks source link

Page 36. skimage.feature.hog #2

Open alrovan opened 5 years ago

alrovan commented 5 years ago

Hi Ahmed, really enjoying the book.

There's a small errata at page 36 with line of code skimage.feature.hog(...) --> visualise should be visualize and normalise is not a parameter in this descriptor.

Here's the example code I used: ` import skimage.io import skimage.feature import numpy import matplotlib.pyplot as plt from skimage import data, exposure

img = skimage.io.imread("dog.jpg") if img.ndim > 2: img= img[:,:,0]

fd, hog_image = skimage.feature.hog(img, orientations=9, pixels_per_cell=(8,8), cells_per_block=(3,3), visualize=True, transform_sqrt=False)

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

ax1.axis('on') ax1.imshow(img, cmap=plt.cm.gray) ax1.set_title('Input image')

hog_image_rescaled = exposure.rescale_intensity(hog_image, in_range=(0, 10))

ax2.axis('on') ax2.imshow(hog_image_rescaled, cmap=plt.cm.gray) ax2.set_title('Histogram of Oriented Gradients') plt.show() `

Great book. I recommend.

ahmedfgad commented 5 years ago

Hi,

Thanks for taking care of preparing this code. I reviewed the latest documentation of this function here (https://scikit-image.org/docs/dev/api/skimage.feature.html#hog) and all as you said. I just want to clarify that the names of the arguments might change from one version to another. This happened in the book in the matplotlib.pyplot.bar() function. The first argument I used is named left and it is replaced by the argument x in the latest version. At all, thank you for recommending the book. You are welcome to more wonderful reviews like that.