Previous Getting Started with IDL: Signal Processing with IDL Next

Frequency Domain Filtering

Perhaps a better way to eliminate noise in the NOISY dataset is to use Fourier transform filtering techniques. Noise is basically unwanted high-frequency content in sampled data. Applying a lowpass filter to the noisy data allows low-frequency components to remain unchanged while high-frequencies are smoothed or attenuated. Construct a filter function by entering the following step-by-step commands:

  1. Create a floating point array using FINDGEN which sets each element to the value of its subscript and stores it in the variable Y by entering:
  2. Y=[FINDGEN(100),FINDGEN(100)-100]  
    

     

  3. Next, make the last 99 elements of Y a mirror image of the first 99 elements:
  4. Y[101:199]=REVERSE(Y[0:98])  
    

     

  5. Now, create a variable filter to hold the filter function based on Y:
  6. filter=1.0/(1+(Y/40)^10)  
    

     

  7. Finally, plot:
  8. IPLOT,FILTER  
    

     

    Figure 5-5: Constructing a Filter Function

    Figure 5-5: Constructing a Filter Function

     

    To filter data in the frequency domain, we multiply the Fourier transform of the data by the frequency response of a filter and then apply an inverse Fourier transform to return the data to the spatial domain.

     

  9. Now we can use a lowpass filter on the NOISY dataset and store the filtered data in the variable lowpass by entering:
  10. LOWPASS=FFT(FFT(NOISY,1)*filter,-1)  
    

     

  11. Then plot:
  12. IPLOT, LOWPASS  
    

     

    Figure 5-6: Using a LOWPASS Filter

    Figure 5-6: Using a LOWPASS Filter


Note
Your plots may look slightly different due to the random number generator.

  1. The same filter function can be used as a high-pass filter (allowing only the high frequency or noise components through) by entering:
  2. NOISY=ORIGINAL+((RANDOMU(SEED,200)-.5)/ 2)  
    HIGHPASS=FFT(FFT(NOISY,1)*(1.0-filter),-1)  
    

     

  3. Then plot:
  4. IPLOT, HIGHPASS  
    

     

    Figure 5-7: Using a Highpass Filter

    Figure 5-7: Using a Highpass Filter

  IDL Online Help (March 06, 2007)