TDI131 Digital Image Processing Frequency Domain Filtering Lecture 6 John See Faculty of Information Technology Multimedia University Some portions of content adapted from Zhu Liu, AT&T Labs. Most figures from Gonzalez/Woods 1
Lecture Outline Image Enhancement in Frequency Domain Filtering in Frequency Domain Low-Pass Filtering High-Pass Filtering Laplacian & High-Boost Filtering Homomorphic Filtering Selective Filtering Bandpass/Bandreject, Notch Filters
Some Announcements Tutorial is OFF this week as Friday is a public holiday. There will be tutorial sessions next week pm-4pm, 3rd March (Wednesday) 10am-1pm, 5th March (Friday) usual time Assignment 1 is still due on the 5th March (Friday), 11.59PM 3
Image Enhancement in Frequency Domain Image after transformation to frequency domain can be modified with frequency filters Nature of periodicity & conjugate symmetry, spectrum components for a NxN image only increase in frequency up to the N/ term, and then decreases until N. So, origin of spectrum is always shifted for Display purpose (what we know so far) Filtering purpose (NEW!) 4
5 Image Enhancement in Frequency Domain Steps taken: 1)Shift the origin of spectrum by multiplying image f(x,y) by (-1) x+y before performing transformation to frequency domain. = = +, ), ( 1) )(, ( ), ( ) ( N v M u F v u G y x f y x g y x
Image Enhancement in Frequency Steps taken: Domain )Enhance the visual information of the transformed image G(u,v) using log transform: D ( u, v) = k log 1+ [ G(u,v) ] 6
Image Enhancement in Frequency Domain 7
Image Enhancement in Frequency Domain G(u,v), the frequency spectrum obtained after applying frequency filter H(u,v) to frequency-transform image F(u,v) by multiplication, is defined as: G( u, v) = H ( u, v) F( u, v) The filtered image, g(x,y) can then be obtained by performing the inverse transform to G(u,v): g( x, y) = G ( u, v) Any shifting to origin performed before filtering should also be reversed after filtering. 1 8
Low-Pass Filter (in Freq. Domain) Lowpass filter remove high-frequency information, or allow LOW-frequency information to PASS through Useful for removing noise in images Also have undesired effect of blurring an image 9
Ideal Low-Pass Filter (ILPF) An ideal low-pass filter contain only 1's and 0's 1 for lower frequency and 0 for high frequency -D ideal lowpass filter (ILPF) is defined as: 1 if D( u, v) D0 H ( u, v) = 0 if D( u, v) > D where D 0 is a positive constant and D(u,v) is the distance from point (u,v) to the origin (center) of the frequency rectangle. It is denoted as D( u, v) = ( u M / ) + ( v N / ) 0 10
Ideal Low-Pass Filter (ILPF) 11
Inituitively, how does it work? x =? H(u,v) F(u,v) What is the expected output if we multiply the two frequency-transformed images above? 1
Ideal Low-Pass Filter (ILPF) An ideal filter has undesired artifacts in images Presence of ripples/waves whenever there are boundaries in the image ringing effect 13
Butterworth Low-Pass Filter (BLPF) Butterworth lowpass filter Can specify order of filter, which determines steepness of slope in the transition of the filter function Higher order of filter steeper slope closer to ideal filter Transfer function of a Butterworth lowpass filter (BLPF) of order n, with cutoff frequency at a distance D 0 from origin, is defined as H ( u, v) = + 1 [ D( u, v) / D ] n o where D(u,v) is the distance from origin of spectrum 1 14
Butterworth Low-Pass Filter (BLPF) 15
Butterworth Low-Pass Filter (BLPF) Ringing properties increase if we increase the BLPF filter order, n 16
Gaussian Low-Pass Filter (GLPF) Gaussian lowpass filter in -D is defined as H ( u, v) = e D ( u, v) / σ where D(u,v) is the distance from the origin of spectrum, σ is the measure of spread of the Gaussian curve By letting σ = D 0, where D 0 is the cutoff frequency, we get H ( u, v) = e D ( u, v) / D 0 where D 0 is the cutoff frequency. When D(u,v) = D 0 u, the GLPF is down to 0.607 of its maximum value. 17
Gaussian Low-Pass Filter (GLPF) 18
Gaussian Low-Pass Filter GLPFs do not produce ringing effect on the images and important characteristic in practice especially in applications that require no artifacts Example: 19
Comparison of LPFs Ideal LPF Butterworth LPF of order Gaussian LPF Cutoff frequencies are set at radii values of 5, 15, 30, 80, 30, left to right, top to bottom 0
High-Pass Filter (in Freq. Domain) Highpass filter remove low-frequency information, or allow HIGH-frequency information to PASS through Useful for sharpening, edge enhancement Transfer function of the highpass filters can be obtained using the relation H ( u, v) = 1 H ( u, v) hp where H lp (u,v) is the transfer function of the corresponding lowpass filter lp 1
High-Pass Filters Ideal highpass filter 0 if D( u, v) D0 H ( u, v) = 1 if D( u, v) > D0 Butterworth highpass filter of order n and with cutoff frequency locus at a distance D 0 from the origin: H ( u, v) = + 1 [ D / (, )] n o D u v Gaussian highpass filter with cutoff frequency locus at a distance D 0 from the origin H ( u, v) = 1 e 1 D ( u, v)/ D 0
High-Pass Filters 3
High-Pass Filters 4
Frequency Domain vs. Spatial Domain 5
Laplacian Filter in Frequency Domain The Fourier transform of Laplacian equation is f x f y [ ] f ( x, y) = + = ( u + v ) F( u, v) I This means that the Laplacian filter in frequency domain can be express as H ( u, v) = ( u + v ) 6
Laplacian Filter in Frequency Domain As the filter origin was shifted to the center of image, we may shift the Laplacian filter in frequency domain by M/ and N/ respectively: Dual relationship in the familiar Fourier transformpair notation: f ( x, y) [ ] ( u M / ) + ( v / ) H ( u, v) = N [ ] ( u M / ) + ( v N / ) F( u, v) 7
8 Laplacian Filter in Frequency Domain The enhanced image by Laplacian filter (using frequency filter), g(x,y) is: Note: Central of Laplacian mask in spatial domain is negative, thus resulting in the equation above ), ( ), ( ), ( y x f y x f y x g = [ ] { } ), ( ) ) / ( ) / (( 1 ), ( 1 v u F N v M u y x g + + I =
Laplacian Filter in Frequency Domain 9
Example: Laplacian Filter 30
High-boost Filtering in Frequency Domain Enhanced image using Laplacian high-boost masking filter can be obtained as follows: g x y Af x y f x y 1 (, ) = I I (, ) (, ) { A (( u M / ) ( v N / ) ) F( u, v) } = I + + 1 The Laplacian high-boost masking filter is H ( u, v) = [ (( / ) ( / ) )] A + u M + v N 31
Example: High-boost Filtering 3
Example: High-boost Filtering 33
Homomorphic Filtering Illumination-reflection Model: Let f(x,y) be non-zero and finite image that 0 < f(x,y) <, f(x,y) may be characterized by components: Source illumination incident on the scene being viewed Amount of illumination reflection by the objects in the scene The two functions combine as a product to form f(x,y) = i(x,y)*r(x,y) where 0 < i(x,y) <, and 0 < r(x,y) < 1 34
Homomorphic Filtering Illumination and Reflection have very different characteristics: Illumination components tend to be slow in spatial variation (low frequency components) Reflection of various objects tends to vary abruptly (high frequency components) 35
Homomorphic Filtering Better control can be achieved if the two components are separated by log function and filters are applied separately to each of the respective components before inversing back z( x, y) = ln( f ( x, y)) = ln( i( x, y)) + ln( r( x, y)) Z( u, v) = I { z( x, y)} = I {ln( i( x, y))} + I{ln( r( x, y))} = F ( u, v) + F ( u, v) i r S( u, v) = H ( u, v) Z( u, v) = H ( u, v) F ( u, v) + H ( u, v) F ( u, v) 1 1 (, ) { (, ) i (, )} { (, ) r (, )} '(, ) i s x y = I H u v F u v + I H u v F u v = i x y + r '( x, y) g x y e e e i x y r x y s( x, y) i '( x, y) r '( x, y) (, ) = = = 0 (, ) 0 (, ) r 36
Homomorphic Filtering The whole process can be summarized as follows: 37
Homomorphic Filtering Filter H(u,v) can be designed such that it tends to decrease the contribution made by low frequencies (illumination, γ L < 1) and amplify the contribution made by high frequencies (reflectance, γ H > 1) The result is simultaneous dynamic range compression and contrast enhancement. 38
Homomorphic Filtering The curve shape can be approximated using the basic form of any of the ideal highpass filters. Example: using a slightlymodified form of GHPF gives: H ( u, v) = ( cd ( u, v)/ D0 γ H γ L )[1 e ] + γ L where constant c controls the sharpness of the slope of the filter function as it transitions between γ L and γ H 39
Example: Homomorphic Filtering 40
Selective Filtering The previous filters all operate over the entire frequency rectangle. However, some applications only require processing of specific bands of frequencies or small regions of the frequency rectangle Bandreject / Bandpass Filters Notch Filters More on selective filtering in Image Restoration next week, but now briefly... 41
Bandreject / Bandpass Filters Based on previous types of filters (Ideal, Butterworth, Gaussian), Bandreject filters can be constructed by adding an addition parameter width of the band, W 0 u, v) = 1 W,if D0 D,otherwise H ( 0 IBR H GBR ( u, v) = 1 e D D DW 0 Equivalent Bandpass filters can be obtained from a bandreject filter by inversing its effect, H BP D W + ( u, v) = 1 H ( u, v) BR 1 = DW 1+ D + D H BBR( u, v) n 0 4
Notch Filters Notch Filter rejects or passes frequencies in a predefined neighborhood about the center of the frequency rectangle A notch with center at (u 0,v 0 ) must have corresponding notch at location (-u 0,-v 0 ) symmetric about origin Notch Reject Filters are constructed as products of highpass filters whose centers translate to the centers of the notches H NR ( u, v) = H k = 1 ( u, v) H ( u, v) where H k (u,v) and H -k (u,v) are highpass filters whose centers are at (u k, v k ) and (-u k,-v k ) respectively Q k k 43
Notch Filters Notch Pass Filter is obtained from a Notch Reject Filter using the expression H NP ( u, v) = 1 H ( u, v) NR Pictures with Moiré patterns, can be filtered using a notch reject filter 44
Other Transforms Discrete Cosine Transform (DCT) Real basis functions, JPEG compression Discrete Sine Transform (DST) Hadamard Transform Walsh Transform Haar Transform Slant Transform Wavelet Transform Multi-resolution, JPEG000 compression 45
Recommended Readings Digital Image Processing (3 rd Edition), Gonzalez & Woods, Chapter 4: 4.7 4.10 (Week 6) Chapter 5: Image Restoration 5.1 5.4 (Week 7) 46