How do I determine the angle, scale and translation between two images after imregister?
Mostrar comentarios más antiguos
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 comentario
Matt J
el 19 de Jun. de 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?
Respuestas (3)
Sean de Wolski
el 19 de Jun. de 2013
You can use imregtform to get the transformation matrix:
doc imregtform
8 comentarios
Sean de Wolski
el 19 de Jun. de 2013
Ah!
Well, good reason to upgrade :)
Well, if I could allow myself to vent for just a moment, I really think they should back-patch this into R2012 or whenever imregister was introduced. A registration routine without the ability to return the transformation parameters is like a 3-wheeled car.
Sean de Wolski
el 19 de Jun. de 2013
You can go into imregister and add the transformation matrix as an output.
Matt J
el 19 de Jun. de 2013
You can go into imregister and add the transformation matrix as an output.
That was easier than I thought!
Matt J
el 11 de Jul. de 2013
Actually, not so easy. The toolbox installs with permission barriers on imregister and its directory. I guess I could de-activate those, but I would have prefered to make my own separate local copy. No good, though, because imregister relies on private directory files.
Sean de Wolski
el 11 de Jul. de 2013
You could make a local copy in that directory. That way it has access to the private files.
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)
1 comentario
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.
Categorías
Más información sobre Image Transforms en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!