2011-10-14 16 views
8

Así que tengo esta imagen 'I'. Tomo F = fft2 (I) para obtener la transformada de Fourier 2D. Para reconstruirlo, podría ir a ifft2 (F).FFT inversa de Matlab de fase/magnitud solamente

El problema es que necesito reconstruir esta imagen solo a) magnitud, yb) componentes de fase de F. ¿Cómo puedo separar estos dos componentes de la transformada de Fourier y luego reconstruir la imagen de cada uno?

Probé las funciones abs() y ángulo() para obtener magnitud y fase, pero la fase uno no se reconstruirá correctamente.

¿Ayuda?

Respuesta

10

Necesita una matriz con la misma magnitud que F y 0 fase, y otra con la misma fase que F y magnitud uniforme. Como señaló abs le da la magnitud. Para obtener la misma matriz uniforme de fase, necesita usar angle para obtener la fase, y luego separar la fase en partes reales e imaginarias.

> F_Mag = abs(F); %# has same magnitude as F, 0 phase 
> F_Phase = cos(angle(F)) + j*(sin(angle(F)); %# has magnitude 1, same phase as F 
> I_Mag = ifft2(F_Mag); 
> I_Phase = ifft2(F_Phase); 
+0

Pongo No veo esta función ffti() a la que se refiere, ¿quiere decir ifft2() tal vez? Si no, ¿tiene un enlace a la documentación para ello? Además, no veo esta función arg(). – Jordan

+0

Disculpa, estaba usando la sintaxis de Octave para 'arg' (equivalente al' ángulo 'de Matlab) y la sintaxis inventada para' ifft2'. – mtrw

+4

+1, 'F_Phase = exp (j * ángulo (F));' también! –

0

de que sea demasiado tarde para poner otra respuesta a este mensaje, pero ... de todos modos

@ zhilevan, puede utilizar los códigos que he escrito usando la respuesta de MTRW:

image = rgb2gray(imread('pillsetc.png')); 
subplot(131),imshow(image),title('original image'); 
set(gcf, 'Position', get(0, 'ScreenSize')); % maximize the figure window 
%::::::::::::::::::::: 
F = fft2(double(image)); 
F_Mag = abs(F); % has the same magnitude as image, 0 phase 
F_Phase = exp(1i*angle(F)); % has magnitude 1, same phase as image 
% OR: F_Phase = cos(angle(F)) + 1i*(sin(angle(F))); 
%::::::::::::::::::::: 
% reconstruction 
I_Mag = log(abs(ifft2(F_Mag*exp(i*0)))+1); 
I_Phase = ifft2(F_Phase); 
%::::::::::::::::::::: 
% Calculate limits for plotting 
% To display the images properly using imshow, the color range 
% of the plot must the minimum and maximum values in the data. 
I_Mag_min = min(min(abs(I_Mag))); 
I_Mag_max = max(max(abs(I_Mag))); 

I_Phase_min = min(min(abs(I_Phase))); 
I_Phase_max = max(max(abs(I_Phase))); 
%::::::::::::::::::::: 
% Display reconstructed images 
% because the magnitude and phase were switched, the image will be complex. 
% This means that the magnitude of the image must be taken in order to 
% produce a viewable 2-D image. 
subplot(132),imshow(abs(I_Mag),[I_Mag_min I_Mag_max]), colormap gray 
title('reconstructed image only by Magnitude'); 
subplot(133),imshow(abs(I_Phase),[I_Phase_min I_Phase_max]), colormap gray 
title('reconstructed image only by Phase');