1 / 65

Frequency Filtering

Frequency Filtering. Instructor: Juyong Zhang juyong@ustc.edu.cn http://staff.ustc.edu.cn/~juyong. Convolution Property of the Fourier Transform. * = convolution · = multiplication.

bella
Download Presentation

Frequency Filtering

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Frequency Filtering Instructor: Juyong Zhang juyong@ustc.edu.cn http://staff.ustc.edu.cn/~juyong

  2. Convolution Property of the Fourier Transform * = convolution · = multiplication The Fourier Transform of a convolution equals the product of the Fourier Transforms. Similarly, the Fourier Transform of a convolution is the product of the Fourier Transforms

  3. Convolution via Fourier Transform Image & Mask Transforms Pixel-wise Product Inverse Transform

  4. How to Convolve via FT in Matlab • Read the image from a file into a variable, say I. • Read in or create the convolution mask, h. • Compute the sum of the mask: s = sum(h(:)); • If s == 0, set s = 1; • Replace h with h = h/s; • Create: H = zeros(size(I)); • Copy h into the middle of H. • Shift Hinto position: H = ifftshift(H); • Take the 2D FT of I and H:FI=fft2(I); FH=fft2(H); • Pointwise multiply the FTs: FJ=FI.*FH; • Compute the inverse FT: J = real(ifft2(FJ)); The mask is usually 1-band For color images you may need to do each step for each band separately.

  5. Even Odd Even Odd Image Origin Image Origin Weight Matrix Origin Weight Matrix Origin After FFT shift After FFT shift After IFFT shift After IFFT shift Coordinate Origin of the FFT Center = (floor(R/2)+1, floor(C/2)+1)

  6. J = fftshift(I): I(1,1)  J ( R/2 +1, C/2 +1) I = ifftshift(J): J( R/2 +1, C/2 +1) I(1,1) Matlab’s fftshift and ifftshift where x = floor(x) = the largest integer smaller than x.

  7. Blurring: Averaging / Lowpass Filtering Blurring results from: • Pixel averaging in the spatial domain: • Each pixel in the output is a weighted average of its neighbors. • Is a convolution whose weight matrix sums to 1. • Lowpass filtering in the frequency domain: • High frequencies are diminished or eliminated • Individual frequency components are multiplied by a nonincreasing function of  such as 1/ = 1/(u2+v2). The values of the output image are all non-negative.

  8. Sharpening: Differencing / Highpass Filtering Sharpening results from adding to the image, a copy of itself that has been: • Pixel-differenced in the spatial domain: • Each pixel in the output is a difference between itself and a weighted average of its neighbors. • Is a convolution whose weight matrix sums to 0. • Highpass filtered in the frequency domain: • High frequencies are enhanced or amplified. • Individual frequency components are multiplied by an increasing function of  such as  = (u2+v2), where  is a constant. The values of the output image positive & negative.

  9. Recall: Convolution Property of the Fourier Transform * = convolution · = multiplication The Fourier Transform of a convolution equals the product of the Fourier Transforms. Similarly, the Fourier Transform of a convolution is the product of the Fourier Transforms

  10. Ideal Lowpass Filter

  11. Ideal Lowpass Filter Image size: 512x512 FD filter radius: 16 Multiply by this, or … … convolve by this Fourier Domain Rep. Spatial Representation Central Profile

  12. Ideal Lowpass Filter Image size: 512x512 FD filter radius: 8 Multiply by this, or … … convolve by this Fourier Domain Rep. Spatial Representation Central Profile

  13. Consider the image below: Power Spectrum and Phase of an Image Original Image Power Spectrum Phase

  14. Ideal Lowpass Filter Image size: 512x512 FD filter radius: 16 Ideal LPF in FD Original Image Power Spectrum

  15. Ideal Lowpass Filter Image size: 512x512 FD filter radius: 16 Original Image Filtered Power Spectrum Filtered Image

  16. Ideal Highpass Filter

  17. Ideal Highpass Filter Image size: 512x512 FD notch radius: 16 Multiply by this, or … … convolve by this Fourier Domain Rep. Spatial Representation Central Profile

  18. Ideal Highpass Filter Image size: 512x512 FD notch radius: 16 Power Spectrum Original Image Ideal HPF in FD

  19. *signed image: 0 mapped to 128 Ideal Highpass Filter Image size: 512x512 FD notch radius: 16 Original Image Filtered Power Spectrum Filtered Image*

  20. *signed image: 0 mapped to 128 Ideal Highpass Filter Image size: 512x512 FD notch radius: 16 Positive Pixels Filtered Image* Negative Pixels

  21. Ideal Bandpass Filter

  22. Ideal Bandpass Filter • A bandpass filter is created by • subtracting a FD radius 2 lowpass filtered image from a FD radius 1 lowpass filtered image, where 2< 1, or • convolving the image with a mask that is the difference of the two lowpass masks. - = FD LP mask with radius 1 FD LP mask with radius 2 FD BP mask 1 -2

  23. *signed image: 0 mapped to 128 Ideal Bandpass Filter image LPF radius 1 image LPF radius 2 image BPF radii 1, 2*

  24. *signed image: 0 mapped to 128 Ideal Bandpass Filter original image* filter power spectrum filtered image

  25. *signed image: 0 mapped to 128 A Different Ideal Bandpass Filter original image filter power spectrum filtered image*

  26. The Optimal Filter

  27. The Uncertainty Relation space frequency FT space frequency FT A small object in space has a large frequency extent and vice-versa.

  28. The Uncertainty Relation frequency space Recall: a symmetric pair of impulses in the frequency domain becomes a sinusoid in the spatial domain. IFT  small extent   large extent   small extent   large extent  frequency space A symmetric pair of lines in the frequency domain becomes a sinusoidal line in the spatial domain. IFT  small extent   large extent   small extent   large extent 

  29. Ideal Filters Do Not Produce Ideal Results IFT A sharp cutoff in the frequency domain… …causes ringing in the spatial domain.

  30. Ideal Filters Do Not Produce Ideal Results Ideal LPF Blurring the image above with an ideal lowpass filter… …distorts the results with ringing or ghosting.

  31. Optimal Filter: The Gaussian IFT The Gaussian filter optimizes the uncertainty relation. It provides the sharpest cutoff with the least ringing.

  32. One-Dimensional Gaussian

  33. R = 512, C = 512 c r  = 257, s= 64 Two-Dimensional Gaussian If  and  are different for r & c… …or if  and  are the same for r & c.

  34. Optimal Filter: The Gaussian Gaussian LPF With a gaussian lowpass filter, the image above … … is blurred without ringing or ghosting.

  35. Compare with an “Ideal” LPF Ideal LPF Blurring the image above with an ideal lowpass filter… …distorts the results with ringing or ghosting.

  36. Gaussian Lowpass Filter

  37. Gaussian Lowpass Filter Image size: 512x512 SD filter sigma = 8 Multiply by this, or … … convolve by this Fourier Domain Rep. Spatial Representation Central Profile

  38. Gaussian Lowpass Filter Image size: 512x512 SD filter sigma = 2 Multiply by this, or … … convolve by this Fourier Domain Rep. Spatial Representation Central Profile

  39. Gaussian Lowpass Filter Image size: 512x512 SD filter sigma = 8 Power Spectrum Original Image Gaussian LPF in FD

  40. Gaussian Lowpass Filter Image size: 512x512 SD filter sigma = 8 Original Image Filtered Power Spectrum Filtered Image

  41. Gaussian Highpass Filter

  42. Gaussian Highpass Filter Image size: 512x512 FD notch sigma = 8 Multiply by this, or … … convolve by this Fourier Domain Rep. Spatial Representation Central Profile

  43. Gaussian Highpass Filter Image size: 512x512 FD notch sigma = 8 Power Spectrum Original Image Gaussian HPF in FD

  44. *signed image: 0 mapped to 128 Gaussian Highpass Filter Image size: 512x512 FD notch sigma = 8 Original Image Filtered Power Spectrum Filtered Image*

  45. *signed image: 0 mapped to 128 Gaussian Highpass Filter Image size: 512x512 FD notch sigma = 8 Negative Pixels Positive Pixels Filtered Image*

  46. *signed image: 0 mapped to 128 Another Gaussian Highpass Filter original image filter power spectrum filtered image*

  47. Gaussian Bandpass Filter

  48. Gaussian Bandpass Filter • A bandpass filter is created by • subtracting a FD radius 2 lowpass filtered image from a FD radius 1 lowpass filtered image, where 2< 1, or • convolving the image with a mask that is the difference of the two lowpass masks. - = FD LP mask with radius 1 FD LP mask with radius 2 FD BP mask 1 -2

  49. *signed image: 0 mapped to 128 Ideal Bandpass Filter original image filter power spectrum filtered image*

  50. *signed image: 0 mapped to 128 Gaussian Bandpass Filter image LPF radius 1 image LPF radius 2 image BPF radii 1, 2*

More Related