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
?