[Solved] How to calculate the number of shapes detected after thresholding

[ad_1]

Jeru’s answer is correct for this case. If you have a case with bigger noise where morpholigocal operations won’t take them out, you can make a cutoff with the contour size, something like

for contour in contours
    if cv2.contourArea(contour) > minimal_length

before counting

1

[ad_2]

solved How to calculate the number of shapes detected after thresholding