0

I took the Fourier transform of an image in Matlab and now I want to take the inverse fourier but the result is a completely black picture instead of the original image. I think there is some step that I need to do before taking the inverse. Thank you for any help. The code:

nasa=imread('nasaNoise _1_','jpg');
N_Fourier=fft2(nasa);
N_Fourier=fftshift(N_Fourier);
N_Fourier=abs(N_Fourier);
N_Fourier=log(N_Fourier+1);
N_Fourier=mat2gray(N_Fourier);

%Now doing the inverse
N_inverse=ifft2(N_Fourier);
N_inverse=abs(N_inverse);
N_inverse=uint8(N_inverse);
imshow(N_inverse);
Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
  • 5
    Well, you're applying fftshift, abs, log, and mat2gray. After that, you don't have the Fourier transform of the image anymore, so why would the inverse Fourier transform recover it? – A. Donda Nov 02 '13 at 17:31
  • 4
    You first lose it when you do `N_Fourier=abs(N_Fourier);` – chappjc Nov 02 '13 at 17:54
  • Well, i want to edit the fourier transform of the image and then go back. I was told i would need the abs, log, and mat2gray in order to get an editable picture, is this not the case? – user2948218 Nov 02 '13 at 18:06
  • 1
    The Fourier transform is in general complex-valued, so I understand the abs, and can have values orders of magnitude different, so I understand the log. But while the log is (in principle) invertible, the abs isn't, so you're never going to be able to apply the inverse transform. Are you sure you want to edit (in a bitmap graphic editor) the Fourier transform? Maybe you just want to apply a mask or something? – A. Donda Nov 02 '13 at 18:39
  • 2
    If stackoverflow was capable of using MathJax like other SE sites I would be a lot more likely to post an answer here. – nispio Nov 02 '13 at 18:59
  • 1
    @nispio: missed that very often, too. Especially since Matlab-related questions tend to have a mathematical side. – A. Donda Nov 02 '13 at 19:15
  • @nispio: consider supporting my post on meta: http://meta.stackexchange.com/questions/203977/theres-seriously-no-reason-why-latex-markup-via-mathjax-shouldnt-be-enabled-on – A. Donda Nov 02 '13 at 20:47
  • @nispio: well,that wasn't exactly successful... :( – A. Donda Nov 02 '13 at 22:25
  • 1
    @A.Donda If I had more time, I would consider proposing matlab.SE on area51, but that seems like a lot of work. If someone makes the proposal, please email me, because I would like to support it. user2948218 Sorry for hijacking the comments for a tangential discussion. :) – nispio Nov 02 '13 at 22:37
  • @A.Donda yes, i want to apply a notch filter to get rid of some noise – user2948218 Nov 03 '13 at 19:05
  • 1
    @user2948218: then you definitely don't need to do the abs, log etc. You don't even need to do the Fourier transform yourself, see `filter2`. The actual work you have to do is to come up with the FIR coefficients that define your notch filter. There are tools for filter design in the "DSP System Toolbox" and "Signal Processing Toolbox". Even if you have and use those, I'd recommend to first try and understand the principles of filter design from a textbook. – A. Donda Nov 04 '13 at 11:51

0 Answers0