First, let's look at the image gradients around a sharp, high-contrast
edge in the image, like the one on the cover of the book:
(The black and yellow box outlines the region of the image we are
examining.) In this region the gradient vectors are almost all
pointing in the same direction:
In the above figure, the left half shows an X for the gradient vector
at each of the 19 x 19 = 361 pixels in the box; the right half shows a
histogram of the orientations of the gradient vectors, weighted by
their lengths. Notice that the gradient vectors do not point
along the edge, but normal to it. To decide which of the two
possible normals to use for a given edge, we are using the arbitrary
convention that the gradient vectors point from light-colored areas of
the image towards dark areas.
If we center the box on top of a sharp line in the image, the box will
contain two high-contrast edges pointing in opposite directions (one on
each side of the line):
In this situation there will be two peaks in the histogram, separated
by pi radians (180 degrees).
For comparison, we can look at the image gradients in a textureless
region of the image:
As expected, the image gradients are small and point in essentially
random directions. Note the difference in scale between this
histogram and the previous ones.
Now let's look at some more complicated areas of the image. What
should we expect if we look at gradients near a corner?
At a corner, there are two edges at approximately right angles to each
other (not exactly right angles because the surface of the desk is not
perpendicular to the direction that the camera is pointing). This
fact is reflected in the image gradients, most of which are orthogonal
to one of the two edges:
If the box contains a curved edge, like so:
then the image gradients will make a wedge, pointing in a range of
different directions depending on exactly where along the edge they
were taken:
(Exercise: do the gradient vectors at the left end of the wedge come
from the left or the right side of the box in the image?)
If we select out a cross in the image, there are four different strong
directions in the image:
Because the box only holds part of the cross, some of the directions
are weaker than others, but you can still see four main peaks in the
histogram of orientations:
Finally, if we select an area with lots of texture like the keys on the
desk:
then there will be edges pointing in all directions, and the histogram
will contain lots of energy but no strong peaks: