Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. import cv2
  2. image = cv2.imread("1.jpg")
  3. import numpy as np
  4.  
  5. def viewImage(image, name_of_window):
  6. cv2.namedWindow(name_of_window, cv2.WINDOW_NORMAL)
  7. cv2.imshow(name_of_window, image)
  8. cv2.waitKey(0)
  9. cv2.destroyAllWindows()
  10.  
  11.  
  12. gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
  13. ret, threshold_image = cv2.threshold(gray_image, 127, 255, 0)
  14. viewImage(threshold_image, "Чёрно-белый пёсик")
  15.  
  16. for y in range(0, threshold_image.shape[0]): #looping through each rows
  17. for x in range(0, threshold_image.shape[1]): #looping through each column
  18. if np.any(img[x, y] == 0):
  19. print(x, y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement