如下所示:
import cv2
import math
import numpy as np
def move(img):
height, width, channels = img.shape
emptyImage2 = img.copy()
x=20
y=20
for i in range(height):
for j in range(width):
if i>=x and j>=y:
emptyImage2[i,j]=img[i-x][j-y]
else:
emptyImage2[i,j]=(0,0,0)
return emptyImage2
img = cv2.imread("e:\\lena.bmp")
cv2.namedWindow("Image")
SaltImage=move(img)
cv2.imshow("Image",img)
cv2.imshow("ss",SaltImage)
cv2.waitKey(0)
旋转:
import cv2
import math
import numpy as np
def XRotate(image, angle):
h, w, channels = image.shape
anglePi = angle * math.pi / 180.0
cosA = math.cos(anglePi)
sinA &