图像平移 cv.warpAffine()函数用法


 

# 图像平移
image1='C:\\Users\\10107472\\Desktop\\myfile\\tensorflow-yolov\\read.jpg'
img = cv.imread(image1,0)
rows,cols = img.shape
print('image_original=',img.shape)
M = np.float32([[1,0,100],[0,1,50]]) # 平移矩阵
dst = cv.warpAffine(img,M,(300,420)) # img为需要变换的图像,M为需要平移的位置,(300,420)为平移后图像尺寸
print('dst.shape=',dst.shape)
cv.imshow('original img',img)
cv.imshow('change img',dst)
cv.waitKey(0)
cv.destroyAllWindows()

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM