From: PRITAM on
Hi,
Im having extreme difficulty in getting my image back from frequency domain to spatial domain after the image is being modified in the frequency domain.I'm executing the following steps in the matlab command window with an image "Cropped_Labyrinth.pgm" (image name given for letting you know the file format).

>> I = imread('Cropped_Labyrinth.pgm');
>> imshow(I)
>> F=fft2(I);
>> S=abs(F);
>>Fc=fftshift(F);
>>imshow(abs(Fc),[])
>>S2=log(1+abs(Fc));
>>imshow(S2,[])

then I'm creating a mask
>>S2(100:110,30:40)=6;

and then I want to get back to the spatial domain
but I dont know why I'm not getting back the image.In stead I'm getting actually a balack background and nothing else!!!...Is it due to the log transformation? Can anyone please help me here ?Can you please tell what's the problemhere or what I need to do to get back the spatal-domain image from frequency domain-image ?

Thanks in advance.


Pritam
From: Ashish Uthama on
On Wed, 21 Apr 2010 17:31:07 -0300, PRITAM <ajpritam(a)gmail.com> wrote:

> Hi,
> Im having extreme difficulty in getting my image back from
> frequency domain to spatial domain after the image is being modified in
> the frequency domain.I'm executing the following steps in the matlab
> command window with an image "Cropped_Labyrinth.pgm" (image name given
> for letting you know the file format).
>
>>> I = imread('Cropped_Labyrinth.pgm');
>>> imshow(I)
>>> F=fft2(I);
>>> S=abs(F);
>>> Fc=fftshift(F);
>>> imshow(abs(Fc),[])
>>> S2=log(1+abs(Fc));
>>> imshow(S2,[])
>
> then I'm creating a mask
>>> S2(100:110,30:40)=6;
>
> and then I want to get back to the spatial domain
> but I dont know why I'm not getting back the image.In stead I'm getting
> actually a balack background and nothing else!!!...Is it due to the log
> transformation? Can anyone please help me here ?Can you please tell
> what's the problemhere or what I need to do to get back the
> spatal-domain image from frequency domain-image ?
>
> Thanks in advance.
>
>
> Pritam

Have you used ifftshift on your way back?
From: PRITAM on
After I made changes to the image "S2",I executed the following commands:


>> K=real(ifft2(S2));
>> imshow(K,[])
From: David Young on
You should indeed be including ifftshift before ifft, but in fact this doesn't solve your problem: even with this step, you won't see a display resembling the original image.

In fact, the display you get isn't all black. The top left pixel is white. If you take the log of K before displaying it, you'll see the rest of its structure. It's probably not what you want, but it isn't clear what you do want.

So the question is: what is the motivation for the operation S2=log(1+abs(Fc))? This is the core operation in the frequency domain, but it doesn't make sense to me and without knowing what the aim is, it's not possible to suggest what might work.

One way forward for you might be simply to start by setting S2 = Fc instead of doing the abs and log operation. Then you can at least assess and understand the effects of setting a region of S2 to the constant 6. But maybe that misses the point.
From: PRITAM on
Thank U David for replying elaborately....actually without doing the log transformation,I was not able to see the full feature of the FFTed image.To visualise the power spectrum clearly I executedthe step:

>> S2=log(1+abs(Fc));,

Then only I could see that there was high frequency periodic noises in the frequency-domain-image.Now I want to get back to spatial domain.

My motivation:

I have a raw gray-scale image which contains high frequency periodic noises.I want to take the image to frequency domain to remove those noises and want to get back my filtered image.So please let me know how can I do that.

Thanking you,
Regards,

Pritam