Backprojection not working when tried with BGR instead of HSV
I tried using BGR
instead of using HSV
for both ROI
and target
on code as on Histogram - 4 : Histogram Backprojection. Even after making changes for the 3 channels for BGR. I'm not finding any difference
Here's the changed code
# calculating object histogram
roihist = cv2.calcHist([roi],[0, 1, 2], None, [256,256,256], [0, 256, 0, 256, 0, 256] )
# normalize histogram and apply backprojection
cv2.normalize(roihist,roihist,0,255,cv2.NORM_MINMAX)
dst = cv2.calcBackProject([target],[0,1,2],roihist,[0,256,0,256,0,256],1)
# Now convolute with circular disc
disc = cv2.getStructuringElement(cv2.MORPH_ELLIPSE,(5,5))
cv2.filter2D(dst,-1,disc,dst)
# threshold and binary AND
ret,thresh = cv2.threshold(dst,50,255,0)
thresh = cv2.merge((thresh,thresh,thresh))
res = cv2.bitwise_and(target,thresh)
Can anyone explain why is it not working with BGR
and only with HSV
?
Are you sure that 's OK in HSV? @berak i think there is a bug in opencv-python when you give three channels
My program is
thresh image is black. In c++ I have got a good result.
when I set
result is good. I don't understand what is wrong in 3D
ok, i can reproduce it. (but no idea, so far)
I think problem is https://github.com/opencv/opencv/blob... . I don't call this function in C++ I call https://docs.opencv.org/master/d6/dc7...