the fourier transform ii image analysis
play

The Fourier Transform II Image Analysis Filtering in the frequency - PowerPoint PPT Presentation

The Fourier Transform II Image Analysis Filtering in the frequency domain The Fourier transform and its inverse allows us to jump back and forth between the spatial and frequency domains. Niclas Brlin niclas.borlin@cs.umu.se By manipulating


  1. The Fourier Transform II Image Analysis Filtering in the frequency domain The Fourier transform and its inverse allows us to jump back and forth between the spatial and frequency domains. Niclas Börlin niclas.borlin@cs.umu.se By manipulating the spectra in the frequency domain we can construct the filters we want more intuitively than if we were to Department of Computing Science construct the filter in the spatial domain. Umeå University February 3, 2009 Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 1 / 24 Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 2 / 24 Filtering in the frequency domain Filter types The basic filtering equation is A filter that attenuates high frequencies while passing low frequencies is called a lowpass filter . g ( x , y ) = F − 1 { H ( u , v ) F ( u , v ) } . Lowpass filters are usually used for smoothing . where F ( u , v ) is the DFT of the input image f ( x , y ) , H ( u , v ) is a A filter that does not effect high frequencies is called a highpass filter function or simply filter and g ( x , y ) is the filtered output filter . image. Highpass filters are usually used for sharpening . The array H ( u , v ) contains the filter coefficient and must be of Furthermore, bandpass (bandreject) filters work on specific the same size as F ( u , v ) . frequency bands. We assume the spectra is shifted such that the zero frequency is Finally, notch filters work on specific frequencies. located at F ( M / 2 , N / 2 ) . Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 3 / 24 Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 4 / 24

  2. Lowpass vs. highpass filters Ideal filters An ideal filter has the property that all frequencies above (or below) a cut off frequency D 0 are set to zero � 1 if D ( u , v ) ≤ D 0 H ( u , v ) = , With suitable scaling the low pass filter has the property that 0 otherwise H ( 0 , 0 ) = 1, i.e. the DC component is not changed. where A high pass filter H hp can then obtained from ( u / P − 1 / 2 ) 2 + ( v / Q − 1 / 2 ) 2 � 1 / 2 � D ( u , v ) = . H hp ( u , v ) = 1 − H lp ( u , v ) . [Q,P]=size(I); u=(0:P-1)/P-1/2; v=(0:Q-1)/Q-1/2; [uu,vv]=meshgrid(u,v); ˆ ˆ H=sqrt(uu. 2+vv. 2)<=D0; Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 5 / 24 Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 6 / 24 Ideal lowpass filtering Ideal highpass filtering f ( x , y ) g ( x , y ) f ( x , y ) g ( x , y ) H ( u , v ) h ( x , y ) H ( u , v ) h ( x , y ) Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 7 / 24 Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 8 / 24

  3. Ideal filters and “ringing” Gaussian filters To avoid ringing we could use smooth filters. The spatial version h ( x , y ) of an ideal filter has severe "ringing". We know that a Gaussian function is smooth in both domains. By the convolution theorem we know that the multiplication The filter H ( u , v ) = e − D 2 ( u , v ) / 2 D 2 F ( u , v ) H ( u , v ) in the frequency domain corresponds to 0 convolution f ( x , y ) ∗ h ( x , y ) in the spatial domain. where D ( u , v ) is the distance from the ( 0 , 0 ) frequency, would be This explain the observed ringing in the filtered image. expected to yield smooth response. Due to the ringing problem, ideal filters are rarely used. At distance D 0 from the zero frequency the response of the filter is about 60% of the value at ( 0 , 0 ) . Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 9 / 24 Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 10 / 24 Gaussian lowpass filtering Gaussian highpass filtering f ( x , y ) g ( x , y ) f ( x , y ) g ( x , y ) H ( u , v ) h ( x , y ) H ( u , v ) h ( x , y ) Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 11 / 24 Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 12 / 24

  4. Butterworth filter The Laplacian in the frequency domain It can be shown that the Laplacian can be implemented in the frequency domain using the filter Another version of smoothing/sharpening filters are the H ( u , v ) = − 4 π 2 ( u 2 + v 2 ) , Butterworth filter . A Butterworth filter of order n and cutoff frequency D 0 is defined or, with respect to the center of the frequency rectangle, using as the filter 1 H ( u , v ) = 1 + [ D ( u , v ) / D 0 ] 2 n . = − 4 π 2 [( u − P / 2 ) 2 + ( v − Q / 2 ) 2 ] H ( u , v ) . = − 4 π 2 D 2 ( u , v ) An advantage with the Butterworth filter is that we can control the sharpness of the filter with the order. The Laplacian image is obtain as ∇ 2 f ( x , y ) = F − 1 { H ( u , v ) F ( u , v ) } Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 13 / 24 Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 14 / 24 The Laplacian in the frequency domain Gaussian bandpass filtering As we have seen enhancement is achieved using equation g ( x , y ) = f ( x , y ) + c ∇ 2 f ( x , y ) The filter H ( u , v ) = e − D 2 ( u , v ) / 2 D 2 1 − e − D 2 ( u , v ) / 2 D 2 2 here c = − 1 because H ( u , v ) is negative. is called a Gaussian bandpass filter . In the frequency domain this is written It is the difference between two Gaussian filters. = F − 1 { F ( u , v ) − H ( u , v ) F ( u , v ) } g ( x , y ) = F − 1 { [ 1 − H ( u , v )] F ( u , v ) } = F − 1 { [ 1 + 4 π 2 D 2 ( u , v )] F ( u , v ) } Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 15 / 24 Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 16 / 24

  5. Gaussian bandpass filtering, D 1 = 0 . 2, D 2 = 0 . 1 Homomorphic Filtering Recall that an image can be expressed as a product of illumination and reflectance components f ( x , y ) = i ( r , x ) r ( x , y ) By using the logarithm z ( x , y ) = ln f ( x , y ) the multiplicative relationship will become additative z ( x , y ) = ln f ( x , y ) = ln i ( x , y ) + ln r ( x , y ) f ( x , y ) g ( x , y ) Then we can calculate the Fourier transform of z ( x , y ) as Z ( u , v ) = F i ( u , v ) + F r ( u , v ) Z ( u , v ) is then filtered with H ( u , v ) forming S ( u , v ) that is re-transformed to the spatial domain as s ( x , y ) To reverse the logarithm the following is used g ( x , y ) = e s ( x , y ) H ( u , v ) h ( x , y ) Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 17 / 24 Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 18 / 24 Homomorphic Filtering Homomorphic filtering It is often assumed that the illumination component is characterized by slower intensity changes than the reflectance component. Thus a filter H ( u , v ) that allows us to adjust the low and high frequencies separately is often used when doing homomorphic filtering One such example is a slightly modified Gaussian high pass filter H ( u , v ) = ( γ H − γ L )[ 1 − e − cD 2 ( u , v ) / D 2 0 ] + γ L The parameter γ L allows us to adjust how much of the low frequencies to keep while γ H gives us control over the high c = 1 , D 0 = 0 . 1 , γ L = 0 . 5 , γ H = 1 . 5 frequencies Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 19 / 24 Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 20 / 24

  6. Padding Padding When filtering in the frequency domain and transforming the filtered image back to the spatial domain there sometimes appear artifacts along the edge of the image This is due to the periodic nature of the discrete Fourier transform Suppose f ( x ) has spectra F ( s ) Sampling f ( x ) with ∆ x indicates that F ( s ) is copied with period 1 ∆ x In the same way: The discrete version of the spectra F ( s ) with 1 resolution ∆ s copies f ( x ) with a period of ∆ s A filtering by multiplying with H ( s ) will produce a convolution with h ( x ) in the spatial domain At the edges of f ( x ) parts of the adjacent instances of f ( x ) will be convolved into the image, since h ( x ) has an extension in the spatial domain Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 21 / 24 Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 22 / 24 Padding Padded filtering The problems of border effects when doing filtering in the frequency domain is avoided by padding the image prior to transforming it to the frequency domain An image of size A × B must be padded to size P = 2 A + 1 and Q = 2 B + 1 prior to filtering H ( u , v ) must be transformed to the spatial domain, padded to size P × Q and re-transformed to the frequency domain After filtering an re-transformation to the spatial domain only a the part that corresponds to the original A × B is kept Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 23 / 24 Niclas Börlin (CS, UmU) Filtering in the frequency domain February 3, 2009 24 / 24

Recommend


More recommend