Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- image = cv2.imread("1.jpg")
- import numpy as np
- def viewImage(image, name_of_window):
- cv2.namedWindow(name_of_window, cv2.WINDOW_NORMAL)
- cv2.imshow(name_of_window, image)
- cv2.waitKey(0)
- cv2.destroyAllWindows()
- gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
- ret, threshold_image = cv2.threshold(gray_image, 127, 255, 0)
- viewImage(threshold_image, "Чёрно-белый пёсик")
- for y in range(0, threshold_image.shape[0]): #looping through each rows
- for x in range(0, threshold_image.shape[1]): #looping through each column
- if np.any(img[x, y] == 0):
- print(x, y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement