1

I would like to extract the Polygon Shape by color, if it's possible the corner coordinates, example of mask

Currently i'm trying with open-cv find contourns, but it's very precise i'm getting a lot of coordinates. what i want it's just the corner points to make the polygon by color.

img = cv2.imread('mask_ZT76_39_A_2_8.png', 0)
img = cv2.medianBlur(img, 5)
thresh =     cv2.adaptiveThreshold(img,255,cv2.ADAPTIVE_THRESH_GAUSSIAN_C,\
cv2.THRESH_BINARY,11,2)

image, contours, hierarchy = cv2.findContours(thresh.copy(),cv2.RETR_LIST,cv2.CHAIN_APPROX_SIMPLE)

cv2.drawContours(image, contours, -1, (0,255,0), 3)

approx_=[]

for i in range(len(contours[0])):
  epsilon = cv2.arcLength(contours[0][i],True)
  approx = cv2.approxPolyDP(contours[0][i],epsilon,True)

Thanks.

ambigus9
  • 1,417
  • 3
  • 19
  • 37

0 Answers0