Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- import numpy as np
- img = cv2.imread("your_image.jpg")
- x,y=img.shape[:2]
- ma=max(x,y)
- blank = np.zeros((ma,ma,3), np.uint8)
- if y>x:
- blank[(y-x)/2:(y-x)/2+x,0:y]=img
- if x>y:
- blank[0:x,(x-y)/2:(x-y)/2+y]=img
- cv2.imshow('result', blank)
- cv2.imwrite("result.jpg",blank)
- cv2.waitKey(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement