Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #10359 > unrolled thread

FFT of a noisy image with weak periodic information

Started byDave Martin <miltydcm@gmail.com>
First post2012-06-06 08:48 +0000
Last post2012-06-08 07:41 +0000
Articles 3 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  FFT of a noisy image with weak periodic information Dave Martin <miltydcm@gmail.com> - 2012-06-06 08:48 +0000
    Re: FFT of a noisy image with weak periodic information "Kevin J. McCann" <kjm@KevinMcCann.com> - 2012-06-07 09:17 +0000
    Re: FFT of a noisy image with weak periodic information Dave Martin <miltydcm@gmail.com> - 2012-06-08 07:41 +0000

#10359 — FFT of a noisy image with weak periodic information

FromDave Martin <miltydcm@gmail.com>
Date2012-06-06 08:48 +0000
SubjectFFT of a noisy image with weak periodic information
Message-ID<jqn5gv$hd3$1@smc.vnet.net>
I'm trying to accomplish what should be a relatively simple frequency
domain filtering of a noisy input image with with some weak, periodic
signals (a low dose transmission electron microscope image of some
organic crystals).   Using the commands below, I've been able to input
the image (x), convert it to data (xi), and calculate the FFT (fx).
Now what I want to do is to set the FFT to zero for all values below
some threshold, and then inverse transform back to a filtered image.
My stumbling block is a simple means to set the values of the array fx
to zero below some threshold, before I perform InverseFourier.

x=Import["data.tif"]   (*import the file as an image*)
xi=ImageData[x];   (*convert image to array data*)
x1=xi[[All,All,1]];    (*extract one of the three color channels from
the RGB image*)
fx=Fourier[x1];       (*calculate the FFT of x1*)

Some other commands I've found useful...

pfx=fx*Conjugate[fx];  (*calculate power spectrum = fx^2*)
n=Length[pfx]             (*determine size of arrays*)
pxr=RotateRight[pfx, {n/2,n/2}];   (*put origin in center of PS
image*)
pi = Image[pxr]           (*convert PS to image for display*)

Inverse transforming...

rx=Chop[InverseFourier[fx]];  (*convert fx back to a real space data
set rx*)
ri=Image[rx]                         (*convert rx to an image ri for
display*)

[toc] | [next] | [standalone]


#10366

From"Kevin J. McCann" <kjm@KevinMcCann.com>
Date2012-06-07 09:17 +0000
Message-ID<jqprim$2at$1@smc.vnet.net>
In reply to#10359
I would suggest that you might wish to use a low pass filter that is a 
little "softer" so that you avoid any ringing. In any event, here is a 
simple way to threshold as you describe:

data = Table[i j, {i, -5, 5}, {j, -5, 5}];
data // MatrixForm

thresh=0;
dataThresh = Map[(If[(# < thresh), thresh, #] &), data, {2}];
dataThresh // MatrixForm


Kevin

On 6/6/2012 4:48 AM, Dave Martin wrote:
> I'm trying to accomplish what should be a relatively simple frequency
> domain filtering of a noisy input image with with some weak, periodic
> signals (a low dose transmission electron microscope image of some
> organic crystals).   Using the commands below, I've been able to input
> the image (x), convert it to data (xi), and calculate the FFT (fx).
> Now what I want to do is to set the FFT to zero for all values below
> some threshold, and then inverse transform back to a filtered image.
> My stumbling block is a simple means to set the values of the array fx
> to zero below some threshold, before I perform InverseFourier.
>
> x=Import["data.tif"]   (*import the file as an image*)
> xi=ImageData[x];   (*convert image to array data*)
> x1=xi[[All,All,1]];    (*extract one of the three color channels from
> the RGB image*)
> fx=Fourier[x1];       (*calculate the FFT of x1*)
>
> Some other commands I've found useful...
>
> pfx=fx*Conjugate[fx];  (*calculate power spectrum = fx^2*)
> n=Length[pfx]             (*determine size of arrays*)
> pxr=RotateRight[pfx, {n/2,n/2}];   (*put origin in center of PS
> image*)
> pi = Image[pxr]           (*convert PS to image for display*)
>
> Inverse transforming...
>
> rx=Chop[InverseFourier[fx]];  (*convert fx back to a real space data
> set rx*)
> ri=Image[rx]                         (*convert rx to an image ri for
> display*)
>
>

[toc] | [prev] | [next] | [standalone]


#10402

FromDave Martin <miltydcm@gmail.com>
Date2012-06-08 07:41 +0000
Message-ID<jqsab7$dhb$1@smc.vnet.net>
In reply to#10359
On Wednesday, June 6, 2012 4:48:31 AM UTC-4, Dave Martin wrote:
> I'm trying to accomplish what should be a relatively simple frequency
> domain filtering of a noisy input image with with some weak, periodic
> signals (a low dose transmission electron microscope image of some
> organic crystals).   Using the commands below, I've been able to input
> the image (x), convert it to data (xi), and calculate the FFT (fx).
> Now what I want to do is to set the FFT to zero for all values below
> some threshold, and then inverse transform back to a filtered image.
> My stumbling block is a simple means to set the values of the array fx
> to zero below some threshold, before I perform InverseFourier.
>
> x=Import["data.tif"]   (*import the file as an image*)
> xi=ImageData[x];   (*convert image to array data*)
> x1=xi[[All,All,1]];    (*extract one of the three color channels from
> the RGB image*)
> fx=Fourier[x1];       (*calculate the FFT of x1*)
>
> Some other commands I've found useful...
>
> pfx=fx*Conjugate[fx];  (*calculate power spectrum = fx^2*)
> n=Length[pfx]             (*determine size of arrays*)
> pxr=RotateRight[pfx, {n/2,n/2}];   (*put origin in center of PS
> image*)
> pi = Image[pxr]           (*convert PS to image for display*)
>
> Inverse transforming...
>
> rx=Chop[InverseFourier[fx]];  (*convert fx back to a real space data
> set rx*)
> ri=Image[rx]                         (*convert rx to an image ri for
> display*)

Thanks to all of you for these different suggestions.  I actually figured out a reasonable solution on my own soon after posting my initial question, but have learned some useful things from these different alternatives, and so I appreciate the comments.  Here is my solution...

thresh = 1;
Do[If
   [Abs[xf[[x1, y1]]] < thresh, xf[[x1, y1]] = 0,
   xf[[x1, y1]] = xf[[x1, y1]]], {x1, 1, n}, {y1, 1, n}];

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web