Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mestrado em Ciência de Computadores Mestrado Integrado em Engenharia de Redes e Sistemas Informáticos VC 15/16 – TP7 Spatial Filters Miguel Tavares Coimbra.

Similar presentations


Presentation on theme: "Mestrado em Ciência de Computadores Mestrado Integrado em Engenharia de Redes e Sistemas Informáticos VC 15/16 – TP7 Spatial Filters Miguel Tavares Coimbra."— Presentation transcript:

1 Mestrado em Ciência de Computadores Mestrado Integrado em Engenharia de Redes e Sistemas Informáticos VC 15/16 – TP7 Spatial Filters Miguel Tavares Coimbra

2 VC 15/16 - TP7 - Spatial Filters Outline Spatial filters Frequency domain filtering Edge detection Acknowledgements: Most of this course is based on the excellent courses offered by Prof. Shree Nayar at Columbia University, USA and by Prof. Srinivasa Narasimhan at CMU, USA. Please acknowledge the original source when reusing these slides for academic purposes.

3 VC 15/16 - TP7 - Spatial Filters Topic: Spatial filters Spatial filters Frequency domain filtering Edge detection

4 VC 15/16 - TP7 - Spatial Filters Images are Discrete and Finite Convolution Fourier Transform Inverse Fourier Transform

5 VC 15/16 - TP7 - Spatial Filters Spatial Mask Simple way to process an image. Mask defines the processing function. Corresponds to a multiplication in frequency domain. Convolution – Mask ‘slides’ over the image Mask Image

6 VC 15/16 - TP7 - Spatial Filters Example Each mask position has weight w. The result of the operation for each pixel is given by: 121 000 -2 222 444 456 Mask Image =1*2+2*2+1*2+… =8+0-20 =-12

7 VC 15/16 - TP7 - Spatial Filters Definitions Spatial filters –Use a mask (kernel) over an image region. –Work directly with pixels. –As opposed to: Frequency filters. Advantages –Simple implementation: convolution with the kernel function. –Different masks offer a large variety of functionalities.

8 VC 15/16 - TP7 - Spatial Filters Averaging Let’s think about averaging pixel values For n=2, convolve pixel values with 121 2D images: 121 (a) use then 1 2 1 121 or (b) use 1 2 1 1 2 1 1 2 1 2 4 2 Which is faster?

9 VC 15/16 - TP7 - Spatial Filters The convolution kernel large Repeated averaging Gaussian smoothing Averaging

10 VC 15/16 - TP7 - Spatial Filters Gaussian Smoothing Gaussian kernel pixels Filter size…can be very large (truncate, if necessary) 2D Gaussian is separable! Use two 1D Gaussian Filters!

11 VC 15/16 - TP7 - Spatial Filters A Gaussian kernel gives less weight to pixels further from the center of the window This kernel is an approximation of a Gaussian function: Gaussian Smoothing 121 242 121

12 VC 15/16 - TP7 - Spatial Filters original

13 VC 15/16 - TP7 - Spatial Filters Mean Filtering We are degrading the energy of the high spatial frequencies of an image (low-pass filtering). –Makes the image ‘smoother’. –Used in noise reduction. Can be implemented with spatial masks or in the frequency domain. 1/9

14 VC 15/16 - TP7 - Spatial Filters Mean filterGaussian filter

15 VC 15/16 - TP7 - Spatial Filters http://www.michaelbach.de/ot/cog_blureffects/index.html

16 VC 15/16 - TP7 - Spatial Filters http://www.michaelbach.de/ot/cog_blureffects/index.html

17 VC 15/16 - TP7 - Spatial Filters Median Filter Smoothing is averaging (a) Blurs edges (b) Sensitive to outliers (a) (b) –Sort values around the pixel –Select middle value (median) –Non-linear (Cannot be implemented with convolution) Median filtering sortmedian

18 VC 15/16 - TP7 - Spatial Filters 3x3 5x5 7x7 Salt and pepper noise Gaussian noise

19 VC 15/16 - TP7 - Spatial Filters Border Problem What a computer sees 121 242 121 How do we apply our mask to this pixel?

20 VC 15/16 - TP7 - Spatial Filters Border Problem Ignore –Output image will be smaller than original Pad with constant values –Can introduce substantial 1 st order derivative values Pad with reflection –Can introduce substantial 2 nd order derivative values

21 VC 15/16 - TP7 - Spatial Filters Topic: Frequency domain filtering Spatial filters Frequency domain filtering Edge detection

22 VC 15/16 - TP7 - Spatial Filters Image Processing in the Fourier Domain Does not look anything like what we have seen Magnitude of the FT

23 VC 15/16 - TP7 - Spatial Filters Convolution in the Frequency Domain f(x,y)f(x,y) h(x,y)h(x,y) g(x,y)g(x,y) |F(s x,s y )| |H(s x,s y )| |G(s x,s y )|

24 VC 15/16 - TP7 - Spatial Filters Lets the low frequencies pass and eliminates the high frequencies. Generates image with overall shading, but not much detail Low-pass Filtering

25 VC 15/16 - TP7 - Spatial Filters Lets through the high frequencies (the detail), but eliminates the low frequencies (the overall shape). It acts like an edge enhancer. High-pass Filtering

26 VC 15/16 - TP7 - Spatial Filters Boosting High Frequencies

27 VC 15/16 - TP7 - Spatial Filters

28

29 The Ringing Effect http://homepages.inf.ed.ac.uk/rbf/HIPR2/freqfilt.htm An ideal low-pass filter causes ‘rings’ in the spatial domain!

30 VC 15/16 - TP7 - Spatial Filters Topic: Edge detection Spatial filters Frequency domain filtering Edge detection

31 VC 15/16 - TP7 - Spatial Filters Edge Detection Convert a 2D image into a set of curves –Extracts salient features of the scene –More compact than pixels

32 VC 15/16 - TP7 - Spatial Filters Origin of Edges Edges are caused by a variety of factors depth discontinuity surface color discontinuity illumination discontinuity surface normal discontinuity

33 VC 15/16 - TP7 - Spatial Filters How can you tell that a pixel is on an edge?

34 VC 15/16 - TP7 - Spatial Filters Edge Types Step Edges Roof Edge Line Edges

35 VC 15/16 - TP7 - Spatial Filters Real Edges Noisy and Discrete! We want an Edge Operator that produces: –Edge Magnitude –Edge Orientation –High Detection Rate and Good Localization

36 VC 15/16 - TP7 - Spatial Filters Gradient Gradient equation: Represents direction of most rapid change in intensity Gradient direction: The edge strength is given by the gradient magnitude

37 VC 15/16 - TP7 - Spatial Filters Theory of Edge Detection Ideal edge Unit step function: Image intensity (brightness):

38 VC 15/16 - TP7 - Spatial Filters Partial derivatives (gradients): Squared gradient: Edge Magnitude: Edge Orientation: Rotationally symmetric, non-linear operator (normal of the edge) Theory of Edge Detection

39 VC 15/16 - TP7 - Spatial Filters Laplacian: Rotationally symmetric, linear operator zero-crossing Theory of Edge Detection

40 VC 15/16 - TP7 - Spatial Filters Discrete Edge Operators How can we differentiate a discrete image? Finite difference approximations: Convolution masks :

41 VC 15/16 - TP7 - Spatial Filters Second order partial derivatives: Laplacian : Convolution masks : or Discrete Edge Operators (more accurate)

42 VC 15/16 - TP7 - Spatial Filters The Sobel Operators Better approximations of the gradients exist –The Sobel operators below are commonly used 01 -202 01 121 000 -2

43 VC 15/16 - TP7 - Spatial Filters Comparing Edge Operators 01 -202 01 121 000 -21 Gradient: Roberts (2 x 2): Sobel (3 x 3): Sobel (5 x 5): -2021 -3032 -5053 -2-3032 -2021 12321 23532 00000 -3-5-3-2 -2-3-2 01 0 10 0 Good Localization Noise Sensitive Poor Detection Poor Localization Less Noise Sensitive Good Detection

44 VC 15/16 - TP7 - Spatial Filters Effects of Noise Consider a single row or column of the image –Plotting intensity as a function of position gives a signal Where is the edge??

45 VC 15/16 - TP7 - Spatial Filters Where is the edge? Solution: Smooth First Look for peaks in

46 VC 15/16 - TP7 - Spatial Filters Derivative Theorem of Convolution … saves us one operation.

47 VC 15/16 - TP7 - Spatial Filters Laplacian of Gaussian (LoG) Laplacian of Gaussian operator Where is the edge? Zero-crossings of bottom graph ! Laplacian of Gaussian

48 VC 15/16 - TP7 - Spatial Filters 2D Gaussian Edge Operators Laplacian of Gaussian Gaussian Derivative of Gaussian (DoG) Mexican Hat (Sombrero) is the Laplacian operator:

49 VC 15/16 - TP7 - Spatial Filters Canny Edge Operator Smooth image I with 2D Gaussian: Find local edge normal directions for each pixel Compute edge magnitudes Locate edges by finding zero-crossings along the edge normal directions (non-maximum suppression)

50 VC 15/16 - TP7 - Spatial Filters Non-maximum Suppression Check if pixel is local maximum along gradient direction –requires checking interpolated pixels p and r

51 VC 15/16 - TP7 - Spatial Filters original image

52 VC 15/16 - TP7 - Spatial Filters magnitude of the gradient

53 VC 15/16 - TP7 - Spatial Filters After non-maximum suppression

54 VC 15/16 - TP7 - Spatial Filters Canny Edge Operator Canny with original The choice of depends on desired behavior –large detects large scale edges –small detects fine features

55 VC 15/16 - TP7 - Spatial Filters Difference of Gaussians (DoG) Laplacian of Gaussian can be approximated by the difference between two different Gaussians

56 VC 15/16 - TP7 - Spatial Filters DoG Edge Detection (a)(b)(b)-(a)

57 VC 15/16 - TP7 - Spatial Filters Unsharp Masking – = = + a

58 VC 15/16 - TP7 - Spatial Filters Resources Gonzalez & Woods – Chapter 3


Download ppt "Mestrado em Ciência de Computadores Mestrado Integrado em Engenharia de Redes e Sistemas Informáticos VC 15/16 – TP7 Spatial Filters Miguel Tavares Coimbra."

Similar presentations


Ads by Google