Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. import numpy as np
  2. import cv2 as cv
  3. from matplotlib import pyplot as plt
  4. import sys
  5. np.set_printoptions(threshold=sys.maxsize)
  6. ig1 = cv.imread('i2.jpg', 0)
  7. ic1 = cv.imread('i2.jpg', 1)
  8. ig2 = cv.imread('i1.png', 0)
  9. ic2 = cv.imread('i1.png', 1)
  10.  
  11. blue1 = ic1[:, :, 0]
  12. blur = cv.GaussianBlur(blue1, (5, 5), 0)
  13. trash, masker = cv.threshold(blur, 0, 255, cv.THRESH_BINARY + cv.THRESH_OTSU)
  14. mask1 = np.ones(blue1.shape, np.uint8)*255
  15. contours, trash = cv.findContours(
  16. masker, cv.RETR_TREE, cv.CHAIN_APPROX_SIMPLE)
  17. cv.drawContours(mask1, contours, -1, (0,0,0),-1)
  18. mcol = cv.mean(ic1, mask=mask1)
  19.  
  20. ic2 = cv.cvtColor(ic2, cv.COLOR_BGR2HSV)
  21. ic2[:, :, 2] = 0
  22. ic2[:, :, 0] = ic2[:, :, 0]*8
  23. """ sat2 = ic2[:, :, 1]
  24. sat2 = np.divide(sat2, 2*256)
  25. # print(sat2)
  26. hue2 = ic2[:, :, 0]
  27. hue2 = hue2 * 4+sat2
  28. maxo = 0
  29. for x in hue2:
  30. for y in x:
  31. if (y > maxo):
  32. maxo = y
  33. print(maxo) """
  34. cv.imshow('1', ic2)
  35. cv.waitKey(0)
  36. cv.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement