Re: 2dFFT & image processing
- To: mathgroup at smc.vnet.net
- Subject: [mg101555] Re: [mg101500] 2dFFT & image processing
- From: Matthias Odisio <matthias at wolfram.com>
- Date: Fri, 10 Jul 2009 06:43:29 -0400 (EDT)
- References: <200907090553.BAA16870@smc.vnet.net>
Alessandro, alexxx.magni at gmail.com wrote, On 7/9/09 12:53 AM: > 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 > You got the idea right, except in 3) you want the inverse fft Moreover: > 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; > Dimensions[f] > {500,500} > > and I can check the fft with Graphics[Raster[255*af/Max[af]]] > and now you see that Fourier does not put the low frequencies at the center as you expected, but at the four corners. > 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; > fholed = Abs[Fourier[holed]]; > There's a couple of problems here: 1. Your mask is centered, hence won't match the corners 2. Don't throw away the phase (argument) of the FFT or you won't be able to reconstruct the image 3. You should use InverseFourier to perform the inverse FFT. If you forgive my obfuscated cornering, this works as expected: k2 = ArrayFlatten[Reverse /@ Reverse[Partition[k, {250, 250}]]]; holed = f*k2; fholed = Abs[InverseFourier[holed]]; Compare Image[fholed, "Byte"] with ImageConvolve[a, CrossMatrix[0, 21] - GaussianMatrix[10]] Matthias Odisio Wolfram Research > since the reconstructed image Graphics[Raster[255*fholed/Max[fholed]]] > is strongly fuzzed, whichever value I choose for the parameter s > above, I wanted to ask you if I completely misunderstood the process! > > thank you, > > > alessandro
- References:
- 2dFFT & image processing
- From: "alexxx.magni@gmail.com" <alexxx.magni@gmail.com>
- 2dFFT & image processing