Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. hsv = cv2.cvtColor(image, cv2.cv.CV_BGR2HSV)
  2. cv2.imshow('hsv', hsv[:,:,0])
  3. (thresh, im_bw) = cv2.threshold(hsv[:,:,0], 128, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
  4. cv2.imshow('OTSU', im_bw)
  5.  
  6. # Smooth image
  7. smoothed = cv2.adaptiveThreshold(input_image.astype(np.uint8), 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 41, 3)
  8.  
  9. # Some morphology to clean up image
  10. kernel = np.ones((5,5),np.uint8)
  11. opening = cv2.morphologyEx(smoothed, cv2.MORPH_OPEN, kernel)
  12. closing = cv2.morphologyEx(opening, cv2.MORPH_CLOSE, kernel)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement