1 computational vision csci 363, fall 2012 lecture 6 edge detection
Post on 19-Jan-2016
213 Views
Preview:
TRANSCRIPT
1
Computational Vision
CSCI 363, Fall 2012Lecture 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 rapidintensity 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
ImageImage 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.
€
G(x) =1
σ
⎛ ⎝ ⎜
⎞ ⎠ ⎟e
−x2
2σ 2
⎛
⎝ ⎜ ⎜
⎞
⎠ ⎟ ⎟
Convolution of I with G is written: G(x) * I(x)
€
y(x)= I(τ )G(x − τ )dτ−∞
∞
∫For continuous functions:
8
The Derivative of a Convolution
€
d
dxG(x) * I(x)( ) =
d
dxG(x)
⎛ ⎝ ⎜
⎞ ⎠ ⎟* I(x)
€
d
dx
d
dxG(x) * I(x)
⎛ ⎝ ⎜
⎞ ⎠ ⎟=d 2
dx 2G(x)
⎛
⎝ ⎜
⎞
⎠ ⎟* I(x)
Gaussian and its derivativesInstead of taking the derivative of a convolution of the image and the Gaussian, we can convolve image with the derivative of the Gaussian
9
2nd 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:
€
G(x,y) =1
2πσ
⎛ ⎝ ⎜
⎞ ⎠ ⎟e
−(x2 +y2 )
2σ 2
⎛
⎝ ⎜ ⎜
⎞
⎠ ⎟ ⎟
To differentiate, we use the Laplacian operator:
€
∇2 =∂ 2 I
∂x 2+∂ 2 I
∂y2
⎛
⎝ ⎜
⎞
⎠ ⎟
€
∇2G(x,y) looks like a center surround receptive field.
€
∇2G(x,y) 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:
14 7 25 9 276 5 18
15 9 2 7 25
2D Image1D Image
We use an approximation of convolution to perform the smoothing and differentiation.
13
Smoothing a 1D array
Image: 1 3 6 4 5 2 3 6 6 3 1 1
Operator: 1 3 5 3 1
Position 1: 1x1 + 3x3 + 6x5 + 4x3 + 5x1 = 57
Image: 1 3 6 4 5 2 3 6 6 3 1 1
Operator: 1 3 5 3 1
Position 2: 3x1 + 6x3 + 4x5 + 5x3 + 2x1 = 58
Position: 1 2 3 4 5 6 7 8Value: 57 58 52 44 50 62 81 43
14
Other Operators
Averaging: 1/5 1/5 1/5 1/5 1/5
Differentiation: 1 -1
Second Derivative: 1 -2 1
2D Convolution:
0 0 0 00 2 3 20 1 2 10 0 0 0
0 0 0 00 2 5 50 3 8 80 1 3 3
1 11 1
* =
15
Matlab MatricesEntering a Matrix:>> A = [1 2 3; 4 5 6; 7 8 9]A =
1 2 34 5 67 8 9
User types
Matlab replies
>> Image = zeros(4, 5)Image =
0 0 0 0 00 0 0 0 00 0 0 0 00 0 0 0 0
All zeros
>> B = ones(3, 4)B =
1 1 1 11 1 1 11 1 1 1
All ones
>> C = 5*ones(2, 3)C =
5 5 55 5 5
All fives
16
Accessing Array Values
A = 1 23 4
A(1, 1) = ?A(2, 1) = ?etc.
Use a colon to specify a range of values. 4:7 indicates 4 5 6 and 7.A colon by itself indicates an entire row or column.
B = 1 2 34 5 67 8 9
B(2:3, 1:2) = ? B(1:2, :) = ?
>> A = zeros(3, 3)>> B = [5 6; 7 8]>> A(1:2, 2:3) = B
A = ?
13
4 57 8
1 2 34 5 6
0 5 60 7 80 0 0
17
Control FlowConditional Example:if (A(1, 1) < 5)
A(1, 1) = A(1, 1) + 1end
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 OperationsAddition and Subtraction are pairwise by element:
1 23 4
5 67 8
6 810 12+ = ?
Matrix Multiplication (*)
1 2 3456
* = ? 32
Pairwise multiplication (.*)
1 23 4
5 67 8
5 1221 32.* = ?
Matrix Division (/)(Multiply first matrix by inverse of second)
Pairwise Division ( ./)
1 23 4
5 55 5
.2 .4
.6 .8./ = ?
top related