Generates an image in which the intensity of each pixel indicates the difference (histogram intersection) between histograms that are collected over rectangular areas that touch each other at the pixel.
In the illustration below, the horizontal gradient for the pixel marked with an “X” is obtained by calculating the intersection of histograms collected from the two areas to the left and right of it. Note that the pixel itself will be included in neither of the histograms.
+-------+ +-------+ | | | | | |X| | | | | | +-------+ +-------+
image: Input image. Must be 8-bit gray, other types are not supported.
windowSize: The size of the window over which the histogram is calculated, in pixels.
direction: The direction of the gradient.
gradient: The gradient as an 8-bit image. 0 means no difference, 255 means maximum difference. The output image will be smaller than the input. If windowSize is too large, the output may be an empty image.