在Python中叠加不同维度的图像

时间:2015-02-24 21:58:45

标签: 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=(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)

感谢您的帮助!

0 个答案:

没有答案