2

Say I have the X-Y coordinates of a certain point in an image.

Then, I perform a non-deforming registration on this image using 'similarity' optimization.

Now I would like to calculate the new X-Y coordinates that correspond with the same point in the image (after registration).

I bet there should be a way to do so by using tform / the spatial referencing object / something similar...

Does anyone know how to do this?

Dan
  • 45,079
  • 17
  • 88
  • 157
Noga
  • 41
  • 2
  • 2
    It should be as simple as multiplying the transformation matrix with your coordinates (and then probably applying some interpolation since you'll likely land up "between" pixels). It would help a lot if you provided some code and also an example of the transformation matrix.... – Dan Jul 27 '15 at 10:31

1 Answers1

2

Given a rigid transformation that is represented in MATLAB as an affine2d object, you can calculate the new XY points that correspond to the location in the output space of the transformed image by calling the transformPointsForward method of affine2d.

For example:

fixed  = imread('cameraman.tif');
theta = 20;
S = 2.3;
tform = affine2d([S.*cosd(theta) -S.*sind(theta) 0; S.*sind(theta)     S.*cosd(theta) 0; 0 0 1]);
moving = imwarp(fixed,tform);
moving = moving + uint8(10*rand(size(moving)));
tformEstimate = imregcorr(moving,fixed);
[x_out,y_out] = transformPointsForward(tformEstimate,10,20)

Also, if you want to transform in the opposite direction (from the output space to the input space), you can similarly use the transformPointsInverse method.

[u_out,v_out] = transformPointsInverse(tformEstimate,x_out,y_out)
Alex Taylor
  • 1,402
  • 1
  • 9
  • 15