Some “facts” about software…

Download Report

Transcript Some “facts” about software…

Edges and Contours– Chapter 7
continued
Edge detection
• All of the previously studied edge
detection filters worked on finding local
gradients (1st derivative)
• As such, all had to make decisions
regarding the actual existence of an
edge based on local information
Sobel edges – threshold on magnitude
Sobel edges – threshold on
magnitude
• The preceding images were edge-detected
with a Sobel operator then binarized with
various thresholds
• The overall trend is predictable but the
individual results are not
• This threshold dependency is the curse of
image processing
– Difficult to isolate “real” edges
– Difficult to find accurate edge location
• We need smarter algorithms
Scale space processing
• One method of dealing with the
threshold dependency is through scalespace processing
– An image is processed at various scales
(sizes/resolution) revealing different sets of
features at each scale
– Features common to all [or many] sets are
deemed “important”
The Gaussian Pyramid
• Select a set of Gaussian filter
parameters (sigma and width) and blur
the image
• Save the image
• Reduce it’s size by subsampling
(eliminating every other row/column)
• Do it again
The Gaussian Pyramid
• You end up with a series of images (a
pyramid) each exposing different
features
– Coarse features at the top of the pyramid
– Fine features at the bottom
• You can now use the coarse features to
select where to concentrate your
processing of the fine features
Better (different) algorithms
• Another method of dealing with the
threshold dependency is through more
complex algorithms
A better kernel
• The Sobel mask is a derivative mask
(computes the weighted difference of
neighborhood pixels)
• So is the Laplacian (negative in the
middle, positive around the rest)
• From calculus: the 2nd derivative of a
signal is zero when the derivative
magnitude is extremal
A better kernel
• Combining these observations we can
derive the Laplacian-Gaussian filter due
to Marr and Hildreth
– Also known as a DoG (Difference of
Gaussians) because it can be
approximated by subtracting two Gaussian
kernels of same width and differing sigmas
The Gaussian kernel
2
G x, y   2
1

y
x

2
2

2e
2
 width 2   x, y   width 2 
7.00E-02
6.00E-02
5.00E-02
4.00E-02
3.00E-02
2.00E-02
1.00E-02
• Sigma 1.6, Filter Width 15
0.00E+00
1
3
5
7
9
11
13
15
The Laplacian-Gaussian kernel
• Bypassing the math and jumping to the
results of applying the rules of calculus…


2
y 


x
 1  

y 
x
2

  1

2

2  e
  4  
2 
   

• Similar in form to the Gaussian kernel
2
2
2
The Laplacian-Gaussian kernel
• In 1 dimension…
Convolution Filter (1 Line)
1.2
1
0.8
0.6
0.4
0.2
0
0
2
4
6
8
10
12
14
16
-0.2
• Can be approximated by difference of
two Gaussians
The Laplacian-Gaussian kernel
• Convolution with this kernel results in
edge magnitudes of both positive and
negative values
• We’re interested in where the sign
changes occur (the zero crossing)
• These are where the edges are (recall
the calculus result)
Sobel vs. Laplacian-Gaussian
• L-G does not detect as much “noise” as Sobel
– why not?
Still something missing…
• What are we ignoring in the following
edge detection processes?
1. Gaussian filter
2. Sobel edge detection
3. Threshold based binarization of Sobel
magnitude
And
1. Laplacian-Gaussian filter
2. Zero crossing detection
We need a smarter algorithm
• We merely selected each edge based on its
magnitude and zero-crossing
• We completely ignored its immediate surroundings
• Why is this bad?
– Detects edges we don’t want
• Prone to noise
• Prone to clutter
– Doesn’t detect edges we do want
• Weak magnitude edges are thresholded (thresheld?)
away
• We need a smarter algorithm!
The Canny edge detector
• John Canny – MIT 1986
• Developed a process (series of steps)
for identifying edges in an image
– Gaussian smoothing of input image
– Local derivative operator to detect edge
candidates
– Removal of edges that are clustered
around a single location
– Adaptive thresholding algorithm for final
edge selection
Concepts
• Gaussian smooth original image
– Reduce the effects of noise
• Local derivative operator
– Simple neighbor pixel subtraction to detect gradients (1st
derivative)
• Non-maximal suppression
– Thin out the edges around a given point
• Threshold
– Use two thresholds combined with spatial continuity
Spatial continuity
• aka contour following
– Apply the high threshold to get “obvious”
edges
– Search for a neighboring edge above the low
threshold in the direction of the strong edge
• We’re using a strong edge as an anchor point for a
contour of weak and strong edges – known as
Hysteresis
Canny results
• With very conservative high/low thresholds
Results
All edges
Strong edges
Weak edges
Contours
Summary
• Through more complex processing we
arrive at a set of edges in which we
have confidence
– Minimal reliance on thresholds
• The cost is complex (slow, memory
intensive) processing
• We must trade resources for accuracy!
ImageJ
• Download/install plugins for
– Sobel, Prewitt, Roberts, Kirsch, NevatiaBabu
• Plugins->FeatureJ->Edges
– Canny implementation
Edge Sharpening
• An process for making an image look
“better”
– In this case “better” means “sharper”
• The general approach is to amplify the
high-frequency components (the edges)
to create a “perceived” sharpness
Method 1 – subtract 2nd derivative
I






u
,
v

I
u
,
v

w

I
'
'
u
,
v
sharp
• This causes a step edge to undershoot
at the bottom and overshoot at the top
• The Laplacian works well for the 2nd
derivative
0 1 0 
1  4 1 


0 1 0 
ImageJ
• Note that this is difficult to do in ImageJ
since the convolution operation clamps
negative pixel values to 0
Unsharp mask
• Steps
– Subtract a Gaussian-smoothed version of
the image from the original creating a mask
– Add a weighted version of the mask to the
original image
ImageJ
• Plugins->Chapter07->Filter UnsharpMask