Advertisement
VladislavSavvateev

Untitled

Nov 3rd, 2021
1,170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.47 KB | None | 0 0
  1. import numpy as np
  2.  
  3.  
  4. def get_first_one_pixel(img):
  5.     for y in range(len(img)):
  6.         for x in range(len(img[0])):
  7.             if img[y, x] == 1:
  8.                 return y, x
  9.  
  10.  
  11. img1 = np.loadtxt('images/img1.txt', skiprows=2)
  12. img2 = np.loadtxt('images/img2.txt', skiprows=2)
  13.  
  14. img1_first_pixel = get_first_one_pixel(img1)
  15. img2_first_pixel = get_first_one_pixel(img2)
  16.  
  17. print(img1_first_pixel[0] - img2_first_pixel[0], img1_first_pixel[1] - img2_first_pixel[1])
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement