Advertisement
Guest User

Untitled

a guest
Feb 21st, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. img = cv2.resize(img, (0,0), fx=2, fy=2)
  2.  
  3. gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
  4. ret, thresh = cv2.threshold(gray_img, 127, 255, 1)
  5. _, contours , _= cv2.findContours(thresh, cv2.RETR_TREE, 1)
  6.  
  7. cnt = contours
  8. for i in range(len(contours)):
  9.  
  10. #---- Mark contours above certain area ----
  11. if (cv2.contourArea(cnt[i]) > 1500):
  12. final_image = cv2.drawContours(img, cnt[i], -1, (0,255,0), 3)
  13.  
  14. cv2.imshow('Marked image', final_image )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement