Guest User

Untitled

a guest
Jan 17th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. Mat dest = new Mat (sections[i].rows(),sections[i].cols(),CvType.CV_8UC3);
  2. Mat hsv_image = new Mat (sections[i].rows(),sections[i].cols(),CvType.CV_8UC3);
  3.  
  4. Imgproc.cvtColor (sections[i],hsv_image,Imgproc.COLOR_BGR2HSV);
  5.  
  6. List <Mat> rgb = new List<Mat> ();
  7. Core.split (hsv_image, rgb);
  8. Imgproc.equalizeHist (rgb [1], rgb [2]);
  9. Core.merge (rgb, sections[i]);
  10. Imgproc.cvtColor (sections[i], dest, Imgproc.COLOR_HSV2BGR);
  11.  
  12. Core.split (dest, rgb);
  13.  
  14. ##(1) read into bgr-space
  15. img = cv2.imread("test.png")
  16.  
  17. ##(2) convert to hsv-space, then split the channels
  18. hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV)
  19. h,s,v = cv2.split(hsv)
  20.  
  21. ##(3) threshold the S channel using adaptive method(`THRESH_OTSU`)
  22. th, threshed = cv2.threshold(s, 100, 255, cv2.THRESH_OTSU|cv2.THRESH_BINARY)
  23.  
  24. ##(4) print the thresh, and save the result
  25. print("Thresh : {}".format(th))
  26. cv2.imwrite("result.png", threshed)
  27.  
  28.  
  29. ## >>> Thresh : 85.0
Add Comment
Please, Sign In to add comment