ECEN 447 Digital Image Processing Lecture 5: Enhancement in Frequency Domain Ulisses Braga-Neto ECE Department Texas A&M University
2-D Fourier Transform The Fourier Transform, both continuous and discrete, can be directly extended to the 2-D case. The 2-D Fourier Transform of image f(x,y) is given by: with inverse 2-D Fourier transform given by As before, these define a Fourier pair
2-D Fourier Transform Example Two-Dimensional Box and Sinc Functions Similarly as in the 1-D case, we have: and
2-D Discrete Fourier Transform Given a digital image we can extend it periodically into an image, such that The 2-D Discrete Fourier Transform (DFT) is given by: The DFT is defined for all integers u,v, and is periodic of period M,N: Note that we use the same variable names u and v as before, with the understanding that these are discrete variables here.
2-D Discrete Fourier Transform - II The 2-D lnverse Discrete Fourier Transform is given by: By duality, the IDFT is defined for all integers x,y, and is periodic of periods M,N: and the original image is recovered by taking one period off this. As before, the tildes remind us that both the DFT and the extended version of the original image (IDFT) are periodic of periods M,N. As before, we can do away with the tildes provided we remember about this periodicity, and write:
Properties of the DFT The DFT is a discrete version of the Fourier Transform. They are very similar to each other, but they are not quite identical. Many of the properties of the DFT and FT look identical: Fourier spectrum and phase Uniqueness of Fourier pairs Linearity Conjugate symmetry Time-reversal Some of the properties of the FT and DFT and specific Fourier pairs are identical up to the complex exponential coefficient or a multiplying factor (typically MN or 1/MN) somewhere in the equations. Also, the DFT and its inverse are always periodic signals. Therefore, negative signs have a special meaning:
Properties of the DFT - II DC Component: where is the average value of the image. A consequence of this property is that if the image is real, then F(0,0) must be real no matter what (even though F(u,v) may be complex away from the origin).
Properties of the DFT - III Given we have: Duality Property: Translation Property: and Rotation Property: Rotating the spatial plane XY by an angle θ produces a rotation in the frequency plane UV by the same angle θ
Properties of the DFT - IV Centering Property: Note that By the translation property, it follows that Therefore, multiplication of the image by "centered" DFT. produces a In practice, this is accomplished by directly shifting the DFT (care must be taken to shift the DFT back before computing the IDFT).
Discrete Linear Convolution Given two discrete (not necessarily periodic) images f and h, the discrete linear convolution between them is given by If f(x,y) is zero outside the interval [0,A-1] x [0,B-1] and g(x,y) is zero outside the interval [0,C-1] x [0,D-1], then the linear convolution is guaranteed to be zero outside the interval [0,A+C-1] x [0,B+D-1].
Discrete Periodic Convolution Given two discrete periodic images f and h, both of period M,N, the discrete periodic convolution between them is given by The tildes are included to remind us that the functions are periodic. The periodic convolution is (you guessed it) periodic, with period M,N. The result of periodic convolution over one period [0,M-1] x [0,N-1] is called the circular convolution of f and h.
Linear x Periodic Convolution linear convolution periodic convolution circular convolution
Discrete Convolution Theorem Theorem: The product of DFTs in the frequency domain is equivalent to periodic convolution of the images in the spatial domain: this is the basis of linear filtering. However, the convolution is periodic, not linear! There is no DFT theorem for linear convolutions. This in general introduces "wrap-around" error with respect to the linear convolution (see previous slide). The wrap-around error can be avoided by means of zero-padding the original images. Conversely, the product of images in the spatial domain is equivalent to scaled periodic convolution of the DFTs in the frequency domain:
Basics of Frequency-Domain Filtering Image filtering in the frequency domain requires the following steps: The original image should be zero-padded to twice its size to avoid wrap-around error (sometimes, this step may be ignored). The image DFT should be computed and centered. A centered filter frequency response should be specified (this is an image of the same size as the image DFT). The image DFT is multiplied elementwise to the filter response. The result is uncentered and the IFDT is computed. The output image is cropped from the previous result. By the convolution theorem, the above is equivalent to applying a spatial filter by convolution with the IDFT of the frequency response. Frequency responses should be real and symmetric around the origin to avoid altering the phase and also to produce real spatial masks. A small value in the frequency response suppresses the corresponding frequency in the original image.
Mechanics of Frequency-Domain Filtering original image zero-padded Centered (here, Gaussian) filter frequency response Fourier spectrum of padded image Spectrum of the product of DFTs Inverse DFT cropped result
Frequency-Domain Image Smoothing As mentioned previously in connection with spatial filters, image smoothing aims at removing or attenuating sharp transitions, which may be associated with noise, artifacts, and small irrelevant features. It turns out that sharp transitions are associated with high frequency content, and frequency-domain image smoothing is performed by attenuating these high-frequency components. This is accomplished by using a filter that has Smaller high frequency response (values away from the origin) Larger low frequency response (values near the origin) Such filters are called lowpass filters. All linear shift-invariant spatial filters discussed previously have a frequency-domain representation. For example, simple averaging filters are box spatial filters, which have sinc frequency responses (which are clearly lowpass filters).
Ideal Lowpass Filter The simplest form of frequency-domain filter is the one that suppresses (zeroes) all "unwanted" frequency components, and pass (do not change) the "desirable" frequency components. Such filters contain instantaneous transitions in their frequency responses, and therefore are not physically realizable in analog circuits (hence the name "ideal filter"). The frequency response of an ideal lowpass filter is given by where D 0 is the "cutoff frequency," and is the distance of point (u,v) to the origin.
Ideal Lowpass Filter Response Frequency Response of ILPF Spatial Response of ILPF
Ideal Lowpass Filter - Power The cutoff frequency is a free parameter in principle. One way to set it automatically is to specify a certain percentage of power that should be allowed to pass by the filter. In formal terms, the percentage of power for an ideal lowpass filter is where is the power spectral density of the original image. original image spectrum + cutoff raddi for 87%, 93.1%, 95.7%, and 97.8% power
Ideal Lowpass Filter - Example original image 87% power 93.1% power 95.7% power 97.8% power 99.2% power
Butterworth Lowpass Filter The ringing problem of ideal filters can be avoided by having a smoother transition around the cutoff frequency. This is the idea behind the Butterworth filter. Its frequency response is given by where n is a free parameter, called the order of the filter. The larger the order is, the sharper the transition around D 0, and the more the Butterworth filter resembles the ideal filter. At the cutoff frequency, D(u,v) = D 0, the response is exactly half of its maximal value.
Butterworth Lowpass Filter Response Frequency Response of BLPF Spatial Response of BLPF n =1 n =2 n =5 n =20
Butterworth Lowpass Filter - Order-2 Example original image 87% power 93.1% power 95.7% power 97.8% power 99.2% power
Gaussian Lowpass Filter The Gaussian filter is smoother still than the Butterworth filter. Its response is given by a spherical bivariate Gaussian density where D 0 plays the role of the standard deviation of the distribution. At the cutoff frequency, D(u,v) = D 0, the response is down to 0.607 of its maximal value.
Gaussian Lowpass Filter Response Frequency Response of GLPF The Spatial response of the GLPF is also Gaussian
Gaussian Lowpass Filter - Example original image 87% power 93.1% power 95.7% power 97.8% power 99.2% power
Frequency-Domain Image Sharpening Image sharpening corresponds to the opposite of image smooting; here, sharp transitions, which often correspond to edge information, should be enhanced instead of removed. This is accomplished by using a filter that has Larger high frequency response (values away from the origin) Smaller low frequency response (values near the origin) Such filters are called highpass filters. Clearly, this is obtained if the frequency reponse H HP (u,v) and spatial response h HP (x,y) satisfy where H LP (u,v) and h LP (x,y) are respectively the frequency and spatial responses of a lowpass filter. This is the approach that is used to obtain ideal, Butterworth, and Gaussian highpass filters.
Highpass Filter Frequency Response The cutoff frequency D 0 as before specifies the threshold between the pass and reject regions, only now in the opposite direction. Ideal highpass filter: Butterworth highpass filter: Gaussian highpass filter:
Ideal Highpass Filter Response Frequency Response of IHPF Spatial Response of IHPF
Butterworth Highpass Filter Response Frequency Response of IHPF Spatial Response of IHPF
Gaussian Highpass Filter Response Frequency Response of IHPF Spatial Response of IHPF
Bandreject and Bandpass Filters Bandreject filters attenuate a specific band of frequencies. Bandpass filters attenuate all other frequencies save the given band. Bandreject and bandpass filters are isotropic: they reject/pass frequency components in the band in all directions uniformly. The transition between pass and reject regions can once again be implemented as ideal, Butterworth, or Gaussian.
Bandreject and Bandpass Frequency Response The cutoff frequency D 0 specifies the center of the rejection band, and an extra parameter W specifies its width. Ideal bandreject filter: Butterworth bandreject filter: Gaussian bandreject filter: The frequency response of corresponding bandpass filters is given by
Bandreject and Bandpass Filter Response Ideal bandreject Butterworth bandreject Gaussian bandreject Gaussian bandreject Gaussian bandpass
Bandreject Filter Example Original image corrupted by periodic noise Fourier spectrum Bandreject filter frequency response Filtered image
Notch Filters Notch filters pass or reject specific regions of the frequency domain. Notch filters are anisotropic: they reject/pass frequency components in specific directions. The transition between pass and reject regions can once again be implemented as ideal, Butterworth, or Gaussian. Care must be taken that the frequency responses be even (so that the corresponding spatial filters are real). The frequency response of a notch reject filter with Q notch pairs located at and, for k=1,...,q, is given in terms of Q pairs of shifted high-pass responses
Notch Filters - II For example, suppose the Q highpass responses correspond to Butterworth filters of cutoff frequencies, for k=1,...q. Then the response of a Butterworth notch reject filter with Q=3 notch pairs is where is the distance from point (u,v) to the center of the notch. The frequency response of corresponding noth pass filters is given by
Notch Filter Frequency Reposnse ideal notch reject Butterworth notch reject (n=2) Gaussian notch reject
Notch Filter Example Original image corrupted by periodic noise Fourier spectrum Fourier spectrum after application of notch reject filter Filtered image
Notch Filter Example - II Original image corrupted by periodic noise Fourier spectrum Notch reject filter frequency response Filtered image Notch pass filter frequency response Filtered noise