GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing thepythoncode.com — How to Apply HOG Feature Extraction in Python - The Python Code Kickstart your coding journey with our Python Code Assistant. An AI-powered assistant that's always ready to help. Don't miss out! The Histogram of Oriented Gradients (HOG) is a feature descriptor used in computer vision and image processing applications for the purpose of object detection. It is a technique that counts events of gradient orientation in a specific portion of an image or region of interest. In 2005, Dalal and Triggs published a research paper named Histograms of Oriented Gradients for Human Detection. After the release of this paper, HOG is used in many object detection applications. Here are the most important aspects of HOG:
Resizing the ImageAs mentioned previously, if you have a wide image, then crop the image to the specific part in which you want to apply HOG feature extraction, and then resize it to the appropriate shape. Calculating GradientsNow, after resizing, we need to calculate the gradient in the x and y directions. The gradient simply involves small changes in the x and y directions; we must convolve two simple filters on the image. The filter for calculating the gradient in the x-direction is:
Calculating the MagnitudeTo calculate the magnitude of the gradient, the following formula is used:
Calculating the OrientationThe gradient direction is given by:
The magnitude will be:
Related: Mastering YOLO: Build an Automatic Number Plate Recognition System with OpenCV in Python. Python CodeNow that we understand the theory, let's look at how we can use scikit-image library to extract HOG features from images. First, let's install the necessary libraries for this tutorial:
I will perform HOG on a cute cat image, get it here, and put it in the current working directory (you can use any image you want, of course). Let's load the image and show it:
Output:
Output:
Output:
The
Finally, if you want to save the images:
ConclusionAlright, now you know how to perform HOG feature extraction in Python with the help of scikit-image library. Check the full code here. Related tutorials:
Happy Learning ♥ Just finished the article? Now, boost your next project with our Python Code Generator. Discover a faster, smarter way to code.
Sharing is caring!
Read alsoSIFT Feature Extraction using OpenCV in PythonLearn how to compute and detect SIFT features for feature matching and more using OpenCV library in Python. How to Detect Contours in Images using OpenCV in PythonLearning how to detect contours in images for image segmentation, shape analysis and object detection and recognition using OpenCV in Python. How to Detect Shapes in Images in Python using OpenCVDetecting shapes, lines and circles in images using Hough Transform technique with OpenCV in Python. Hough transform is a popular feature extraction technique to detect any shape within an image. CommentsGot a coding query or need some guidance before you comment? Check out this Python Code Assistant for expert advice and handy tips. It's like having a coding tutor right in your fingertips! |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |