Basic Properties of signal, Fourier Expansion and it’s Applications in Digital Image processing. Md. Al Mehedi Hasan Assistant Professor Dept. of Computer Science & Engineering RUET, Rajshahi-6204. E-mail: mehedi_ru@yahoo.com Signals • Signal is defined by its Amplitude, Frequency and Phase • Signals can be analog or digital. • Analog signals can have an infinite number of values in a range. • Digital signals can number of values. have only a limited Comparison of analog and digital signals Periodic Signal Both analog and digital signals can be of two forms: Periodic and Aperiod. A signal is a periodic if it completes a pattern within a measurable time frame, called a period, and repeats that pattern over identical subsequent period. Periodic signals (continue) Periodic signals can be classified as simple or composite. simple composite Aperiodic Signal An aperiodic, or nonperiodic, signal has no patterns. Amplitude The Amplitude of a signal is the value of the signal at any point on the wave. Period and Frequency Period refers to the amount of time, a signal needs to complete one cycle. Frequency refers to the number of periods in one second. Frequency and period are the inverse of each other. Units of period and frequency 3.10 Phase The term phase describes the position of the waveform relative to time zero. Two signals with the same phase and frequency, but different amplitudes Two signals with the same amplitude and phase, but different frequencies 3.13 Three sine waves with the same amplitude and frequency, but different phases 3.14 Example The power we use at home has a frequency of 60 Hz. The period of this sine wave can be determined as follows: 3.15 Example The period of a signal is 100 ms. What is its frequency in kilohertz? Solution First we change 100 ms to seconds, and then we calculate the frequency from the period (1 Hz = 10−3 kHz). 3.16 Note If a signal does not change at all, its frequency is zero. If a signal changes instantaneously, its frequency is infinite. 3.17 Example A sine wave is offset 1/6 cycle with respect to time 0. What is its phase in degrees and radians? Solution We know that 1 complete cycle is 360°. Therefore, 1/6 cycle is 3.18 Sine and Cosine Functions • Periodic functions • General form of sine and cosine functions: Sine and Cosine Functions Special case: A=1, b=0, α=1 π Sine and Cosine Functions (cont’d) • Shifting or translating the sine function by a const b Cosine is a shifted sine function: Sine and Cosine Functions (cont’d) • Changing the amplitude A 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: sin(αt)=sin(2πt/T)=sin(2πft) Definition of Radian One radian is the measure of a central angle that intercepts an arc equal in length to the radius of the circle. See Figure. Algebraically, this means that where θ is measured in radians. Why Radian Measure? In most applications of trigonometry, angles are measured in degrees. In more advances work in mathematics, radian measure of angles is preferred. Radian measure allows us to treat the trigonometric functions as functions with domains of real numbers, rather than angles. Linear speed measures how fast the particle moves, and angular speed measures how fast the angle changes. Frequency and Angular Frequency Frequency is a metric for expressing the rate of oscillation in a wave. For planar and longitudinal waves, this often expressed in oscillations-per-second or Hz. Angular frequency used for expressing rates of rotation, similar to revolutions-per-second, and is usually expressed in radians-per-second. It can be thought of as a wave with a constant amplitude where the amplitude rotates in a circle in space. 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 of Sine and Cosine Functions (continue) 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.36 The time domain and frequency domain of three sine waves 3.37 Frequency Spectrum and Bandwidth The frequency spectrum of a signal is the combination of all sine wave signals that make up that signal. The bandwidth of a signal is the width of the frequency spectrum. 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 Fourier analysis • A single-frequency sine wave is not useful in some situation • We need to use a composite signal, a signal made of many simple sine waves. • According to Fourier analysis, any composite signal is a combination of simple sine waves with different frequencies, amplitudes, and phases. 3.41 Composite Signals and Periodicity • If the composite signal is periodic, the decomposition gives a series of signals with discrete frequencies. • If the composite signal is nonperiodic, the decomposition gives a combination of sine waves with continuous frequencies. 3.42 Fourier Series of composite periodic signal • Every composite periodic signal can be represented with a series of sine and cosine functions. • The functions are integral harmonics of the fundamental frequency “f” of the composite signal. • Using the series we can decompose any periodic signal into its harmonics. A composite periodic signal 3.44 Decomposition of a composite periodic signal in the time and frequency domains 3.45 Nonperiodic signal The time and frequency domains of a nonperiodic signal Fourier Series Fourier Series Where Meaning of Coefficients An equation with many faces There are several different ways to write the Fourier series. Examples of Signals and the Fourier Series Representation Sawtooth Signal Application 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). Spatial Frequency in image (con..) Spatial Frequency in image (con..) 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. Spatial Frequency in image (con..) 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. Spatial Frequency in image (con..) 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). Spatial Frequency in image (con..) If you wonder, you can assign different k values (e.g. f(x,y)=cos(x)cos(3y) ) for the base cosine functions, and plot the result. Our goal is to create an image containing a single frequency component as much as possible. Let us pick a cosine signal with a low frequency: cos(t) . 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. Spatial Frequency in image (con..) Here are images for different k values. Values of k represents the level of frequency (from low to high) for k=0,….,20. Spatial Frequency in image (con..) Spatial Frequency in image (con..) Similar to the 1D case, we can say that if the intensity values in an image changes dramatically, that image has high frequency components. Frequency Domain 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 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) Images taken from Gonzalez & Woods, Digital Image Processing (2002) The DFT and Image Processing 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? 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 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 Thank You