Re: FFT with NANs in an array [message #49435 is a reply to message #49342] |
Thu, 20 July 2006 19:48   |
Kenneth P. Bowman
Messages: 585 Registered: May 2000
|
Senior Member |
|
|
In article <1153439903.349812.299130@75g2000cwc.googlegroups.com>,
adisn123@yahoo.com wrote:
> My purpose here is to get rid of low frequency by applyting high pass
> filter into my image.
> My image is quite huge (about 10,000 x 10,000 pixel size).
>
> Then, if my image has NANs, what is the reaction of FFT into that?
> What does FFT consider those NANs as?
>
> When I do FFT, it certainly doesn't give me any errors, then does it
> mean
> FFT reads NANs as some sort of data values?
>
> Thanks.
The FFT is a clever algorithm for performing a discrete Fourier
transform. At bottom it amounts to a lot of dot products (additions and
multiplications).
The example below demonstrates the effects of having NaNs in the input
data. (The IDL FFT function must turn off floating-point error
notification, which is an odd thing to do.)
Since your interest is high-pass filtering, you could use a
curve-fitting routine to fit a smooth function to the data and then
subtract it from the original data. There are least-squares methods and
nonlinear approaches, such as Craig Markwardt's MPFIT
(http://cow.physics.wisc.edu/~craigm/idl/).
Interpolating the gaps will introduce high-frequency components and
should probably be avoided.
Ken Bowman
n = 8
x = RANDOMN(seed, n)
xt = FFT(x)
xx = FFT(xt, /INVERSE)
PRINT, 'No NaNs'
PRINT, 'x = ', x
PRINT, 'xt = ', xt
PRINT, 'xx = ', FLOAT(xx)
x[5] = !VALUES.F_NAN
xt = FFT(x)
xx = FFT(xt, /INVERSE)
PRINT
PRINT, 'One NaN'
PRINT, 'x = ', x
PRINT, 'xt = ', xt
PRINT, 'xx = ', FLOAT(xx)
No NaNs
x = -0.303949 1.09403 0.627827 1.23538 -1.09260
-0.563133 0.00560129
1.14969
xt = ( 0.269105, 0.00000)( 0.237482, -0.231826)(
-0.253748, 0.231771)
( -0.0403187, -0.0762694)( -0.459886, -0.00000)(
-0.0403187, 0.0762694)
( -0.253748, -0.231771)( 0.237482, 0.231826)
xx = -0.303949 1.09403 0.627827 1.23538 -1.09260
-0.563133 0.00560129
1.14969
One NaN
x = -0.303949 1.09403 0.627827 1.23538 -1.09260
NaN 0.00560129
1.14969
xt = ( NaN, NaN)( NaN, NaN)(
NaN, NaN)
( NaN, NaN)( NaN, NaN)(
NaN, -NaN)
( NaN, -NaN)( NaN, -NaN)
xx = NaN NaN NaN NaN NaN
NaN NaN
NaN
|
|
|