Respected All,
I am using watershed algorithm in the attached image, now I want to find the size of the enclosed boundary image (irregular object in the image).
Respected All,
I am using watershed algorithm in the attached image, now I want to find the size of the enclosed boundary image (irregular object in the image).
Update:
In OpenCV 3.4 , cv2.findContours
returns image, contours, hierarchy
cv2.findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> image, contours, hierarchy
In OpenCV 4.0, cv2.findContours
returns contours, hierarchy
cv2.findContours(image, mode, method[, contours[, hierarchy[, offset]]]) -> contours, hierarchy
So to find contours in a threshed binary image, and calculate the areas, use:
cnts= cv.findContours(threshed, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)[-2]
for cnt in cnts:
area = cv2.contourArea(cnt)
print(area)