Translating my code from MATLAB I am trying to apply an affine transformation to georeference a TERRA-ASTER satellite image using Python 3,
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')
using a tranformation matrix from pairs of coordinates (src,dst) of the four scene corners.
# 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]])
using functions from the Skimage package
tform = tf.estimate_transform('affine',movingpoints,fixedpoints)
newnaivasha_rgb = tf.warp(naivasha_rgb,tform.inverse)
The tform is the same as in MATLAB but transposed but the warping creates a plane green image, not the one expected as in MATLAB (see WeTransfer link below).
newnaivasha_rgb = exposure.rescale_intensity(newnaivasha_rgb,
out_range='uint8')
plt.figure()
io.imshow(newnaivasha_rgb)
plt.axis('off')
plt.show()
Any ideas? The numerical values indicate a low-contrast or no image, depending whether I use tform or tform.inverse with tf.warp, according to solutions I googled.
Download of images from WeTransfer (50 MB) including input image naivasha.tif and output images naivasha_georef_python.png and naivasha_georef_matlab.jpg.