Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to plot histogram of an area inside a contour

Hi, i am using OpenCV and python. i have a contour. and i need histogram of that contour. there is no any build-in function. How can i plot the histogram of an area inside the contour?

How to plot histogram of an area inside a contour

Hi, i am using OpenCV and python. i have a contour. and can find the biggest contour biggest contour i need histogram of that contour. there this area. i tried this

 for c in cntrs:
        area = cv2.contourArea(c)
        if area > area_thresh:
            area = area_thresh
            big_contour = c
        if cntrs != None:
            results = fg.copy() #draw the contour on a copy of the input image
            cv2.drawContours(results,[big_contour],0,(0,0,255),2) # 2 is no any build-in function. How can i plot the histogram of thickness
            cv2.imshow('results', results)

       hist_item = cv2.calcHist([results],[cntrs],big_contour,[256],[0,255])

i see this error message: <built-in function calcHist> returned NULL without setting an area inside the contour?error