If you want to find the in-plane rotation between the two images, here is an example that does just that.
find the angle between two very similar pictures in matlab
-
28-06-2023 - |
Question
hi i find the angle between 2 similar(but not the same) pictures ?
i used
hVideoSrc = vision.VideoFileReader(filename, 'ImageColorSpace', 'Intensity');
imgA = step(hVideoSrc); % Read first frame into imgA
imgB = step(hVideoSrc); % Read second frame into imgB
figure; imshowpair(imgA, imgB, 'montage');
title(['Frame A', repmat(' ',[1 70]), 'Frame B']);
figure; imshowpair(imgA,imgB,'ColorChannels','red-cyan');
title('Color composite (frame A = red, frame B = cyan)');
from http://www.mathworks.com/help/vision/examples/video-stabilization-using-point-feature-matching.html but it not help anybody have a idia
Solution 3
OTHER TIPS
Just wanted to flag that an algorithm that is very similar to Patrick's suggestion exists in the Image Processing Toolbox as of R2014a. It is named imregcorr and uses phase-correlation in the log-polar domain. This might also work very well for this problem, I haven't tried it yet.
http://www.mathworks.com/help/images/ref/imregcorr.html
http://adessowiki.fee.unicamp.br/media/Attachments/courseIA369O1S2011/Ex13/phasecorrelation5.pdf
I'd recommend doing some sort of feature detection then using that to find a homography matrix. It might be overkill but at least you'll be able to not only find the rotation from one image with respect to another, but any shearing or translation as well.
Check the Feature Detection module that is part of the Computer Vision toolbox to help you with detecting keypoints: http://www.mathworks.com/help/vision/feature-detection-extraction-and-matching.html
Once you find pairs of corresponding points, take a look at rebuilding the homography matrix required to morph one image to another. These slides are awesome: http://www.comp.nus.edu.sg/~cs4243/lecture/camera.pdf . Look at slides 29 - 35.
Once you find the homography matrix then you can very easily determine the angle of rotation by examining the coefficients and applying an inverse trigonometric operation.
EDIT (April 7th, 2014): I couldn't find the actual MATLAB example, but the link by Dima (thanks!) shows you a worked out MATLAB example through MathWorks that does it (http://www.mathworks.com/help/vision/examples/find-image-rotation-and-scale-using-automated-feature-matching.html).
Do a correlation in log-polar coordinates. This gives you both scale and rotational measurements (the polar axis gives you the rotational component).
Here is one reference. This one describes the same method in the optical domain, but it is still very useful for visualization and understanding the method.