MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: 2dFFT & image processing

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101565] Re: [mg101500] 2dFFT & image processing
  • From: Sseziwa Mukasa <mukasa at jeol.com>
  • Date: Fri, 10 Jul 2009 06:45:27 -0400 (EDT)
  • References: <200907090553.BAA16870@smc.vnet.net>

On Jul 9, 2009, at 1:53 AM, alexxx.magni at gmail.com wrote:

> hi everybody,
> I need to perform a high-pass filter on some images.
>
> I know I can get a high pass filter doing a convolution of the image
> with a predefined kernel, but for various reasons (and my learning
> too) I wanted to follow the sequence:
> 1) fft
> 2) cut away central region (with a smooth edge)
> 3) fft again
>
> but, due to my ignorance, I'm unable to accomplish the process:
>
> given the image in a, I put:
>
> f = Fourier[a[[1]]];
> af = Abs@f;

Why are you taking the absolute value here?  You can't recover the  
image from this data anymore.

> Dimensions[f]
>    {500,500}
>
> and I can check the fft with Graphics[Raster[255*af/Max[af]]]
>
> I then create the "hole" and apply it to the fft and invert again:
>
> k = Table[1 - Exp[-(x^2 + y^2)/s], {x, -249, 250}, {y, -249, 250}] /.
> s -> 1000.;
> holed = af*k;

The indices are incorrect, the frequency (0,0) is not in the center  
of the spectrum, it's actually the very first point in the lower left  
hand corner of the plot.  You have two options: shift the spectrum  
after Fourier, or shift the filter.  So I'd define k as:

k = Table[1 - Exp[-(If[x>249,x-500,x]^2 + If[y>249,y-500,y]^2)/s],{x, 
0,500},(y,0,500}]/.s->1000.;

> fholed = Abs[Fourier[holed]];

InverseFourier is the Inverse Fourier transform, so given the new k  
I'd use:

fholed=InverseFourier[f*k]

Best Regards,

Sseziwa Mukasa


  • Prev by Date: Re: Manipulating list
  • Next by Date: Re: about Implication
  • Previous by thread: 2dFFT & image processing
  • Next by thread: Re: 2dFFT & image processing