What is an image histogram and how does histogram equalization improve contrast?
Whether you understand intensity distributions and CDF-based remapping.
Define a histogram as pixel counts per intensity; explain equalization normalizes the CDF to spread intensities across the full range.
WHAT THIS TESTS: This question checks whether you understand the statistical representation of image intensities and the signal-processing mechanics behind contrast enhancement. Interviewers want to see that you can move beyond API calls like cv::equalizeHist and explain the underlying cumulative distribution function remapping that makes the technique work. At the senior level, they also care whether you recognize when the method succeeds and when it fails.
A GOOD ANSWER COVERS: A strong response starts by defining an image histogram as a graphical representation that quantifies the number of pixels for each intensity value in the image. Next, it explains that histogram equalization is a method to improve contrast by stretching the intensity range. The core mechanism is computing the cumulative distribution function from the histogram, normalizing that CDF so its maximum equals the highest possible intensity such as 255, and then using that normalized CDF as a lookup table to remap every pixel. This redistributes pixel intensities toward a more uniform spread across the full range, which is especially effective when the original image has low contrast because its pixels are clustered in a narrow band of intensities.
COMMON WRONG ANSWERS: A common red flag is describing equalization as simply brightening the image or multiplying all pixels by a constant. Another mistake is confusing histogram equalization with linear contrast stretching, which only scales the min and max values without considering the actual probability distribution of intensities. Candidates also err by claiming the output histogram is perfectly flat; in practice, discrete quantization prevents a perfectly uniform distribution.
LIKELY FOLLOW-UPS: An interviewer might ask when you would avoid histogram equalization, such as in images where contrast differences are subtle but meaningful and should not be flattened. They may also ask about adaptive histogram equalization, CLAHE, or how to handle color images by converting to a color space like HSV and equalizing only the value channel rather than applying the operation independently to BGR channels.
ONE CONCRETE EXAMPLE: Consider an eight-bit grayscale image where most pixels fall between intensity 100 and 150, making it look dull and gray. The histogram shows a tall spike in that middle range with almost no pixels near 0 or 255. Histogram equalization computes the cumulative sum of that histogram, normalizes it to 255, and builds a transfer function. A pixel at intensity 100 might map to 50, while a pixel at 150 might map to 200. The result is an image that uses the full 0 to 255 spectrum, revealing details that were previously hidden in similar gray tones.
Read the original → docs.opencv.org
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.