import cv2
import numpy as np
template = cv2.imread("d:\\zengfuji\\pic\\lena.bmp")
h,w = template.shape[:2]
center = (w//2,h//2)
M = cv2.getRotationMatrix2D(center, 60, 1)
rotated_template = cv2.warpAffine(template, M, (w, h))
rotated_template2 = cv2.warpAffine(template, M, (w, h),borderMode=cv2.INTER_LINEAR, borderValue=cv2.BORDER_REPLICATE)
rotated_template3 = cv2.warpAffine(template, M, (w, h),borderValue=(255,255,255))
cv2.imshow("rotated_template",rotated_template)
cv2.imshow("rotated_template2",rotated_template2)
cv2.imshow("rotated_template3",rotated_template3)
cv2.waitKey()
不做填充處理
BORDER_REPLICATE:復(fù)制邊緣填充
指定顏色填充