ELI5: Histogram of Oriented Gradients
A Histogram of Oriented Gradients, or HOG, is a smart way for a computer to recognize the shape of an object in a picture by looking at the direction the edges are pointing.
Imagine you are using a coloring book. You do not need to see all the colors to know what the picture is; you can easily tell a cat from a car just by looking at the dark outlines. A computer uses HOG to do the exact same thing!
Here is how it works, step by step:
- Finding the Edges (Gradients): A computer sees an image as a giant grid of tiny colored dots called pixels. When a light pixel sits right next to a dark pixel, that sudden change creates an edge. In computer vision, this change in brightness is called a gradient.
- Checking the Direction (Orientation): Every edge points in a certain way. An edge might be straight up-and-down, flat across, or tilted diagonally. The computer checks which way every tiny edge is pointing.
- Counting in Small Boxes (Histogram): The computer chops the whole picture into small patches, like a checkerboard. Inside each little square, it counts how many edges are pointing up, down, left, or right. A tally chart that counts things like this is called a histogram.
- Putting the Puzzle Together: Finally, the computer combines the tallies from all the squares. This creates a simplified, blocky outline of the image made entirely of little arrows showing edge directions.
Why is this so useful?
Think about spotting a pedestrian crossing the street. A person might wear a red jacket, blue jeans, or a yellow hat. Colors change all the time! However, the basic outline of a human body—a round head on top, vertical lines for legs, and horizontal lines for shoulders—almost always stays the same.
Because HOG focuses purely on edge directions rather than colors or lighting, it helps computers easily spot people, cars, or animals, even if the picture is bright, shadowy, or taken from slightly different angles.
Ask your own question
Follow-up questions
Test yourself
Three quick questions to see if it stuck. You can challenge a friend after.
Get this entry by email
We'll send it to your inbox, plus one good explanation a week if you like.