1 Computational Vision CSCI 363, Fall 2012 Lecture 6 Edge Detection
2 Stages for Edge Detection Detecting Edges: Smoothing--Eliminates noise. Determines spatial scale. Differentiation--Localizes the intensity change Feature Extraction: Determine the feature that caused the intensity change.
3 Smoothing
4 Localization of an edge Changes in intensity are not instantaneous, particularly in a smoothed image. Humans can localize edges to within a few seconds of arc (a few mm for a line a distance of 1 meter from the observer). Accurate localization is necessary for stereo vision. Differentiation allows us to find the location of the most rapid intensity change. The first derivative gives a peak at the location of the most rapid change. The second derivative gives a zero at this location. Marr and Hildreth suggested using these zero crossings to indicate edges.
5 Intensity Derivative
6 Zero Crossings and Edges Image Image after smoothing and second derivative Black = Negative White = Positive Zero Crossings
7 Convolution To smooth a function, we replace the value at each x position with the averaged values around that position. This process is called convolution. Smoothing works best if the average is weighted: nearby neighbors count more, distant neighbors count less. A Gaussian function works well for this weighting. Convolution of I with G is written: G(x) * I(x) For continuous functions:
8 The Derivative of a Convolution Gaussian and its derivatives Instead of taking the derivative of a convolution of the image and the Gaussian, we can convolve image with the derivative of the Gaussian
9 2 nd Derivative of Gaussian Looks Like... Retinal Ganglion cells and bipolar cells have receptive fields that exhibit a center-surround structure.
10 A 2D Gaussian For a 2D image, I(x, y), we convolve with a 2D Gaussian: To differentiate, we use the Laplacian operator: looks like a center surround receptive field. can be approximated by G( 1, x, y) - G( 2, x, y) (A "Difference of Gaussians" or DOG)
11 Difference of Gaussians Note: A single retinal ganglion cell cannot distinguish between a zero crossing and uniform intensity. To find edges, one must evaluate the difference in responses of neighboring cells.
12 Detecting Edges with Discrete Samples Normally, images will be a group of discrete values: D Image 1D Image We use an approximation of convolution to perform the smoothing and differentiation.
13 Smoothing a 1D array Image: Operator: Position 1: 1x1 + 3x3 + 6x5 + 4x3 + 5x1 = 57 Image: Operator: Position 2: 3x1 + 6x3 + 4x5 + 5x3 + 2x1 = 58 Position: Value:
14 Other Operators Averaging: 1/5 1/5 1/5 1/5 1/5 Differentiation: 1 -1 Second Derivative: D Convolution: * =
15 Matlab Matrices Entering a Matrix: >> A = [1 2 3; 4 5 6; 7 8 9] A = User types Matlab replies >> Image = zeros(4, 5) Image = All zeros >> B = ones(3, 4) B = 1 1 All ones >> C = 5*ones(2, 3) C = All fives
16 Accessing Array Values A = A(1, 1) = ? A(2, 1) = ? etc. Use a colon to specify a range of values. 4:7 indicates and 7. A colon by itself indicates an entire row or column. B = B(2:3, 1:2) = ? B(1:2, :) = ? >> A = zeros(3, 3) >> B = [5 6; 7 8] >> A(1:2, 2:3) = B A = ?
17 Control Flow Conditional Example: if (A(1, 1) < 5) A(1, 1) = A(1, 1) + 1 end For loop example: for i = 1:5 A(i, 1) = 2*i; end Stepping by 2: for i = 2:2:10 A(i, 2) = 3; end Relational operators: == & | ~=
18 Matrix Operations Addition and Subtraction are pairwise by element: = ? Matrix Multiplication (*) * = ?32 Pairwise multiplication (.*) *= ? Matrix Division (/) (Multiply first matrix by inverse of second) Pairwise Division (./) /= ?