Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Mat dest = new Mat (sections[i].rows(),sections[i].cols(),CvType.CV_8UC3);
- Mat hsv_image = new Mat (sections[i].rows(),sections[i].cols(),CvType.CV_8UC3);
- Imgproc.cvtColor (sections[i],hsv_image,Imgproc.COLOR_BGR2HSV);
- List <Mat> rgb = new List<Mat> ();
- Core.split (hsv_image, rgb);
- Imgproc.equalizeHist (rgb [1], rgb [2]);
- Core.merge (rgb, sections[i]);
- Imgproc.cvtColor (sections[i], dest, Imgproc.COLOR_HSV2BGR);
- Core.split (dest, rgb);
- ##(1) read into bgr-space
- img = cv2.imread("test.png")
- ##(2) convert to hsv-space, then split the channels
- hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
- h,s,v = cv2.split(hsv)
- ##(3) threshold the S channel using adaptive method(`THRESH_OTSU`)
- th, threshed = cv2.threshold(s, 100, 255, cv2.THRESH_OTSU|cv2.THRESH_BINARY)
- ##(4) print the thresh, and save the result
- print("Thresh : {}".format(th))
- cv2.imwrite("result.png", threshed)
- ## >>> Thresh : 85.0
Add Comment
Please, Sign In to add comment