Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Hands-On Image Processing with Python

You're reading from  Hands-On Image Processing with Python

Product type Book
Published in Nov 2018
Publisher Packt
ISBN-13 9781789343731
Pages 492 pages
Edition 1st Edition
Languages
Author (1):
Sandipan Dey Sandipan Dey
Profile icon Sandipan Dey

Table of Contents (20) Chapters

Title Page
Copyright and Credits
Dedication
About Packt
Contributors
Preface
Getting Started with Image Processing Sampling, Fourier Transform, and Convolution Convolution and Frequency Domain Filtering Image Enhancement Image Enhancement Using Derivatives Morphological Image Processing Extracting Image Features and Descriptors Image Segmentation Classical Machine Learning Methods in Image Processing Deep Learning in Image Processing - Image Classification Deep Learning in Image Processing - Object Detection, and more Additional Problems in Image Processing Other Books You May Enjoy Index

Histogram of Oriented Gradients


A popular feature descriptor for object detection is the Histogram of Oriented Gradients (HOG). In this section, we will discuss how HOG descriptors can be computed from an image.

Algorithm to compute HOG descriptors

The following steps describe the algorithm:

  1. If you wish to, you can globally normalize the image
  2. Compute the horizontal and vertical gradient images
  3. Compute the gradient histograms
  4. Normalize across blocks
  5. Flatten into a feature descriptor vector

HOG descriptors are the normalized block descriptors finally obtained by using the algorithm. 

Compute HOG descriptors with scikit-image

Let's now compute the HOG descriptors using the scikit-image feature module's hog() function and visualize them:

from skimage.feature import hog
from skimage import exposure
image = rgb2gray(imread('../images/cameraman.jpg'))
fd, hog_image = hog(image, orientations=8, pixels_per_cell=(16, 16), cells_per_block=(1, 1), visualize=True) 
print(image.shape, len(fd))
# ((256L, 256L),...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}