Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- hsv = cv2.cvtColor(image, cv2.cv.CV_BGR2HSV)
- cv2.imshow('hsv', hsv[:,:,0])
- (thresh, im_bw) = cv2.threshold(hsv[:,:,0], 128, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
- cv2.imshow('OTSU', im_bw)
- # Smooth image
- smoothed = cv2.adaptiveThreshold(input_image.astype(np.uint8), 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY, 41, 3)
- # Some morphology to clean up image
- kernel = np.ones((5,5),np.uint8)
- opening = cv2.morphologyEx(smoothed, cv2.MORPH_OPEN, kernel)
- closing = cv2.morphologyEx(opening, cv2.MORPH_CLOSE, kernel)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement