2D Histogram
One dimensional histogram only needs to consider gray value, but 2D histogram needs to consider hue and saturation.
2D histogram in OpenCV
The parameters of cv2.calcHist() method are different between one-dimensional histogram and 2D histogram,parameters should be modified as follows:
- channels = [0, 1] :We need to deal with both H and S channels at the same time
- bins = [180, 256]: 180 for H channel and 256 for S channel
- range = [0, 180, 0, 256]: The value range of H is 0 to 180, and the value range of S is 0 to 256
import cv2
import numpy