Before going deeper into histograms and how to construct and visualize them by using the OpenCV (and also NumPy and Matplotlib) functions related to histograms, we need to understand some terminologies in connection with histograms:
- bins: The histograms in the previous screenshot show the number of pixels (frequency) for every tonal value, ranging from 0 to 255. Each of these 256 values is called a bin in histogram terminology. The number of bins can be selected as desired. Common values are 8, 16, 32, 64, 128, 256. OpenCV uses histSize to refer to bins.
- range: This is the range of intensity values we want to measure. Normally, it is [0,255], corresponding to all the tonal values (0 corresponds to black and 255 corresponds to white).