You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
895 B
29 lines
895 B
# coding=gbk
|
|
import cv2
|
|
import numpy as np
|
|
|
|
def move1(filepath):#·ÅËõ
|
|
img = cv2.imread(filepath+'image1.png')
|
|
l, w, h = img.shape
|
|
img = cv2.resize(img, (0, 0), fx=2, fy=2, interpolation=cv2.INTER_LINEAR)
|
|
height, width, channel = img.shape
|
|
cv2.imwrite(filepath+'out.png', img)
|
|
|
|
def move2(filepath,x,y):#Æ½ÒÆ
|
|
img = cv2.imread(filepath + 'image1.png')
|
|
height, width, channel = img.shape
|
|
M = np.float32([[1, 0, x], [0, 1, y]])
|
|
img = cv2.warpAffine(img, M, (width, height))
|
|
cv2.imwrite(filepath + 'out.png', img)
|
|
|
|
def move3(filepath):#Ðýת
|
|
img = cv2.imread(filepath + 'image1.png')
|
|
M = cv2.getRotationMatrix2D((width / 2, height / 2), 45, 1)
|
|
dst = cv2.warpAffine(img, M, (width, height))
|
|
cv2.imwrite(filepath + 'out.png', img)
|
|
|
|
if __name__ == '__main__':
|
|
filepath = 'pic/'
|
|
move1(filepath)
|
|
move2(filepath,256,256)
|
|
move3(filepath) |