I want to calculate 3D histogram of my Cielab image in python. I am using openCV to calculate my histogram. I want to compare images using compareHist
function
For computing a histogram in cielab, this worked for me:
function signature of calcHist: images, channels, mask, number of bins, array of the dims arrays of the histogram bin boundaries in each dimension.
img = cv2.imread(file) # in bgr
hist = cv2.calcHist([img],[0, 1, 2],None,[256, 256, 256],[0, 255, 0, 255, 0, 255]) # in bgr
img = cv2.cvtColor(img, cv2.COLOR_BGR2LAB) # in lab
hist = cv2.calcHist([img],[0, 1, 2],None,[100, 2*128, 2*128],[0, 100, -128, 127, -128, 127])`# in lab
correlation = cv2.HISTCMP_CORREL # compare histograms using correlation
corr = cv2.compareHist(img, img2, correlation)