0

輪郭マスクの塗りつぶし領域を見つけようとしています。33 の等高線に対して同じ値を生成するだけです。

これは、グレースケール イメージを 0 と 255 にしきい値処理した後です。

contours, hier = cv.findContours(green, cv.RETR_LIST, cv.CHAIN_APPROX_TC89_L1)
cv.drawContours(img_contours, contours, -1, (0,255,0), cv.FILLED)

cv.imwrite(filepath + imgname  + '_green' + '_countours3' + imgtyp, img_contours)

contours, hier = cv.findContours(green, cv.RETR_LIST,cv.CHAIN_APPROX_TC89_L1)
cv.drawContours(img_contours, contours, -1, (0,255,0), cv.FILLED)

cv.imwrite(filepath + imgname  + '_green' + '_countours3' + imgtyp, img_contours)



for contour in contours:
    area = cv.contourArea(cnt)
    print (area)

結果:

33
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
392.5
4

0 に答える 0