opencv仿射变换

代码如下:

复制代码
import numpy as np
import cv2


# 读取图像
img = cv2.imread("../image/dog.jpg")
# 图像平移
height, width = img.shape[:2]
# 创建平移矩阵,[1, 0, 100] 表示 x 轴平移 100 个像素,[0, 1, 50] 表示 y 轴平移 50 个像素
translation_matrix = np.float32([[1, 0, 100], [0, 1, 50]])
# 应用平移变换
translated_img = cv2.warpAffine(img, translation_matrix, (width, height))


# 结果
# 显示平移后的图像
cv2.imshow("Translated img", translated_img)
# 显示原始图像
cv2.imshow("original", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
相关推荐
困死,根本不会14 小时前
OpenCV摄像头实时处理:基于 HSV 颜色空间的摄像头实时颜色筛选工具
人工智能·opencv·计算机视觉
Shirley~~14 小时前
Vue-skills的中文文档
前端·人工智能
华大哥14 小时前
AI大模型基于LangChain 进行RAG与Agent智能体开发
人工智能·langchain
Sagittarius_A*14 小时前
角点检测:Harris 与 Shi-Tomasi原理拆解【计算机视觉】
图像处理·人工智能·python·opencv·计算机视觉
困死,根本不会14 小时前
OpenCV实时摄像头处理:曝光调节、降噪与二值化实战
人工智能·opencv·计算机视觉
LitchiCheng14 小时前
Mujoco 开源机械臂 RL 强化学习避障、绕障
人工智能·python·开源
A先生的AI之旅14 小时前
2026-1-30 LingBot-VA解读
人工智能·pytorch·python·深度学习·神经网络
Learn Beyond Limits14 小时前
文献阅读:A Probabilistic U-Net for Segmentation of Ambiguous Images
论文阅读·人工智能·深度学习·算法·机器学习·计算机视觉·ai
丝瓜蛋汤14 小时前
微调生成特定写作风格助手
人工智能·python
OpenMiniServer15 小时前
电气化能源革命下的社会
java·人工智能·能源