在Python中叠加不同维度的图像
嗨,我想知道如何叠加两个不同分辨率和尺寸的图像(源和目标)来显示。实际上,我想旋转和平移这些图像,以便对齐它们,或者从技术上讲,注册两个图像在Python中叠加不同维度的图像,python,numpy,Python,Numpy,嗨,我想知道如何叠加两个不同分辨率和尺寸的图像(源和目标)来显示。实际上,我想旋转和平移这些图像,以便对齐它们,或者从技术上讲,注册两个图像 import numpy as np from scipy import ndimage img_source = np.random.randint(50, size=(150,250)) # distance between two pixels is 1 mm img_target = np.random.randint(900, size=(75
import numpy as np
from scipy import ndimage
img_source = np.random.randint(50, size=(150,250)) # distance between two pixels is 1 mm
img_target = np.random.randint(900, size=(750,900)) # distance between two pixels is 0.005 mm
# i do not know how to superimpose them
# may be import CV2
img_reg = cv2.addWeighted(img_source,0.8,img_target,0.3,0)
cv2.imshow('reg', img_reg)
# rotate target img if its not well aligned with source image
rotate_target = ndimage.rotate(img_target, 1, reshape=False)
谢谢你的帮助 什么样的图像?你知道图像之间有什么对应点吗?通常我在图像中绘制轮廓,并在没有任何特定点的情况下对齐它们。如果你认为如果有任何对应的点,这将很容易,我也可以在它们上创建。你可以使用将一个图像缩放到与另一个图像相同的分辨率。使用ndimage,它看起来像是在修改结果。我不想更改数据。