mirror image with frequency domain

How can I obtain a mirrir image with frequency domain? It probably some kind of manipulation of fft2, but which one?

Respuestas (1)

David Young
David Young el 18 de Nov. de 2011
Essentially you just flip left to right, using for example fliplr, as you would in the space domain, except that you need to move the zero-frequency column back to the left of the matrix, and also restore the origin back in the space domain.
For example
% get a test image
im = double(imread('pout.tif'))/256;
% move to the frequency domain
fim = fft2(im);
% mirror image in the frequency domain
% circshift one column to the right corrects the origin
fim_mirror = circshift(fliplr(fim), [0 1]);
% back to the space domain to see if it worked
% circshift one column to the left corrects the origin
im_mirror = circshift(ifft2(fim_mirror), [0 -1]);
% compare differences to check result, and display the image
max(max(abs(im - fliplr(im_mirror))))
imshow(im);
figure;
imshow(im_mirror);
If the final one-column shift in the space domain needs to be done in the frequency domain also, you can just multiply by a phase factor.

4 comentarios

Michael Shapira
Michael Shapira el 19 de Nov. de 2011
Great!!
Exactly what I needed. Do you also know by the chance how to rotate the image in frequency domain?
Image Analyst
Image Analyst el 19 de Nov. de 2011
Just flip it again. There is a flipud() function. Now that you've seen David's nice demo, it should be a simple straightforward modification. Course, you can just use it directly on the spatial domain image directly rather than doing it in the Fourier domain.
Michael Shapira
Michael Shapira el 26 de Nov. de 2011
Thank you. But how can I rotate an image by SOME angle. I don't want to rotate it upside down, but by X angle (e.g. 13)?
David Young
David Young el 27 de Nov. de 2011
You'd use imrotate in the frequency domain. Getting the origin right and maintaining the symmetries might be fiddly and I'd have to give that some thought. But is it really necessary? Why not do the rotation in the space domain (using imrotate)?

Iniciar sesión para comentar.

Etiquetas

Preguntada:

el 18 de Nov. de 2011

Community Treasure Hunt

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

Start Hunting!

Translated by