S. Mandayam/ DIP/ECE Dept./Rowan University Digital Image Processing ECE /ECE Fall 2007 Shreekanth Mandayam ECE Department Rowan University Lecture 4 October 1, 2007
S. Mandayam/ DIP/ECE Dept./Rowan UniversityPlan Image Enhancement Spatial Filtering Detection of Discontinuities Edge detection (Sobel, Prewitt and Laplacian masks) Image Spectrum 2-D Fourier Transform (DFT & FFT) Spectral Filtering Lab 2: Spatial and Spectral Filtering
S. Mandayam/ DIP/ECE Dept./Rowan University DIP: Details
S. Mandayam/ DIP/ECE Dept./Rowan University Image Preprocessing Enhancement Restoration Spatial Domain Spectral Domain Point Processing >>imadjust >>histeq Spatial filtering >>filter2 Filtering >>fft2/ifft2 >>fftshift Inverse filtering Wiener filtering
S. Mandayam/ DIP/ECE Dept./Rowan University Spatial Filtering (Masking) R w1w1 w2w2 w3w3 w4w4 w5w5 w6w6 w7w7 w8w8 w9w9 z1z1 z2z2 z3z3 z4z4 z5z5 z6z6 z7z7 z8z8 z9z9 Portion of a digital image Mask = w 1 z 1 + w 2 z 2 + ….. +w 9 z 9 Replace with
S. Mandayam/ DIP/ECE Dept./Rowan University Low-pass Filters R z1z1 z2z2 z3z3 z4z4 z5z5 z6z6 z7z7 z8z8 z9z9 Moving Average Filter = median(z 1, z 2, ….., z 9 ) Replace with (1/9)* Median Filter
S. Mandayam/ DIP/ECE Dept./Rowan University Noise Models SNR g = 10 log 10 (P f /P n ) Power Variance (how?) SNR g = 10 log 10 ( f 2 / n 2 ) f(x,y) g(x,y) n(x,y) Degradation Model: g = f + n
S. Mandayam/ DIP/ECE Dept./Rowan University Noise Models N(0,1): zero-mean, unit-variance, Gaussian RV Theorem: N(0, 2 ) = N(0,1) Use this for generating normally distributed r.v.’s of any variance >>imnoise >>nrfiltdemo >>filter2 demos/demo2spatial_filtering/lowpassdemo.m
S. Mandayam/ DIP/ECE Dept./Rowan University High-pass Filters 8 z1z1 z2z2 z3z3 z4z4 z5z5 z6z6 z7z7 z8z8 z9z9 Basic HP Filter (1/9)* Gradient Filter demos/demo2spatial_filtering/highpassdemo.m
S. Mandayam/ DIP/ECE Dept./Rowan University Detection of Discontinuities Point Detection Line Detection (Prewitt’s Gradient) demos/demo2spatial _filtering/prewitt.m
S. Mandayam/ DIP/ECE Dept./Rowan University Edge Detection Sobel Masks >>edgedemo >>edge demos/demo2spatial_filtering/edgegradientdemo.m
S. Mandayam/ DIP/ECE Dept./Rowan University Image Preprocessing Enhancement Restoration Spatial Domain Spectral Domain Point Processing >>imadjust >>histeq Spatial filtering >>filter2 Filtering >>fft2/ifft2 >>fftshift Inverse filtering Wiener filtering
S. Mandayam/ DIP/ECE Dept./Rowan University Recall: 1-D CFT Continuous Fourier Transform (CFT) Frequency, [Hz] Amplitude Spectrum Phase Spectrum Inverse Fourier Transform (IFT)
S. Mandayam/ DIP/ECE Dept./Rowan University Recall: 1-D DFT Discrete Domains Discrete Time: k = 0, 1, 2, 3, …………, N-1 Discrete Frequency:n = 0, 1, 2, 3, …………, N-1 Discrete Fourier Transform Inverse DFT Equal time intervals Equal frequency intervals n = 0, 1, 2,….., N-1 k = 0, 1, 2,….., N-1
S. Mandayam/ DIP/ECE Dept./Rowan University How to get the frequency axis in the DFT The DFT operation just converts one set of number, x[k] into another set of numbers X[n] - there is no explicit definition of time or frequency How can we relate the DFT to the CFT and obtain spectral amplitudes for discrete frequencies? (N-point FFT) n= n=N f=0 f = f s Need to know f s
S. Mandayam/ DIP/ECE Dept./Rowan University DFT Properties DFT is periodic X[n] = X[n+N] = X[n+2N] = ……… I-DFT is also periodic! x[k] = x[k+N] = x[k+2N] = ………. Where are the “low” and “high” frequencies on the DFT spectrum? n=0 N/2 n=N f=0 f s /2 f = f s
S. Mandayam/ DIP/ECE Dept./Rowan University 1-D FFT Demo >>fft /ecomms/demos/dft.m
S. Mandayam/ DIP/ECE Dept./Rowan University 2-D Continuous Fourier Transform Spatial Domain Spatial Frequency Domain v u y x
S. Mandayam/ DIP/ECE Dept./Rowan University 2-D Discrete Fourier Transform >>fft2 >>ifft2 u=0 u=N/2 u=N v=N v=N/2 v=0
S. Mandayam/ DIP/ECE Dept./Rowan University 2-D DFT Properties Conjugate symmetry demos/demo3dft_properties/con_symm_and_trans.m Rotation demos/demo3dft_properties/rotation.m Separability demos/demo3dft_properties/separability.m >>fftshift
S. Mandayam/ DIP/ECE Dept./Rowan University Spectral Filtering: Radially Symmetric Filter Low-pass Filter demos/demo4freq_filtering/lowpass.m u=-N/2 u=0 u=N/2 v=N/2 v=0 v=-N/2 D0D0 D(u,v)
S. Mandayam/ DIP/ECE Dept./Rowan University Lab 2: Spatial & Spectral Filtering
S. Mandayam/ DIP/ECE Dept./Rowan UniversitySummary