opencv - How to calculate 3D histogram in python using open CV -


i want calculate 3d histogram of cielab image in python. using opencv calculate histogram. want compare images using comparehist function of opencv, thats why using opencv compute 3d histogram of image.

i tried following variables:

i_lab = image.copy() i_lab = i_lab.astype(np.uint8) range_hist = [[0, 100], [-100, 100], [-100, 100]]     hist_1 = cv2.calchist([i_lab], [[0], [1], [2]], none, [[20], [20], [20]], range_hist) 

but gives error systemerror: error return without exception set please tell me doing wrong , if possible compute 3d histogram using opencv in python

i came across question while trying make 3d histogram of hsv image, , encountered same error. turns out opencv documentation leading astray here. docs written c++ api , such can used vague guide python cv2 api (although have found docs misleading c++ @ times).

the function signature follows:

cv2.calchist(images, channels, mask, histsize, ranges[, hist[, accumulate]]) -> hist 

the key point channels, histsize , ranges parameters should flat lists, not nested lists in example. try following, assuming i_lab three-channel image:

range_hist = [0, 100, -100, 100, -100, 100] hist_1 = cv2.calchist([i_lab], [0, 1, 2], none, [20, 20, 20], range_hist) 

for more complete example, try this code listing opencvpython blog.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -