opencv对图片旋转后,对黑色边界填充

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:复制边缘填充
指定颜色填充

你可能感兴趣的:(opencv对图片旋转后,对黑色边界填充)