Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. import cv2
  2. import numpy as np
  3.  
  4. path = 'test.jpg'
  5. img = cv2.imread(path,0)
  6.  
  7. print(img)
  8. height,width = img.shape # 440 * 455
  9.  
  10. new_arr = np.zeros((height+2,width+2), dtype = int)
  11.  
  12. #for i in range(height):
  13. # for j in range(width):
  14. # new_arr[i+1][j+1] = img[i][j]
  15.  
  16. new_arr[1:height+1,1:width+1] = img
  17. print(new_arr)
  18.  
  19.  
  20. cv2.imshow('new image',new_arr)
  21. cv2.waitKey(0)
  22. cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement