Python 打开CV贴图面片到图像

Python 打开CV贴图面片到图像,python,opencv,affinetransform,Python,Opencv,Affinetransform,我有下面的情况,我有一个高度贴图,在它的仿射贴图之后提取了几个面片,然后我对面片应用了颜色贴图,现在我需要做的是在校正的坐标处将面片混合到高度贴图上。我该怎么做?下面是我用来做变换的函数,基本上我需要求逆 def extract_patch(image, center, theta, width, height): vx = (np.cos(theta), np.sin(theta)) vy = (-np.sin(theta), np.cos(theta)) sx = c

我有下面的情况,我有一个高度贴图,在它的仿射贴图之后提取了几个面片,然后我对面片应用了颜色贴图,现在我需要做的是在校正的坐标处将面片混合到高度贴图上。我该怎么做?下面是我用来做变换的函数,基本上我需要求逆

def extract_patch(image, center, theta, width, height):
    vx = (np.cos(theta), np.sin(theta))
    vy = (-np.sin(theta), np.cos(theta))
    sx = center[0] - vx[0] * (width / 2) - vy[0] * (height / 2)
    sy = center[1] - vx[1] * (width / 2) - vy[1] * (height / 2)

    mapping = np.array([[vx[0],vy[0], sx], [vx[1],vy[1], sy]])
    return cv2.warpAffine(image, mapping, (width, height), flags = cv2.WARP_INVERSE_MAP, borderMode = cv2.BORDER_REPLICATE)