Digital Image Processing in Frequency Domain Md. Al Mehedi Hasan Assistant Professor Dept. of Computer Science & Engineering RUET, Rajshahi How con we connect broken text ? How can we remove blemishes in a photograph? Enhanced image How can we get the enhanced image from the original image? How can we get this original image? Image transformation What is a transformation? • im is the original image; • IM is the transformed image; • ๐ฅ, ๐ฆ (or ๐ข, ๐ฃ) represents the spatial coordinates of a pixel. Goal of a transformation The goal of a transformation is to get a new representation of the incoming picture. This new representation can be more convenient for a particular application or can ease the extraction of particular properties of the picture. Image transformation Point to point transformation • Geometric transformation such as rotation, scaling... Example of rotation: Remark: a point to point transformation doesn't require extra memory... Local to point transformation Note that local to point transformation is also called neighborhood operators. Examples of local to point transformation: Global to point transformation One of the most important transformation is the Fourier transform that gives a frequential representation of the signal. Fourier series (development in real term): Every periodic signal can be decomposed into a linear combination of sinusoidal and cosinusoidal component functions. ∞ ๐ ๐ฅ = ๐0 + ∞ ๐๐ cos(2๐๐๐๐ฅ) + ๐=1 ๐๐ sin(2๐๐๐๐ฅ) ๐=1 ๐๐ and ๐๐ are used to weight the influence of each frequency component. Why Frequency Domain? Similar jobs can be done in the spatial and frequency domains. Filtering in the spatial domain can be easier to understand. Filtering in the frequency especially for large images. domain can be much faster – Note that convolution in the time domain is equivalent to multiplication in the frequency domain (and vice versa) – When you are faced with a difficult convolution (or multiplication), you can switch domains and do the complement operation Jean Baptiste Joseph Fourier Fourier was born in Auxerre, France in 1768 – Most famous for his work “La Théorie Analitique de la Chaleur” published in 1822 – Translated into English in 1878: “The Analytic Theory of Heat” Nobody paid much attention when the work was first published One of the most important mathematical theories in modern engineering Images taken from Gonzalez & Woods, Digital Image Processing (2002) The Big Idea = Any function that periodically repeats itself can be expressed as a sum of sines and cosines of different frequencies each multiplied by a different coefficient – a Fourier series Mathematical Background Sine and Cosine Functions • Periodic functions • General form of sine and cosine functions: ๐ฆ ๐ก = ๐ด๐ ๐๐(๐ผ๐ก + ๐) ๐ฆ ๐ก = ๐ด๐๐๐ (๐ผ๐ก + ๐) Sine and Cosine Functions (cont’d) • Changing the period T=2π/|α| e.g., y=cos(αt) α =4 period 2π/4=π/2 shorter period higher frequency (i.e., oscillates faster) Frequency is defined as f=1/T Different notation: cos(αt)=cos(2πt/T)=cos(2πft) Angular Frequency In physics, angular frequency ω is a scalar measure of rotation rate. Angular frequency is the magnitude of the vector quantity angular velocity. One revolution is equal to 2π radians, hence Where ω is the angular frequency or angular speed (measured in radians per second), T is the period (measured in seconds), f is the ordinary frequency (measured in hertz). Different Notation of Sine and Cosine Functions • Changing the period T=2π/|α| e.g., y=cos(αt) α =4 period 2π/4=π/2 shorter period higher frequency (i.e., oscillates faster) Frequency is defined as f=1/T Different notation: cos(αt)=cos(2πt/T)=cos(2πft)=cos(๐ค0 ๐ก) where ๐ค0 = 2๐๐ Different Notation of Sine and Cosine Functions (continue) cos 2๐๐๐๐ฅ sin 2๐๐๐๐ฅ ๐ ๐ฅ = ๐0 + ๐1 cos 2๐๐๐ฅ + ๐2 cos(2๐๐2๐ฅ)+๐3 cos 2๐๐3๐ฅ + โฏ +๐1 sin 2๐๐๐ฅ + ๐2 sin(2๐๐2๐ฅ)+๐3 sin 2๐๐3๐ฅ + โฏ Fundamental Frequency? Time Domain and Frequency Domain Time Domain: The time-domain plot shows changes in signal amplitude with respect to time. Phase and frequency are not explicitly measure on a time-domain plot. Frequency Domain: The time-domain plot shows changes in signal amplitude with respect to frequency. The time-domain and frequency-domain plots of a sine wave 3.22 The time domain and frequency domain of three sine waves A composite periodic signal Decomposition of a composite periodic signal in the time and frequency domains Spatial Frequency in image When we deal with a one dimensional signal (time series), it is quite easy to understand what the concept of frequency is. Frequency is the number of occurrences of a repeating event per unit time. For example, in the figure below, we have 3 cosine functions with increasing frequencies cos(t), cos(2t), and cos(3t). So, we know that a sequence of such numbers gives us the feeling that cos(t) is a low frequency signal. How we can create an image of these numbers? Let scale the numbers to the range 0 and 255: Considering that values are intensity values, we can obtain the following image. This is our first image with a low frequency component. We have a smooth transition from white to black and black to white. However, it is still difficult to say anything since we have not seen an image with high frequency. If we repeat all the steps for cos(3t) , we obtain the following image: where we have sudden jumps to black. You can try the same experiment for different cosines. By looking at two examples, we can say that if there are sharp intensity changes in an image, those regions correspond to high frequency components. On the other hand, regions with smooth transitions correspond to low frequency components. We now have an idea for one dimensional image. It is time to switch to two dimensional representation of a signal. Let us first define a kind of two dimensional signal: f(x, y)=cos(kx) cos(ky). For example, the signal for k=1, we have: f(x, y)=cos(x) cos(y). Our corresponding two dimensional function will be f(x, y)=cos(x) cos(y). How we will obtain a two dimensional image from this function? This is the question! We are going to define a matrix and store the values of f(x,y) for different (x, y) pairs. Basically, we divide the angle range 0-2∏ into M=512 and N=512 regions for x and y, respectively. Here are images for different k values. Values of k represents the level of frequency (from low to high) for k=0,….,20. Similar to the 1D case, we can say that if the intensity values in an image changes dramatically, that image has high frequency components. Special Frequency In Images ๏ท Spatial frequency of an image refers to the rate at which the pixel intensities change ๏ท In picture on right: ๏ฎ High frequences: ๏ฌ ๏ฎ Near center Low frequences: ๏ฌ Corners Fourier Series and it’s Derivation According to Fourier, any periodic function defined in can be expressed as ∞ ๐ ๐ฅ = ๐0 + ∞ ๐๐ cos(๐๐ฅ) + ๐=1 Where 1 ๐0 = 2๐ 1 ๐๐ = ๐ 1 ๐๐ = ๐ ๐๐ sin(๐๐ฅ) ๐=1 ๐ ๐ ๐ฅ ๐๐ฅ −๐ ๐ ๐ ๐ฅ cos(๐๐ฅ)๐๐ฅ −๐ ๐ ๐ ๐ฅ ๐ ๐๐(๐๐ฅ)๐๐ฅ −๐ ๐ = 1,2,3, … … Mathematical Concepts Basis, Coordinate Definition A: A set ๐ = ๐ข1 , ๐ข2 , … … , ๐ข๐ of vectors is a basis of V if it has the following two properties: ( 1 ) S is linearly independent. (2) S spans V. Definition B: A set ๐ = ๐ข1 , ๐ข2 , … … , ๐ข๐ of vectors is a basis of V if every ๐ฃ๐๐ can be written uniquely as a linear combination of the basis vectors. Let ๐ฃ๐๐ ๐ฃ = ๐1 ๐ข1 + ๐2 ๐ข2 + โฏ + ๐๐ ๐ข๐ These n scalars ๐1 , ๐2 , … … , ๐๐ are called the coordinates of v relative to the basis S. Thus ๐ฃ ๐ = ๐1 , ๐2 , … … , ๐๐ Example Consider real space ๐ 3 . The following vectors form a basis S of ๐ 3 : The coordinates of v = (5 , 3 , 4) relative to the basis S is obtained as follows. Set ๐ฃ = ๐ฅ๐ข1 + ๐ฆ๐ข2 + ๐ง๐ข3 , that is, set v as a linear combination of the basis vectors using unknown scalars x, y, z. This yields: The equivalent system of linear equations is as follows: The solution of the system is x = 3, y = 2, z = 4. Thus Inner product Definition An inner product on a real vector spaces V is a function that associates a number, denoted ใu, vใ, with each pair of vectors u and v of V. This function has to satisfy the following conditions for vectors u, v, and w, and scalar c. 1.ใu, vใ=ใv, uใ (symmetry axiom) 2.ใu + v, wใ=ใu, wใ+ใv, wใ (additive axiom) 3.ใcu, vใ= cใu, vใ (homogeneity axiom) 4.ใu, uใ๏ณ 0, and ใu, uใ= 0 if and only if u = 0 (position definite axiom) 40 Inner product Space, Norm. Metric, Projection Inner Product Ine Space N Norm Metric Orthogonal Projection ORTHOGONAL SETS AND BASES Consider a set ๐ = ๐ข1 , ๐ข2 , … … , ๐ข๐ of nonzero vectors in an inner product space V. S is called orthogonal if each pair of vectors in S are orthogonal, and S is called orthonormal if S is orthogonal and each vector in S has unit length. That is: Orthogonal Basis and Linear Combinations Let S consist of the following three vectors in ๐ 3 : we can verify that the vectors are orthogonal; hence they are linearly independent. Thus S is an orthogonal basis of ๐ 3 . Suppose we want to write v = (7 , 1 , 9) as a linear combination of ๐ข1 , ๐ข2 , ๐ข3 . First we set v as a linear combination of ๐ข1 , ๐ข2 , ๐ข3 using unknowns ๐ฅ1 , ๐ฅ2 , ๐ฅ3 as follows: Method One Expand (*) to obtain the system Solve the system by Gaussian elimination to obtain ๐ฅ1 = 3, ๐ฅ2 = − 1, ๐ฅ3 = 2. Thus Method Two This method uses the fact that the basis vectors are orthogonal, and the arithmetic i s much simpler. If we take the inner product of each side of (*) with respect to ๐ข๐ we get Here two terms drop out, since ๐ข1 , ๐ข2 , ๐ข3 are orthogonal. Accordingly, Orthogonal Basis and Linear Combinations (continue) Theorem Let ๐ข1 , ๐ข2 , … … , ๐ข๐ be an orthogonal basis of V. Then, for any ๐ฃ ∈ ๐, ๐ฃ, ๐ข1 ๐ฃ, ๐ข2 ๐ฃ, ๐ข๐ ๐ฃ= ๐ข1 + ๐ข2 + โฏ + ๐ข๐ ๐ข1 , ๐ข1 ๐ข2 , ๐ข2 ๐ข๐ , ๐ข ๐ Hilbert Space Definition . A Hilbert space H is a vector space endowed with an inner product and associated norm and metric, such that every Cauchy sequence in H has a limit in H. An example of a Hilbert space is the space ๐ฟ2 (๐, ๐) Definition of ๐ฟ2 (๐, ๐) . The space ๐ฟ2 (๐, ๐) is the collection of Borel measurable real or complex valued square integrable functions f on (a,b), i.e., ๐ ๐ ๐(๐ก) 2 < ∞ , endowed with inner product ๐, ๐ = ๐ ๐(๐ก)๐ ๐ ๐ก ๐๐ก ,and associated norm and metric ๐ = ๐ ๐ ๐(๐ก) 2 ๐๐ก , ๐ ๐, ๐ = ๐ − ๐ = ๐ ๐ ๐ ๐ก − ๐(๐ก) 2 ๐๐ก respectively, where the integrals involved are Lebesgue integrals. Basis of a Hilbert space ๐ ๐ and ๐ถ ๐ are examples of finite dimensional Hilbert spaces; that is, any basis will have a finite number of basis vectors (in fact, n of them); expressing a vector in ๐ ๐ and ๐ถ ๐ as a vector in terms of an orthonormal basis is easy. In infinite-dimensional Hilbert spaces, however, such an expression must involve an infinite sum, and hence issues of convergence. To say that ๐ฅ = ∞ 1 ๐ฅ๐ ๐๐ for some vectors ๐๐ , we mean that ๐ฅ− ๐ ๐=1 ๐ฅ๐ ๐๐ → 0 as ๐ → ∞ Basis of a Hilbert space (con..) Orthonormal System: Let V be an inner product space. A collection of vectors ๐ฅ๐ผ ๐ผ∈๐ด ⊆ ๐ is said to be an orthonormal system if ๐ฅ๐ผ , ๐ฅ๐ฝ = 0 for ๐ผ ≠ ๐ฝ and if ๐ฅ๐ผ , ๐ฅ๐ผ = 1 for all ๐ผ ∈ ๐ด. Complete orthonormal system A collection of vectors ๐ฅ๐ผ ๐ผ∈๐ด in a Hilbert space H is complete if ๐ฆ, ๐ฅ๐ผ = 0 for all ๐ผ ∈ ๐ด implies that y = 0. An equivalent definition of completeness is the following. ๐ฅ๐ผ ๐ผ∈๐ด is complete in H if span ๐ฅ๐ผ is dense in H , that is, given u ∈ ๐ป and ๐ > 0, there exists ๐ฃ ∈ ๐ ๐๐๐ ๐ฅ๐ผ such that ๐ข − ๐ฃ < ๐. Basis of a Hilbert space (Continue) Definition Let ๐ธ be an orthonormal set in an Hilbert space ๐ .Then ๐ธ is said to be an orthonormal basis of ๐ if it is a complete orthonormal set in ๐. Theorem Let ๐ธ be an orthonormal set in an Hilbert space ๐. Then ๐ธ is an orthonormal basis if and only if ๐ฌ⊥ = {๐}. Theorem Every Hilbert spaces has an orthonormal basis. Separable Hilbert spaces Definition. A Hilbert space with a countable dense subset is separable. That is, a separable Hilbert space H has subset ๐ท = ๐1 , ๐2 , … such that for any ๐ฆ ∈ ๐ป and for all ๐ > 0, there exist ๐๐ ∈ ๐ท with ๐ฆ − ๐๐ < ๐. Therefore the closure of D is H. Theorem A Hilbert space ๐ is separable if and only if it has a countable orthonormal basis. Basis of a Separable Hilbert space A set ๐๐ |๐ ∈ โ is a basis for a Hilbert space H if every x can be expressed uniquely in the form ๐ฅ= ∞ ๐=1 ๐ฅ๐ ๐๐ for some ๐ฅ๐ in the field of scalars. If in addition ๐๐ |๐ ∈ โ is an orthonormal set, then we refer to it as an orthonormal basis. Proposition . Let ๐๐ |๐ ∈ โ be an orthonormal set in a Hilbert space H. Then the following are equivalent: According to Fourier, any function defined in can be expressed as ∞ ๐ ๐ฅ = ๐0 + ∞ ๐๐ cos(๐๐ฅ) + ๐=1 Where 1 ๐0 = 2๐ 1 ๐๐ = ๐ 1 ๐๐ = ๐ ๐๐ sin(๐๐ฅ) ๐=1 ๐ ๐ ๐ฅ ๐๐ฅ −๐ ๐ ๐ ๐ฅ cos(๐๐ฅ)๐๐ฅ −๐ ๐ ๐ ๐ฅ ๐ ๐๐(๐๐ฅ)๐๐ฅ −๐ ๐ = 1,2,3, … … (Con..) ∞ ๐ ๐ฅ = ๐0 + ∞ ๐๐ cos(๐๐ฅ) + ๐=1 ๐๐ sin(๐๐ฅ) ๐=1 This is an infinite series of continuous functions, so each of the functions 1, ๐๐๐ ๐ฅ, ๐ ๐๐๐ฅ, ๐๐๐ 2๐ฅ, ๐ ๐๐2๐ฅ, … . belong to . What happens if we compute the inner product of these functions? (Con..) (Con..) So the functions 1, cos x, sin x, cos 2x, sin 2x, . . . are orthogonal with respect to the ๐ฟ2 inner product! (Con..) They are not, however, orthonormal, since: (Con..) Normalizing them appropriately, we get the orthonormal sequence of functions: 1 1 1 1 1 , ๐๐๐ ๐ฅ, ๐ ๐๐๐ฅ, ๐๐๐ 2๐ฅ, ๐ ๐๐2๐ฅ, … . ๐ ๐ ๐ 2๐ ๐ If this sequence were in fact an orthonormal basis, then we would be able to say that every function in has an expression in terms of that basis, i.e. a Fourier series, which converges to the function in question. (Con..) Theorem. The sequence 1 1 1 1 1 , ๐๐๐ ๐ฅ, ๐ ๐๐๐ฅ, ๐๐๐ 2๐ฅ, ๐ ๐๐2๐ฅ, … . ๐ ๐ ๐ 2๐ ๐ of functions in form an orthonormal basis of that space. Lemma. If f is integrable on [−π, π], and f is orthogonal to each of the functions 1 1 1 1 1 , ๐๐๐ ๐ฅ, ๐ ๐๐๐ฅ, ๐๐๐ 2๐ฅ, ๐ ๐๐2๐ฅ, … . ๐ ๐ ๐ 2๐ ๐ then f(x) = 0 almost everywhere in [−π, π]. So we can write any function defined in AS ∞ ๐ ๐ฅ = ๐0 + ∞ ๐๐ cos(๐๐ฅ) + ๐=1 ๐๐ sin(๐๐ฅ) ๐=1 Inner Product of ๐ ๐, ๐ = ๐(๐ฅ)๐ ๐ฅ ๐๐ฅ −๐ So we can write any function defined in AS ๐ ๐ฅ ๐(๐ฅ), 1 = 1 1,1 ∞ + ๐=1 So ∞ ๐(๐ฅ), cos(๐๐ฅ) ๐(๐ฅ), sin(๐๐ฅ) cos(๐๐ฅ) + sin(๐๐ฅ) sin(๐๐ฅ), sin(๐๐ฅ) cos(๐๐ฅ), cos(๐๐ฅ) ๐=1 1 ๐0 = 2๐ 1 ๐๐ = ๐ 1 ๐๐ = ๐ ๐ ๐ ๐ฅ ๐๐ฅ −๐ ๐ ๐ ๐ฅ cos(๐๐ฅ)๐๐ฅ −๐ ๐ ๐ ๐ฅ ๐ ๐๐(๐๐ฅ)๐๐ฅ −๐ ๐ = 1,2,3, … … Functions of arbitrary periodicity Functions with a periodicity of 2๐ฟ (i.e: ๐ ๐ฅ + 2๐ฟ๐ = ๐(๐ฅ) for all n) ๐๐ฅ can be decomposed into contributions from sin(๐ ) and ๐๐ฅ cos(๐ ) ๐ฟ ๐ฟ which are periodic on the period 2๐ฟ. ∞ ๐ ๐ฅ = ๐0 + ∞ ๐๐ cos(๐๐๐ฅ/๐ฟ) + ๐=1 Where 1 ๐0 = 2๐ฟ 1 ๐๐ = ๐ฟ 1 ๐๐ = ๐ฟ ๐๐ sin(๐๐๐ฅ/๐ฟ) ๐=1 ๐ฟ ๐ ๐ฅ ๐๐ฅ −๐ฟ ๐ฟ ๐ ๐ฅ cos(๐๐๐ฅ/๐ฟ)๐๐ฅ −๐ฟ ๐ฟ ๐ ๐ฅ ๐ ๐๐(๐๐๐ฅ/๐ฟ)๐๐ฅ −๐ฟ An equation with many faces ∞ ∞ ๐ ๐ฅ = ๐0 + ๐๐ cos(๐๐ฅ) + ๐=1 ∞ ๐ ๐ฅ = ๐0 + ๐๐ sin(๐๐ฅ) ๐=1 ∞ ๐๐ cos(2๐๐๐๐ฅ) + ๐=1 ∞ ๐๐ sin(2๐๐๐๐ฅ) ๐=1 ∞ ๐ ๐ฅ = ๐0 + ๐๐ cos(๐๐ค๐ฅ) + ๐=1 ∞ ๐ ๐ฅ = ๐0 + ๐๐ sin(๐๐ค๐ฅ) ๐=1 ∞ ๐๐ cos(2๐๐๐ฅ/๐) + ๐=1 ๐=1 ∞ ๐ ๐ฅ = ๐0 + ๐๐ sin(2๐๐๐ฅ/๐) ∞ ๐๐ cos(๐๐๐ฅ/๐ฟ) + ๐=1 ๐๐ sin(๐๐๐ฅ/๐ฟ) ๐=1 The Complex Fourier Series You are reminded of the following identities: Let ๐๐ and ๐๐ be the Fourier coefficients of the function f(x) defined on [-L, L]. We introduce a new set of coefficients, viz. ๐๐ , where ๐ = −∞, … , −๐, −๐ + 1, 0, 1, ๐ − 1, ๐, … ∞ . These are given by ๐0 = ๐0 ๐0 = ๐0 1 ๐๐ = (๐๐ + ๐−๐ ) ๐๐ = (๐๐ − ๐๐๐ ) 2 1 ๐๐ = (๐๐ − ๐๐−๐ ) ๐−๐ = (๐๐ + ๐๐๐ ) 2 The Fourier series may then be expressed as ๐ ๐ฅ = ๐0 + ∞ ๐=1 ๐๐ cos(๐๐๐ฅ/๐ฟ) + ∞ ๐=1 ๐๐ sin(๐๐๐ฅ/๐ฟ) =๐0 + ∞ ๐=1[(๐๐ +๐−๐ )cos(๐๐๐ฅ/๐ฟ) + ๐(๐๐ +๐−๐ )sin(๐๐๐ฅ/๐ฟ)] =๐0 + ∞ ๐=1[๐๐ (cos ๐๐๐ฅ/๐ฟ + ๐sin(๐๐๐ฅ/๐ฟ))] + ๐−๐ ((cos(๐๐๐ฅ/ A new formula for the Fourier coefficients can be obtained as follows: 1 1 ๐ฟ [ −๐ฟ ๐ 2 ๐ฟ 1 = 2๐ฟ ๐ฅ ๐ฟ 1 ๐±๐ = (๐๐ ± ๐๐๐ ) 2 ๐๐๐ฅ ๐ ๐ฟ cos ๐๐ฅ ± −๐ฟ ๐ ๐ฟ ๐ฟ ๐ ๐ฅ −๐ฟ 1 = 2๐ฟ = ๐ฅ sin ๐๐๐ฅ ๐๐๐ฅ cos ± ๐๐ ๐๐ ๐ฟ ๐ฟ ๐๐๐ฅ ๐ฟ ๐๐ฅ ๐ฟ ๐(๐ฅ)๐ ±๐๐๐๐ฅ/๐ฟ ๐๐ฅ −๐ฟ and 1 ๐0 = ๐0 = 2๐ฟ ๐ฟ ๐(๐ฅ)๐ 0 ๐๐ฅ −๐ฟ The formula for the complex Fourier coefficients is therefore ๐๐ = 1 ๐ฟ −๐๐๐๐ฅ/๐ฟ ๐๐ฅ ๐(๐ฅ)๐ 2๐ฟ −๐ฟ ๐๐ฅ] for ๐ = −∞, … … … , ∞ Meaning of Coefficients ๐ ๐ฅ = ๐0 + ๐1 cos ๐ฅ + ๐2 cos(2๐ฅ)+๐3 cos 3๐ฅ + โฏ +๐1 sin ๐ฅ + ๐2 sin(2๐ฅ)+๐3 sin 3๐ฅ + โฏ ๐ ๐ฅ = ๐0 + ๐1 cos 2๐๐๐ฅ + ๐2 cos(2๐๐2๐ฅ)+๐3 cos 2๐๐3๐ฅ + โฏ +๐1 sin 2๐๐๐ฅ + ๐2 sin(2๐๐2๐ฅ)+๐3 sin 2๐๐3๐ฅ + โฏ Examples of Signals and the Fourier Series Representation Sawtooth Signal ๐ ๐ = 3.69 ๐๐จ ๐๐จ ๐๐จ ๐๐จ ๐ฌ๐ข๐ง ๐๐ ๐๐ − ๐๐๐ ๐๐ ๐๐๐ + ๐๐๐ ๐๐ ๐๐๐ − ๐๐๐ ๐๐ ๐๐๐ + โฏ ๐ ๐๐ ๐๐ ๐๐ Application Fourier Series to Fourier Transform If ๐(๐ฅ) has period 2๐ฟ, its (complex) Fourier series expansion is ๐=∞ f x = ๐๐๐๐ฅ ๐๐ ๐ ๐ฟ ๐=−∞ ๐๐ = 1 ๐ฟ −๐๐๐๐ฅ/๐ฟ ๐๐ฅ ๐(๐ฅ)๐ 2๐ฟ −๐ฟ We now develop an expansion for non-periodic functions, by allowing complex exponentials (or equivalently sin’s and cos’s) of all possible periods, not just 2๐ฟ, for some fixed ๐ฟ. So, from now on, do not assume that ๐(๐ฅ) is periodic. Fourier Series to Fourier Transform 1 f x = 2๐ ∞ ๐ ๐ค ๐ ๐๐ค๐ฅ ๐๐ค −∞ Where ∞ ๐ ๐ค = ๐(๐ฅ)๐ −๐๐ค๐ฅ ๐๐ฅ −∞ Parseval's Theorem: Energy Relations in Time and Frequency Now We have Finished Mathematical Discussion Start DFT and it’s application in Image Processing Discrete Fourier Transform 1-D case Discrete Fourier transform (1-D) The Discrete Fourier Transform (DFT) 2-D case The Discrete Fourier Transform of f(x, y), for x = 0, 1, 2…M-1 and y = 0,1,2…N-1, denoted by F(u, v), is given by the equation: M ๏ญ1 N ๏ญ1 F (u, v) ๏ฝ ๏ฅ๏ฅ f ( x, y)e ๏ญ j 2๏ฐ ( ux / M ๏ซvy / N ) x ๏ฝ0 y ๏ฝ0 for u = 0, 1, 2…M-1 and v = 0, 1, 2…N-1. The Inverse DFT It is really important to note that the Fourier transform is completely reversible. The inverse DFT is given by: 1 f ( x, y ) ๏ฝ MN M ๏ญ1 N ๏ญ1 ๏ฅ๏ฅ F (u, v)e u ๏ฝ0 v ๏ฝ0 for x = 0, 1, 2…M-1 and y = 0, 1, 2…N-1 j 2๏ฐ ( ux / M ๏ซvy / N ) Discrete Fourier transform (2-D) Spatial Domain and Frequency Domain of an Image Image data can be represented in either the spatial domain or the frequency domain. The frequency domain contains the same information as the spatial domain but in a vastly different form. Useful for data compression More efficient for certain image operations Spatial Domain Frequency Domain For each location in the image, what is the value of the light intensity at that location? For each frequency component in the image, what is power or its amplitude? Image and it’s DFT Image Representation using basis A frequential decomposition in terms of exponential basis images ... f ๐ฅ, ๐ฆ = ๐น 0,0 × exp ๐2๐ 0 × ๐ฅ + 0 × ๐ฆ + ๐น 0,1 × exp ๐2๐ 0 × ๐ฅ + 1 × ๐ฆ + ๐น 1,0 × exp ๐2๐ 1 × ๐ฅ + 0 × ๐ฆ + โฏ f ๐ฅ, ๐ฆ = ๐น 0,0 + ๐น 0,1 (cos 2๐๐ฆ + ๐ sin 2๐๐ฆ ) + ๐น 1,0 (cos 2๐๐ฅ + ๐ sin 2๐๐ฅ ) + โฏ ๐น[๐ข, ๐ฃ] are the weighting coefficients of the spatial frequencies present in the signal. Note: A picture having a size of ๐ × ๐ is a linear combination of ๐ × ๐ exponential basis images!!!! Image Representation using basis Images taken from Gonzalez & Woods, Digital Image Processing (2002) The DFT and Image Processing DFT & Images DFT Scanning electron microscope image of an integrated circuit magnified ~2500 times Fourier spectrum of the image Filter Images taken from Gonzalez & Woods, Digital Image Processing (2002) Some Basic Frequency Domain Filters Low Pass Filter High Pass Filter Smoothing Frequency Domain Filters Smoothing is achieved in the frequency domain by dropping out the high frequency components The basic model for filtering is: G(u,v) = H(u,v)F(u,v) where F(u,v) is the Fourier transform of the image being filtered and H(u,v) is the filter transform function Low pass filters – only pass the low frequencies, drop the high ones Images taken from Gonzalez & Woods, Digital Image Processing (2002) Ideal Low Pass Filter Simply cut off all high frequency components that are a specified distance D0 from the origin of the transform changing the distance changes the behaviour of the filter Ideal Low Pass Filter (cont…) The transfer function for the ideal low pass filter can be given as: ๏ฌ1 if D(u, v) ๏ฃ D0 H (u, v) ๏ฝ ๏ญ ๏ฎ0 if D(u, v) ๏พ D0 where D(u,v) is given as: D(u, v) ๏ฝ [(u ๏ญ M / 2) 2 ๏ซ (v ๏ญ N / 2) 2 ]1/ 2 Images taken from Gonzalez & Woods, Digital Image Processing (2002) Ideal Low Pass Filter (cont…) Above we show an image, it’s Fourier spectrum and a series of ideal low pass filters of radius 5, 15, 30, 80 and 230 superimposed on top of it Images taken from Gonzalez & Woods, Digital Image Processing (2002) Ideal Low Pass Filter (cont…) Original image Result of filtering with ideal low pass filter of radius 5 Result of filtering with ideal low pass filter of radius 15 Result of filtering with ideal low pass filter of radius 30 Result of filtering with ideal low pass filter of radius 80 Result of filtering with ideal low pass filter of radius 230 Illustration Images taken from Gonzalez & Woods, Digital Image Processing (2002) Butterworth Lowpass Filters The transfer function of a Butterworth lowpass filter of order n with cutoff frequency at distance D0 from the origin is defined as: 1 H (u , v) ๏ฝ 1 ๏ซ [ D(u , v) / D0 ]2 n Images taken from Gonzalez & Woods, Digital Image Processing (2002) Butterworth Lowpass Filter (cont…) Original image Result of filtering with Butterworth filter of order 2 and cutoff radius 5 Result of filtering with Butterworth filter of order 2 and cutoff radius 15 Result of filtering with Butterworth filter of order 2 and cutoff radius 30 Result of filtering with Butterworth filter of order 2 and cutoff radius 80 Result of filtering with Butterworth filter of order 2 and cutoff radius 230 Images taken from Gonzalez & Woods, Digital Image Processing (2002) Gaussian Lowpass Filters The transfer function of a Gaussian lowpass filter is defined as: H (u, v) ๏ฝ e ๏ญ D 2 ( u ,v ) / 2 D0 2 Images taken from Gonzalez & Woods, Digital Image Processing (2002) Gaussian Lowpass Filters (cont…) Original image Result of filtering with Gaussian filter with cutoff radius 5 Result of filtering with Gaussian filter with cutoff radius 15 Result of filtering with Gaussian filter with cutoff radius 30 Result of filtering with Gaussian filter with cutoff radius 85 Result of filtering with Gaussian filter with cutoff radius 230 Images taken from Gonzalez & Woods, Digital Image Processing (2002) Lowpass Filters Compared Result of filtering with ideal low pass filter of radius 15 Result of filtering with Gaussian filter with cutoff radius 15 Result of filtering with Butterworth filter of order 2 and cutoff radius 15 Images taken from Gonzalez & Woods, Digital Image Processing (2002) Lowpass Filtering Examples A low pass Gaussian filter is used to connect broken text Images taken from Gonzalez & Woods, Digital Image Processing (2002) Lowpass Filtering Examples (cont…) Different lowpass Gaussian filters used to remove blemishes in a photograph Sharpening in the Frequency Domain Edges and fine detail in images are associated with high frequency components. High pass filters – only pass the high frequencies, drop the low ones High pass frequencies are precisely the reverse of low pass filters, so: Hhp(u, v) = 1 – Hlp(u, v) Images taken from Gonzalez & Woods, Digital Image Processing (2002) Ideal High Pass Filters The ideal high pass filter is given as: ๏ฌ0 if D(u, v) ๏ฃ D0 H (u, v) ๏ฝ ๏ญ ๏ฎ1 if D(u, v) ๏พ D0 where D0 is the cut off distance as before Images taken from Gonzalez & Woods, Digital Image Processing (2002) Ideal High Pass Filters (cont…) Results of ideal high pass filtering with D0 = 15 Results of ideal high pass filtering with D0 = 30 Results of ideal high pass filtering with D0 = 80 Images taken from Gonzalez & Woods, Digital Image Processing (2002) Butterworth High Pass Filters The Butterworth high pass filter is given as: 1 H (u , v) ๏ฝ 2n 1 ๏ซ [ D0 / D(u , v)] where n is the order and D0 is the cut off distance as before Images taken from Gonzalez & Woods, Digital Image Processing (2002) Butterworth High Pass Filters (cont…) Results of Butterworth high pass filtering of order 2 with D0 = 15 Results of Butterworth high pass filtering of order 2 with D0 = 80 Results of Butterworth high pass filtering of order 2 with D0 = 30 Images taken from Gonzalez & Woods, Digital Image Processing (2002) Gaussian High Pass Filters The Gaussian high pass filter is given as: H (u, v) ๏ฝ 1 ๏ญ e ๏ญ D 2 ( u ,v ) / 2 D0 2 where D0 is the cut off distance as before Images taken from Gonzalez & Woods, Digital Image Processing (2002) Gaussian High Pass Filters (cont…) Results of Gaussian high pass filtering with D0 = 80 Results of Gaussian high pass filtering with D0 = 15 Results of Gaussian high pass filtering with D0 = 30 Images taken from Gonzalez & Woods, Digital Image Processing (2002) Highpass Filter Comparison Results of ideal high pass filtering with D0 = 15 Results of Butterworth high pass filtering of order 2 with D0 = 15 Results of Gaussian high pass filtering with D0 = 15 Original image Highpass filtering result After histogram equalisation High frequency emphasis result Images taken from Gonzalez & Woods, Digital Image Processing (2002) Highpass Filtering Example Images taken from Gonzalez & Woods, Digital Image Processing (2002) Band Reject Filters The ideal band reject filter is shown below, along with Butterworth and Gaussian versions of the filter Ideal Band Reject Filter Butterworth Band Reject Filter Gaussian Band Reject Filter Images taken from Gonzalez & Woods, Digital Image Processing (2002) Band Reject Filter Example Image corrupted by sinusoidal noise Fourier spectrum of corrupted image Butterworth band reject filter Filtered image Magnitude and Phase of DFT • What is more important? magnitude phase • Hint: use inverse DFT to reconstruct the image using magnitude or phase only information Magnitude and Phase of DFT (cont’d) Reconstructed image using magnitude only (i.e., magnitude determines the contribution of each component!) Reconstructed image using phase only (i.e., phase determines which components are present!) Another example: amplitude vs. phase Thank You