How do I determine the angle, scale and translation between two images after imregister?

10 views (last 30 days)
I have one rotated, scaled, translated image and a fixed image. The output of imregister, t is shown:
[movingregistered] = imregister(fixed,moving,'similarity',optimizer,metric,'DisplayOptimization',1);
t = [1.001092e+00 -6.373544e-04 0.000000e+00;...
6.373544e-04 1.001092e+00 0.000000e+00;...
-1.351965e+00 5.672809e-01 1.000000e+00];
I need accurate subpixel knowledge of the offset and rotation of two images. Is t rotated about center pixel or upper left pixel (1,1). It is not sufficient to show the images "look" registered :) Using R2012B
What is the definition of the 9 elements of t?
Thanks, Howard
  1 Comment
Matt J
Matt J on 19 Jun 2013
Your code doesn't show how t was produced. It appears nowhere in your call to imregister. Did you call imregister with a 2nd output arg that you aren't showing?

Sign in to comment.

Answers (3)

Sean de Wolski
Sean de Wolski on 19 Jun 2013
You can use imregtform to get the transformation matrix:
doc imregtform
  8 Comments
Matt J
Matt J on 11 Jul 2013
Edited: Matt J on 11 Jul 2013
yes, I've done that now. I'm vaguely nervous, though, about tampering with factory-installed MATLAB directories. I'll be happier once I've upgraded to a version with imregtform!

Sign in to comment.


Matt J
Matt J on 19 Jun 2013
Edited: Matt J on 19 Jun 2013
Is t rotated about center pixel or upper left pixel (1,1).
After some experimentation with code (below) that duplicates the relevant portions of IMREGISTER, I think I can safely say that the rotation is about the upper left pixel.
M=100;N=M;
A=zeros(M);
A(1:M+1:50*(M+1))=1;
%30 degree rotation
t=[ 0.8660 -0.5000 0
0.5000 0.8660 0
0 0 1.0000];
B = imtransform(A, maketform('affine',t), 'XData', [1 N], 'YData', [1 M], ...
'Size', [M N]);
figure;imagesc(A)
figure; imagesc(B+A)

Howard
Howard on 10 Jul 2013
Edited: Matt J on 11 Jul 2013
If I use imtransform and then imregister I get transform matrix t which do not agree. What's up with that?
M=100;N=M; A=zeros(M);
A(1:M+1:50*(M+1))=1; %
t=[ 1.0 0 0
0 1.0 0
1.1 0 1.0000];
B = imtransform(A, maketform('affine',t), 'XData', [1 N], 'YData', [1 M], ...
'Size', [M N]);
figure; imagesc(B+A)
fixed = A;
moving = B;
[optimizer,metric] = imregconfig('monomodal'); %try monomodal
[movingregistered] = imregister(fixed,moving,'similarity',optimizer,metric,'DisplayOptimization',1, 'PyramidLevels',3);
But the output of imregister has a very different transform with cos values > 1.0
Use the resulting tform struct with imtransform.
t = [1.010712e+00 7.025940e-04 0.000000e+00;...
-7.025940e-04 1.010712e+00 0.000000e+00;...
1.817039e-01 -9.390789e-01 1.000000e+00];
  1 Comment
Matt J
Matt J on 11 Jul 2013
Edited: Matt J on 11 Jul 2013
This seems like a different question than what you originally posted. First, please confirm whether that question is still open. I thought I provided pretty convincing evidence that the rotation was about the upper left corner. If you agree, please Accept-click that answer and start a new question. If you don't agree, please explain why the question is unanswered.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!