Extract transformation matrix from image distortion

9 views (last 30 days)
Hey, I have used the following code for image distortion using control points. I would like to extract the transformation matrix that has been applied to the distorted image using the imwarp function. Is there any way to extract the transformation matrix so I can apply the same transformation also to other images?
clc
clear all
close all
orthophoto = imread('cropped_image.tif');
figure, imshow(orthophoto)
unregistered = imread('cropped_image2.tif');
figure, imshow(unregistered)
[movingPoints, fixedPoints] = cpselect(unregistered,orthophoto,'Wait',true);
movingPoints
fixedPoints
pause
t = fitgeotrans(movingPoints, fixedPoints,'polynomial', 2);
Rfixed = imref2d(size(orthophoto));
registered = imwarp(unregistered,t,'OutputView',Rfixed);
imshow(registered)
imwrite(registered, 'undistorted_cropped_image2.tif');

Accepted Answer

Steve Eddins
Steve Eddins on 4 Nov 2020
In your call to fitgeotrans, you have specified that you want a 'polynomial' transformation. This type of transformation is not characterized by a matrix, at least not in the sense of an affine transform matrix. However, you can still use the output, t, in calls to imwarp to warp other images the same way.
In the call to fitgeotrans, if you specify a transform type that is characterized by a matrix, then you can retrieve the matrix using t.T.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!