In this tutorial, you will learn how to compute image histograms using OpenCV and the

cv2.calcHistfunction.

Histograms are prevalent in nearly every aspect of computer vision.

We use grayscale histograms for thresholding. We use histograms for white balancing. We use color histograms for object tracking in images, such as with the CamShift algorithm.

We use color histograms as features — include color histograms in multiple dimensions.

And in an abstract sense, we use histograms of image gradients to form the HOG and SIFT descriptors.

Even the extremely popular bag-of-visual-words representation used in image search engines and machine learning is a histogram as well!

And in all likelihood, I’m sure this is not the first time you have run across histograms in your studies.

So, why are histograms so useful?

Because histograms capture the frequency distribution of a set of data. And it turns out that examining these frequency distributions is a very nice way to build simple image processing techniques … along with very powerful machine learning algorithms.

Inside this blog post you’ll receive an introduction to image histograms, including how to compute grayscale and color histograms. In future blog posts I’ll cover more advanced histogram techniques.

OpenCV Image Histograms ( cv2.calcHist )
1.45 GEEK