Effacer les filtres
Effacer les filtres

Rotation angle between two images

2 vues (au cours des 30 derniers jours)
laura kenny
laura kenny le 21 Juil 2016
I would like to determine the angle of rotation between two images. Each image consists of clearly visible horizontal and vertical lines. This results in the magnitude plot of the fft having clearly defined vertical and horizontal energy components, which are orthogonal.
How can I determine the angle of the vertical and horizontal energy components, which will directly give me the rotation angle of the image, from unrotated state.
Here's my code to get the FFT of the image and plot the magnitude of the fft. Please help me determine the angle of the energy lines in the magnitude plot.
%Read in image and set to Black and White
BW = imread('BW.jpg');
BW = rgb2gray(BW);
%FFT of image
F = fft2(BW);
F = fftshift(F); % Center FFT
%Magnitude of FFT of image
F = abs(F); % Get the magnitude
F = log(F+1); % Use log, for perceptual scaling, and +1 since log(0) is undefined
F = mat2gray(F); % Use mat2gray to scale the image between 0 and 1
imshow(F,[]); % Display the result

Réponses (1)

Michael Byrne
Michael Byrne le 14 Août 2017
One way this might be accomplished is to test the similarity of rotated images against the image in question for varying angles of rotation. In the context of the images you attached, you could rotate fft0.jpg using the function imrotate for angles between 0 and 359 degrees and use functions such as ssim, psnr, or immse to determine which angle of rotation produces the image most similar to fft45.jpg (which would be 45 degrees). You can find more info about these similarity functions here.

Catégories

En savoir plus sur Geometric Transformation and Image Registration dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by