从 MATLAB 翻译我的代码我正在尝试使用 Python 3 应用仿射变换来地理配准 TERRA-ASTER 卫星图像,
import numpy as np
import matplotlib.pyplot as plt
from skimage import transform as tf
from skimage import io, exposure
naivasha_rgb = io.imread('naivasha.tif')
使用来自四个场景角的坐标对 (src,dst) 的变换矩阵。
# upper left
# lower left
# upper right
# lower right
movingpoints = np.array([
[36.214332,-0.319922],
[36.096003,-0.878267],
[36.770406,-0.400443],
[36.652213,-0.958743]])
fixedpoints = np.array([
[0,0],
[0,4200],
[4100,0],
[4100,4200]])
使用 Skimage 包中的函数
tform = tf.estimate_transform('affine',movingpoints,fixedpoints)
newnaivasha_rgb = tf.warp(naivasha_rgb,tform.inverse)
tform 与 MATLAB 中的相同,但经过转置,但翘曲会创建平面绿色图像,而不是 MATLAB 中的预期图像(请参阅下面的 WeTransfer 链接)。
newnaivasha_rgb = exposure.rescale_intensity(newnaivasha_rgb,
out_range='uint8')
plt.figure()
io.imshow(newnaivasha_rgb)
plt.axis('off')
plt.show()
有任何想法吗?根据我搜索的解决方案,数值表示低对比度或没有图像,具体取决于我使用 tform 还是 tform.inverse 和 tf.warp。
从WeTransfer (50 MB) 下载图像,包括输入图像 naivasha.tif 和输出图像 naivasha_georef_python.png 和 naivasha_georef_matlab.jpg。