Horizontal and Vertical Image Gradients
The inspector wants to find a vertical boundary around a scratch.
Horizontal and Vertical Image Gradients explained visually
The inspector wants to find a vertical boundary around a scratch. English captions are optional and start off. The complete transcript follows the written lesson.
What you will learn
The inspector wants to find a vertical boundary around a scratch.
A practical question
The scratch on our metal part has a dark line beside a bright surface. Where exactly does the brightness change? Look across the image from left to right, then from top to bottom. A horizontal gradient measures change across columns; a vertical gradient measures change across rows. Those names describe the direction of measurement, not the direction of the edge itself.
The useful idea
A vertical boundary often produces a strong horizontal gradient because we cross it while moving sideways. A horizontal boundary often produces a strong vertical gradient. Combine both responses to estimate how strong a change is, and which way the image values change most quickly. The direction of the edge runs across that change.
Work through the example
Let's compare a clean straight boundary with a patch of bright surface texture. Both can give us large gradient values. A gradient says that nearby measurements differ; it cannot tell us that the difference is a scratch. Look at the original image next to each response and check where genuine marks occur.
Limits and next step
Keep the gradients in their original numeric range while calculating. If you clip negative changes too early, you can erase one direction of a boundary. Our map now shows likely changes, but those responses can still be several pixels wide. Next, we'll make them thin enough to locate an edge.
Worked example
Combine horizontal and vertical responses to estimate edge strength and direction.
Quick check: test your understanding
Try it yourself: In the situation described above, explain the method and one reason its output might be misleading.
Check the reasoning
Horizontal and vertical derivatives measure intensity change across each axis. A bright texture can create gradients without being the target object.
What is the main idea behind horizontal and vertical image gradients?
Horizontal and vertical derivatives measure intensity change across each axis.
How is it used in the example?
Combine horizontal and vertical responses to estimate edge strength and direction.
What limitation should be checked?
A bright texture can create gradients without being the target object.
Further reading
Digital Image Processing, 4th edition — Rafael C. Gonzalez and Richard E. Woods.
Original ToolsInVision teaching examples. Editorial approach · Suggest a correction
Accessible referenceLesson 33 transcript216 words · Video transcript · Matches the published narration and captionsOpen transcript
The scratch on our metal part has a dark line beside a bright surface. Where exactly does the brightness change? Look across the image from left to right, then from top to bottom. A horizontal gradient measures change across columns; a vertical gradient measures change across rows. Those names describe the direction of measurement, not the direction of the edge itself.
A vertical boundary often produces a strong horizontal gradient because we cross it while moving sideways. A horizontal boundary often produces a strong vertical gradient. Combine both responses to estimate how strong a change is, and which way the image values change most quickly. The direction of the edge runs across that change.
Let's compare a clean straight boundary with a patch of bright surface texture. Both can give us large gradient values. A gradient says that nearby measurements differ; it cannot tell us that the difference is a scratch. Look at the original image next to each response and check where genuine marks occur.
Keep the gradients in their original numeric range while calculating. If you clip negative changes too early, you can erase one direction of a boundary. Our map now shows likely changes, but those responses can still be several pixels wide. Next, we'll make them thin enough to locate an edge.