opencv 欧拉变换

 

import cv2
import numpy as np

def euler_view_transformation(image, angle, scale, dx, dy):
    # 获取图像尺寸
    (h, w) = image.shape[:2]
    # 设置旋转矩阵
    center = (w // 2, h // 2)
    M = cv2.getRotationMatrix2D(center, angle, scale)
    # 应用旋转和缩放
    rotated = cv2.warpAffine(image, M, (w, h))
    # 应用平移
    translated = cv2.translate(rotated, dx, dy)
    return translated

# 读取图像
image = cv2.imread('path_to_your_image.jpg')

# 定义变换参数
angle = 30  # 旋转角度
scale = 1.5  # 缩放比例
dx = 50      # x方向平移
dy = 50      # y方向平移

# 应用欧拉视图变换
transformed_image = euler_view_transformation(image, angle, scale, dx, dy)

# 显示结果
cv2.imshow('Transformed Image', transformed_image)
cv2.waitKey(0)
cv2.destroyAllWindows()

 

 

 

#############################

posted @ 2024-06-30 21:37  西北逍遥  阅读(8)  评论(0编辑  收藏  举报