SlideShare a Scribd company logo
1 of 71
Download to read offline
Computer Vision
SBE 404, Spring 2020
Professor
Ahmed M. Badawi
ambadawi@eng1.cu.edu.eg
http://scholar.google.com.eg/citations?user=r9pLu6EAAAAJ&hl=en
http://www.bmes.cufe.edu.eg
TA’s:
Eman Marzban
eman.marzban@eng1.cu.edu.eg
Asem Abdelaziz
asem.a.abdelaziz@eng1.cu.edu.eg
3/19/2020 2
Overview
1.Edge Detection
2.Edge Representation using Chain Codes
3.Line and Circle Detection using Hough
Transforms
4.Active contour deformable model
(Snakes)
3/19/2020 3
Edge Detection Goal: Could you point out the most “salient” or “strongest” edges or
the object boundaries? [Szeliski's Book p.210]
3/19/2020 4
-Qualitatively, edges occur at boundaries between regions of
different color, intensity, or texture.
-Define an edge as a location of rapid intensity variation.
-Think of an image as a height field. On such a surface, edges
occur at locations of steep slopes.
- A mathematical way to define the slope and direction of a
surface is through its gradient,
- The local gradient vector J points in the direction of steepest
ascent in the intensity function. Its magnitude is an indication of
the slope or strength of the variation, while its orientation
points in a direction perpendicular to the local contour.
How can we basically detect an edge?
3/19/2020 5
[Ch. 14, Practical Image and Video Processing Using MATLAB by Oge Marques]
3/19/2020 6
- Beware of the image noise! Smooth the image with a low-pass
filter prior to computing the gradient.
-The gradient of the smoothed image can therefore be written as
i.e., we can convolve the image with the horizontal and vertical
derivatives of the Gaussian kernel function,
Handling image noise in edge detection
3/19/2020 7
[Ch. 14,
Practical
Image
and Video
Processin
g Using
MATLAB
by Oge
Marques]
Even low noise levels can corrupt the edge detection operation…
3/19/2020 8
- For many applications, we wish to thin such a continuous
gradient image to only return isolated edges, i.e., as single pixels
at discrete locations along the edge contours.
-This can be achieved by looking for maxima in the edge strength
(gradient magnitude) in a direction perpendicular to the edge
orientation, i.e., along the gradient direction.
-Finding this maximum corresponds to taking a directional
derivative of the strength field in the direction of the gradient and
then looking for zero crossings.
- The desired directional derivative is equivalent to the dot
product between a second gradient operator and the results
of the first,
Thinning the gradient image
3/19/2020 9
-The gradient operator dot product with the gradient is called the
Laplacian. The convolution kernel
is therefore called the Laplacian of Gaussian (LoG) kernel. This
kernel can be split into two separable parts,
which allows for a much more efficient implementation
using separable filtering.
Thinning the gradient image (continued)
3/19/2020 10
[Ch. 14,
Practical
Image and
Video
Processing
Using
MATLAB by
Oge
Marques]
3/19/2020 11
- Estimate the gray-level gradient at a pixel, which can be approximated by the
digital equivalent of the first-order derivative as follows [Marques’ book, p.338]:
- The gradients are often computed within a 3×3 neighborhood using convolution:
where the Prewitt kernels are given by:
Example 1: Prewitt Edge Detector (First-order
Detector)
3/19/2020 12
[Ch. 14,
Practical
Image
and
Video
Processi
ng Using
MATLAB
by Oge
Marque
s]
3/19/2020 13
- The Laplacian operator is a straightforward digital
approximation of the second-order derivative of the intensity.
Although it has the potential for being employed as an isotropic
(i.e., omnidirectional) edge detector, it is rarely used in isolation
because of two limitations [Marques’ book, p. 343]:
• It generates “double edges,” that is, positive and negative
values for each edge.
• It is extremely sensitive to noise.
Example 2: Zero-crossing Edge Detector
(Second-order detector)
3/19/2020 14
[Ch. 14,
Practical
Image
and
Video
Processi
ng Using
MATLAB
by Oge
Marque
s]
3/19/2020 15
- The Laplacian of Gaussian (LoG) edge detector works by
smoothing the image with a Gaussian low-pass filter (LPF), and
then applying a Laplacian edge detector to the
result.
- David Marr and Ellen Hildreth proposed that LoG filtering
explains much of the low-level behavior of the human vision
system, since the response profile of an LoG filter approximates
the receptive field of retinal cells tuned to respond to edges.
Example 3: Laplacian-of-Gaussian Edge
Detector (Second-order detector)
3/19/2020 16
[Ch. 14,
Practical
Image
and
Video
Processi
ng Using
MATLAB
by Oge
Marque
s]
3/19/2020 17
[Ch. 14,
Practical
Image
and
Video
Processi
ng Using
MATLAB
by Oge
Marque
s]
3/19/2020 18
1. The input image is smoothed using a Gaussian low-pass filter, with a
specified value of σ: large values of σ will suppress much of the noise at
the expense of weakening potentially relevant edges.
2. The local gradient (intensity and direction) is computed for each point in
the smoothed image.
3. The edge points at the output of step 2 result in wide ridges. The
algorithm thins those ridges, leaving only the pixels at the top of each
ridge, in a process known as nonmaximal suppression.
4. The ridge pixels are then thresholded using two thresholds Tlow and Thigh:
ridge pixels with values greater than Thigh are considered strong edge
pixels; ridge pixels with values between Tlow and Thigh are said to be weak
pixels. This process is known as hysteresis thresholding.
5. The algorithm performs edge linking, aggregating weak pixels that are 8-
connected to the strong pixels.
Example 4: Canny Edge Detector
3/19/2020 19
Canny Edge Detection
http://www.cse.iitd.ernet.in/~pkalra/csl783/canny.pdf
3/19/2020 20
[Ch. 14,
Practical
Image
and
Video
Processi
ng Using
MATLAB
by Oge
Marque
s]
3/19/2020 21
Study and Comparison of
Various Image Edge Detection
Techniques
Raman Maini, Himanshu
Aggarwal
http://www.cscjournals.org/cs
c/download/issuearchive/IJIP/
volume3/IJIP_V3_I1.pdf
3/19/2020 22
Overview
1.Edge Detection
2.Edge Representation using Chain
Codes
3.Line and Circle Detection using Hough
Transforms
4.Active contour deformable model
(Snakes)
3/19/2020 23
Edge Representation using Chain Codes [Szeliski's Book p.217]
- Linked edgel lists can be encoded more compactly using a variety of alternative
representations.
A chain code encodes a list of connected points lying on an N-8 grid using a
three-bit code corresponding to the eight cardinal directions (N, NE, E, SE, S, SW, W, NW)
between a point and its successor (Figure 4.34).
-While this representation is more compact than the original edgel list (especially if
predictive variable-length coding is used), it is not very suitable for further processing.
-See: Introduction to Chain Codes
http://www.mind.ilstu.edu/curriculum/chain_codes_intro/chain_codes_intro.php
3/19/2020 24
Edge Representation using Chain Codes
- Chain code examples http://www.eng.iastate.edu/ee528/sonkamaterial/chapter_3.htm
http://www.cs.ru.nl/~ths/rt2/col/h9/9ge
biedENG.html
3/19/2020 25
Edge Representation using Arc-Length Parameterization [Szeliski's Book p.217]
- A more useful representation is the arc length parameterization of a contour, x(s), where
s denotes the arc length along a curve (Figure 4.35).
3/19/2020 26
Edge Representation using Arc-Length Parameterization [Szeliski's Book p.217]
- The advantage of the arc-length parameterization is that it makes matching and
processing (e.g., smoothing) operations much easier (Figure 4.36). Arc-length
parameterization can also be used to smooth curves in order to remove digitization noise.
3/19/2020 27
Overview
1.Edge Detection
2.Edge Representation using Chain Codes
3.Line and Circle Detection using Hough
Transforms
4.Active contour deformable model
(Snakes)
3/19/2020 28
Points and lines
in image and
parameter spaces
http://books.google.com.eg/books/abou
t/Digital_Image_Processing.html?id=jCEi
9MVfxD8C&redir_esc=y
[Chapter 9]
3/19/2020 29
3/19/2020 30
Line Detection using Hough Tranform [Szeliski's Book p.221]
Motivation: Lines in the real world are sometimes broken up into disconnected
components or made up of many collinear line segments. In many cases, it is desirable to
group such collinear segments into extended lines.
Original Formulation: Each edge point votes for all possible lines passing through it, and
lines corresponding to high accumulator or bin values are examined for potential line fits.
3/19/2020 31
Line Detection using Hough Tranform [Szeliski's Book p.222]
Alternate Formulation: Use the local orientation information at each edgel
to vote for a single accumulator cell.
3/19/2020 32
Line Detection using Hough Tranform [Szeliski's Book p.223]
3/19/2020 33
Hough Transform for Circles
3/19/2020 34
Hough Transform for General Parametric Curves
3/19/2020 35
Overview
1.Edge Detection
2.Edge Representation using Chain Codes
3.Line and Circle Detection using Hough
Transforms
4.Active contour model (Snakes)
3/19/2020 36
Image Segmentation using the Snake Active
Contour Model
3/19/2020 37
- The active contour model, or snake, is defined as an energy minimizing spline
- The snake's energy depends on its shape and location within the image.
- Local minima of this energy then correspond to desired image properties.
- Snakes may be understood as a special case of a more general technique of
matching a deformable model to an image by means of energy minimization.
- Snakes do not solve the entire problem of finding contours in images, but
rather, they depend on other mechanisms like interaction with a user,
interaction with some higher level image understanding process, or information
from image data adjacent in time or space.
- This interaction must specify an approximate shape and starting position for
the snake somewhere near the desired contour.
-A priori information is then used to push the snake toward an appropriate
solution.
- The energy functional which is minimized is a weighted combination of
internal and external forces.
- The internal forces emanate from the shape of the snake, while the external
forces come from the image and/or from higher level image understanding
processes.
http://www.engineering.uiowa.edu/~dip/LECTURE/Understanding2.html
3/19/2020 38
Deformable model (Snakes)
Deformable contours
Given: initial contour (model) near desired object
a.k.a. active contours, snakes
(Single frame)
Fig: Y. Boykov
[Snakes: Active contour models, Kass, Witkin, & Terzopoulos, ICCV1987]
Deformable contours
Given: initial contour (model) near desired object
a.k.a. active contours, snakes
(Single frame)
Fig: Y. Boykov
Goal: evolve the contour to fit exact object boundary
[Snakes: Active contour models, Kass, Witkin, & Terzopoulos, ICCV1987]
Deformable contours
initial intermediate final
a.k.a. active contours, snakes
Fig: Y. Boykov
Initialize near contour of interest
Iteratively refine: elastic band is adjusted so as to
• be near image positions with high gradients, and
• satisfy shape “preferences” or contour priors
Deformable contours
initial intermediate final
a.k.a. active contours, snakes
Like generalized Hough transform, useful for shape fitting; but
Hough
Fixed model shape
Single voting pass can
detect multiple instances
Snakes
Prior on shape types, but shape
iteratively adjusted (deforms)
Requires initialization nearby
One optimization “pass” to fit a
single contour
Why do we want to fit deformable
shapes?
• Non-rigid,
deformable
objects can
change their
shape over
time, e.g. lips,
hands.
Figure from Kass et al. 1987
Why do we want to fit deformable
shapes?
• Some objects have similar basic form but
some variety in the contour shape.
Slides by Kristen Grauman, UT-Austin
Deformable contours: intuition
Image from http://www.healthline.com/blogs/exercise_fitness/uploaded_images/HandBand2-795868.JPG Figure from Shapiro & Stockman
Deformable contours
initial intermediate final
a.k.a. active contours, snakes
How is the current contour adjusted to find the new contour at
each iteration?
• Define a cost function (“energy” function) that says how
good a possible configuration is.
• Seek next configuration that minimizes that cost function.
What are examples of problems with energy functions
that we have seen previously?
Snakes energy function
The total energy (cost) of the current snake is
defined as:
externalinternaltotal EEE 
A good fit between the current deformable contour
and the target shape in the image will yield a low
value for this cost function.
Internal energy: encourage prior shape preferences:
e.g., smoothness, elasticity, particular known shape.
External energy (“image” energy): encourage contour to
fit on places where image structures exist, e.g., edges.
10))(),(()(  ssysxs
Parametric curve representation
(continuous case)
Fig from Y. Boykov
External energy: intuition
• Measure how well the curve matches the image data
• “Attract” the curve toward different image features
– Edges, lines, etc.
External image energy
Magnitude of gradient
- (Magnitude of gradient)
 22
)()( IGIG yx 
22
)()( IGIG yx 
How do edges affect
“snap” of rubber
band?
Think of external
energy from image
as gravitational pull
towards areas of
high contrast
External image energy
• Image I(x,y)
• Gradient images and
• External energy at a point v(s) on the curve is
• External energy for the whole curve:
),( yxGx ),( yxGy
)|))((||))((|())(( 22
sGsGsE yxexternal  

1
0
))(( dssEE externalexternal 
Internal energy: intuition
Internal energy: intuition
http://www3.imperial.ac.uk/pls/portallive/docs/1/52679.JPG
A priori, we want to favor smooth shapes,
contours with low curvature, contours
similar to a known shape, etc. to balance
what is actually observed (i.e., in the
gradient image).
Internal energy
For a continuous curve, a common internal energy term is the “bending energy”.
At some point v(s) on the curve, this is:
The more the curve
bends  the larger
this energy value is.
The weights α and β
dictate how much
influence each
component has.
Elasticity,
Tension
Stiffness,
Curvature
sd
d
ds
d
sEinternal
2
2
))((
22
  

1
0
))(( dssEE internalinternal 
Internal energy
for whole curve:
Dealing with missing data
• The smoothness constraint can deal with missing data:
[Figure from Kass et al. 1987]
Total energy
(continuous form)
// bending energy
// total edge strength
under curve
externalinternaltotal EEE 

1
0
internal ))(( dssEEinternal 

1
0
))(( dssEE externalexternal 
Parametric curve representation
(discrete form)
• Represent the curve with a set of n points
10),(  niyx iii  …
Discrete energy function:
external term
2
1
0
2
|),(||),(| iiy
n
i
iixexternal yxGyxGE 



Discrete image gradients
),( yxGx ),( yxGy
• If the curve is represented by n points
Discrete energy function:
internal term
• If the curve is represented by n points
Elasticity,
Tension
Stiffness
Curvature
10),(  niyx iii 
i1iv
ds
d


  11112
2
2)()(   iiiiiii
ds
d





 
1
0
2
11
2
1 2
n
i
iiiiiinternalE 
…
Penalizing elasticity
• Current elastic energy definition uses a discrete estimate of
the derivative, and can be re-written as:
Possible problem with this
definition?
This encourages a closed
curve to shrink to a cluster.




1
0
2
n
i
iinternal LE  2
1
1
0
2
1 )()( ii
n
i
ii yyxx  



 
21
0
2
1
2
1 )()(


 
n
i
iiiiinternal dyyxxE 
Penalizing elasticity
• To stop the curve from shrinking to a cluster of points, we can
adjust the energy function to be:
• This encourages chains of equally spaced points.
Average distance between pairs of points –
updated at each iteration
Function of the weights

large  small medium 
• weight controls the penalty for internal elasticity




1
0
2
n
i
iinternal LE  2
1
1
0
2
1 )()( ii
n
i
ii yyxx  



Fig from Y. Boykov
Optional: specify shape prior
• If object is some smooth variation on a known
shape, we can use a term that will penalize
deviation from that shape:
where are the points of the known
shape.




1
0
2
)ˆ(
n
i
iiinternalE 
}ˆ{ i
Fig from Y. Boykov
Summary: elastic snake
• A simple elastic snake is defined by
– A set of n points,
– An internal elastic energy term
– An external edge based energy term
• To use this to locate the outline of an
object
– Initialize in the vicinity of the object
– Modify the points to minimize the total
energy
How should the weights in the energy function be chosen?
Energy minimization
• Several algorithms proposed to fit deformable
contours, including methods based on
– Greedy search
– Dynamic programming (for 2d snakes)
– (Gradient descent)
Energy minimization: greedy
• For each point, search window around it
and move to where energy function is
minimal
– Typical window size, e.g., 5 x 5 pixels
• Stop when predefined number of points
have not changed in last iteration, or after
max number of iterations
• Note
– Convergence not guaranteed
– Need decent initialization
Values shown in the cells correspond to Etotal
3/19/2020 67
Tiilikainen NP. A Comparative Study of Contour Snakes. 2007.
3/19/2020 68
Snakes: Parameters
3/19/2020 69
3/19/2020 70
3/19/2020 71
Assignment 2: Edge and boundary detection (Hough transform and SNAKE)
Due time: March 16th, 2020, 11:59 pm
For given images (grayscale and color)/you may run on other images
A) Tasks to implement
For all given images; detect edges using Canny edge detector, detect lines, circles,
ellipsed located in these images (if any). Superimpose the detected shapes on the
images.
For given images; initialize the contour for a given object and evolve the Active
Contour Model (snake) using the greedy algorithm. Represent the output as chain
code and compute the perimeter and the area inside these contours.
B) Report all of the above to TA’s (One Zip file including report, codes, results, etc).

More Related Content

What's hot

Image representation
Image representationImage representation
Image representation
Rahul Dadwal
 

What's hot (20)

Morphological image processing
Morphological image processingMorphological image processing
Morphological image processing
 
Digital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency DomainDigital Image Processing: Image Enhancement in the Frequency Domain
Digital Image Processing: Image Enhancement in the Frequency Domain
 
Image Segmentation
 Image Segmentation Image Segmentation
Image Segmentation
 
Unit3 dip
Unit3 dipUnit3 dip
Unit3 dip
 
Chapter 6 color image processing
Chapter 6 color image processingChapter 6 color image processing
Chapter 6 color image processing
 
Color models in Digitel image processing
Color models in Digitel image processingColor models in Digitel image processing
Color models in Digitel image processing
 
Image segmentation
Image segmentation Image segmentation
Image segmentation
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Image processing
Image processingImage processing
Image processing
 
Image Smoothing using Frequency Domain Filters
Image Smoothing using Frequency Domain FiltersImage Smoothing using Frequency Domain Filters
Image Smoothing using Frequency Domain Filters
 
Introduction to Image Compression
Introduction to Image CompressionIntroduction to Image Compression
Introduction to Image Compression
 
Image compression
Image compression Image compression
Image compression
 
Chapter 1 and 2 gonzalez and woods
Chapter 1 and 2 gonzalez and woodsChapter 1 and 2 gonzalez and woods
Chapter 1 and 2 gonzalez and woods
 
Watershed
WatershedWatershed
Watershed
 
Chain code in dip
Chain code in dipChain code in dip
Chain code in dip
 
Image Restoration (Frequency Domain Filters):Basics
Image Restoration (Frequency Domain Filters):BasicsImage Restoration (Frequency Domain Filters):Basics
Image Restoration (Frequency Domain Filters):Basics
 
Bit plane coding
Bit plane codingBit plane coding
Bit plane coding
 
Image representation
Image representationImage representation
Image representation
 
Hough Transform By Md.Nazmul Islam
Hough Transform By Md.Nazmul IslamHough Transform By Md.Nazmul Islam
Hough Transform By Md.Nazmul Islam
 
MPEG video compression standard
MPEG video compression standardMPEG video compression standard
MPEG video compression standard
 

Similar to Lecture 4&5 computer vision edge-detection code chains hough transform snakes

mathpsy2012 poster_Shweta_3(1)
mathpsy2012 poster_Shweta_3(1)mathpsy2012 poster_Shweta_3(1)
mathpsy2012 poster_Shweta_3(1)
Shweta Gupte
 
ModelingOfUnsegmentedCloudPointData-RP-SanjayShukla
ModelingOfUnsegmentedCloudPointData-RP-SanjayShuklaModelingOfUnsegmentedCloudPointData-RP-SanjayShukla
ModelingOfUnsegmentedCloudPointData-RP-SanjayShukla
Sanjay Shukla
 
Line Detection on the GPU
Line Detection on the GPU Line Detection on the GPU
Line Detection on the GPU
Gernot Ziegler
 

Similar to Lecture 4&5 computer vision edge-detection code chains hough transform snakes (20)

Bx31498502
Bx31498502Bx31498502
Bx31498502
 
Bx31498502
Bx31498502Bx31498502
Bx31498502
 
A PROJECT REPORT ON REMOVAL OF UNNECESSARY OBJECTS FROM PHOTOS USING MASKING
A PROJECT REPORT ON REMOVAL OF UNNECESSARY OBJECTS FROM PHOTOS USING MASKINGA PROJECT REPORT ON REMOVAL OF UNNECESSARY OBJECTS FROM PHOTOS USING MASKING
A PROJECT REPORT ON REMOVAL OF UNNECESSARY OBJECTS FROM PHOTOS USING MASKING
 
Learning Graph Representation for Data-Efficiency RL
Learning Graph Representation for Data-Efficiency RLLearning Graph Representation for Data-Efficiency RL
Learning Graph Representation for Data-Efficiency RL
 
Laplacian-regularized Graph Bandits
Laplacian-regularized Graph BanditsLaplacian-regularized Graph Bandits
Laplacian-regularized Graph Bandits
 
IRJET- Devnagari Text Detection
IRJET- Devnagari Text DetectionIRJET- Devnagari Text Detection
IRJET- Devnagari Text Detection
 
Estimating the Crest Lines on Polygonal Mesh Models by an Automatic Threshold
Estimating the Crest Lines on Polygonal Mesh Models by an Automatic ThresholdEstimating the Crest Lines on Polygonal Mesh Models by an Automatic Threshold
Estimating the Crest Lines on Polygonal Mesh Models by an Automatic Threshold
 
IMPROVEMENTS OF THE ANALYSIS OF HUMAN ACTIVITY USING ACCELERATION RECORD OF E...
IMPROVEMENTS OF THE ANALYSIS OF HUMAN ACTIVITY USING ACCELERATION RECORD OF E...IMPROVEMENTS OF THE ANALYSIS OF HUMAN ACTIVITY USING ACCELERATION RECORD OF E...
IMPROVEMENTS OF THE ANALYSIS OF HUMAN ACTIVITY USING ACCELERATION RECORD OF E...
 
ESTIMATING THE CREST LINES ON POLYGONAL MESH MODELS BY AN AUTOMATIC THRESHOLD
ESTIMATING THE CREST LINES ON POLYGONAL MESH MODELS BY AN AUTOMATIC THRESHOLDESTIMATING THE CREST LINES ON POLYGONAL MESH MODELS BY AN AUTOMATIC THRESHOLD
ESTIMATING THE CREST LINES ON POLYGONAL MESH MODELS BY AN AUTOMATIC THRESHOLD
 
Wordoku Puzzle Solver - Image Processing Project
Wordoku Puzzle Solver - Image Processing ProjectWordoku Puzzle Solver - Image Processing Project
Wordoku Puzzle Solver - Image Processing Project
 
Edge detection by modified otsu method
Edge detection by modified otsu methodEdge detection by modified otsu method
Edge detection by modified otsu method
 
EDGE DETECTION BY MODIFIED OTSU METHOD
EDGE DETECTION BY MODIFIED OTSU METHOD EDGE DETECTION BY MODIFIED OTSU METHOD
EDGE DETECTION BY MODIFIED OTSU METHOD
 
SIFT.ppt
SIFT.pptSIFT.ppt
SIFT.ppt
 
mathpsy2012 poster_Shweta_3(1)
mathpsy2012 poster_Shweta_3(1)mathpsy2012 poster_Shweta_3(1)
mathpsy2012 poster_Shweta_3(1)
 
representation.pptx
representation.pptxrepresentation.pptx
representation.pptx
 
EFFECTIVE INTEREST REGION ESTIMATION MODEL TO REPRESENT CORNERS FOR IMAGE
EFFECTIVE INTEREST REGION ESTIMATION MODEL TO REPRESENT CORNERS FOR IMAGE EFFECTIVE INTEREST REGION ESTIMATION MODEL TO REPRESENT CORNERS FOR IMAGE
EFFECTIVE INTEREST REGION ESTIMATION MODEL TO REPRESENT CORNERS FOR IMAGE
 
DDGK: Learning Graph Representations for Deep Divergence Graph Kernels
DDGK: Learning Graph Representations for Deep Divergence Graph KernelsDDGK: Learning Graph Representations for Deep Divergence Graph Kernels
DDGK: Learning Graph Representations for Deep Divergence Graph Kernels
 
ModelingOfUnsegmentedCloudPointData-RP-SanjayShukla
ModelingOfUnsegmentedCloudPointData-RP-SanjayShuklaModelingOfUnsegmentedCloudPointData-RP-SanjayShukla
ModelingOfUnsegmentedCloudPointData-RP-SanjayShukla
 
Line Detection on the GPU
Line Detection on the GPU Line Detection on the GPU
Line Detection on the GPU
 
Vf sift
Vf siftVf sift
Vf sift
 

More from cairo university

More from cairo university (20)

Tocci chapter 13 applications of programmable logic devices extended
Tocci chapter 13 applications of programmable logic devices extendedTocci chapter 13 applications of programmable logic devices extended
Tocci chapter 13 applications of programmable logic devices extended
 
Tocci chapter 12 memory devices
Tocci chapter 12 memory devicesTocci chapter 12 memory devices
Tocci chapter 12 memory devices
 
Tocci ch 9 msi logic circuits
Tocci ch 9 msi logic circuitsTocci ch 9 msi logic circuits
Tocci ch 9 msi logic circuits
 
Tocci ch 7 counters and registers modified x
Tocci ch 7 counters and registers modified xTocci ch 7 counters and registers modified x
Tocci ch 7 counters and registers modified x
 
Tocci ch 6 digital arithmetic operations and circuits
Tocci ch 6 digital arithmetic operations and circuitsTocci ch 6 digital arithmetic operations and circuits
Tocci ch 6 digital arithmetic operations and circuits
 
Tocci ch 3 5 boolean algebra, logic gates, combinational circuits, f fs, - re...
Tocci ch 3 5 boolean algebra, logic gates, combinational circuits, f fs, - re...Tocci ch 3 5 boolean algebra, logic gates, combinational circuits, f fs, - re...
Tocci ch 3 5 boolean algebra, logic gates, combinational circuits, f fs, - re...
 
A15 sedra ch 15 memory circuits
A15  sedra ch 15 memory circuitsA15  sedra ch 15 memory circuits
A15 sedra ch 15 memory circuits
 
A14 sedra ch 14 advanced mos and bipolar logic circuits
A14  sedra ch 14 advanced mos and bipolar logic circuitsA14  sedra ch 14 advanced mos and bipolar logic circuits
A14 sedra ch 14 advanced mos and bipolar logic circuits
 
A13 sedra ch 13 cmos digital logic circuits
A13  sedra ch 13 cmos digital logic circuitsA13  sedra ch 13 cmos digital logic circuits
A13 sedra ch 13 cmos digital logic circuits
 
A09 sedra ch 9 frequency response
A09  sedra ch 9 frequency responseA09  sedra ch 9 frequency response
A09 sedra ch 9 frequency response
 
5 sedra ch 05 mosfet.ppsx
5  sedra ch 05  mosfet.ppsx5  sedra ch 05  mosfet.ppsx
5 sedra ch 05 mosfet.ppsx
 
5 sedra ch 05 mosfet
5  sedra ch 05  mosfet5  sedra ch 05  mosfet
5 sedra ch 05 mosfet
 
5 sedra ch 05 mosfet revision
5  sedra ch 05  mosfet revision5  sedra ch 05  mosfet revision
5 sedra ch 05 mosfet revision
 
Fields Lec 2
Fields Lec 2Fields Lec 2
Fields Lec 2
 
Fields Lec 1
Fields Lec 1Fields Lec 1
Fields Lec 1
 
Fields Lec 5&6
Fields Lec 5&6Fields Lec 5&6
Fields Lec 5&6
 
Fields Lec 4
Fields Lec 4Fields Lec 4
Fields Lec 4
 
Fields Lec 3
Fields Lec 3Fields Lec 3
Fields Lec 3
 
Lecture 2 (system overview of c8051 f020) rv01
Lecture 2 (system overview of c8051 f020) rv01Lecture 2 (system overview of c8051 f020) rv01
Lecture 2 (system overview of c8051 f020) rv01
 
Lecture 1 (course overview and 8051 architecture) rv01
Lecture 1 (course overview and 8051 architecture) rv01Lecture 1 (course overview and 8051 architecture) rv01
Lecture 1 (course overview and 8051 architecture) rv01
 

Recently uploaded

FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
dollysharma2066
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptxBSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
BSides Seattle 2024 - Stopping Ethan Hunt From Taking Your Data.pptx
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
FULL ENJOY Call Girls In Mahipalpur Delhi Contact Us 8377877756
 
University management System project report..pdf
University management System project report..pdfUniversity management System project report..pdf
University management System project report..pdf
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01Double rodded leveling 1 pdf activity 01
Double rodded leveling 1 pdf activity 01
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
(INDIRA) Call Girl Bhosari Call Now 8617697112 Bhosari Escorts 24x7
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 

Lecture 4&5 computer vision edge-detection code chains hough transform snakes

  • 1. Computer Vision SBE 404, Spring 2020 Professor Ahmed M. Badawi ambadawi@eng1.cu.edu.eg http://scholar.google.com.eg/citations?user=r9pLu6EAAAAJ&hl=en http://www.bmes.cufe.edu.eg TA’s: Eman Marzban eman.marzban@eng1.cu.edu.eg Asem Abdelaziz asem.a.abdelaziz@eng1.cu.edu.eg
  • 2. 3/19/2020 2 Overview 1.Edge Detection 2.Edge Representation using Chain Codes 3.Line and Circle Detection using Hough Transforms 4.Active contour deformable model (Snakes)
  • 3. 3/19/2020 3 Edge Detection Goal: Could you point out the most “salient” or “strongest” edges or the object boundaries? [Szeliski's Book p.210]
  • 4. 3/19/2020 4 -Qualitatively, edges occur at boundaries between regions of different color, intensity, or texture. -Define an edge as a location of rapid intensity variation. -Think of an image as a height field. On such a surface, edges occur at locations of steep slopes. - A mathematical way to define the slope and direction of a surface is through its gradient, - The local gradient vector J points in the direction of steepest ascent in the intensity function. Its magnitude is an indication of the slope or strength of the variation, while its orientation points in a direction perpendicular to the local contour. How can we basically detect an edge?
  • 5. 3/19/2020 5 [Ch. 14, Practical Image and Video Processing Using MATLAB by Oge Marques]
  • 6. 3/19/2020 6 - Beware of the image noise! Smooth the image with a low-pass filter prior to computing the gradient. -The gradient of the smoothed image can therefore be written as i.e., we can convolve the image with the horizontal and vertical derivatives of the Gaussian kernel function, Handling image noise in edge detection
  • 7. 3/19/2020 7 [Ch. 14, Practical Image and Video Processin g Using MATLAB by Oge Marques] Even low noise levels can corrupt the edge detection operation…
  • 8. 3/19/2020 8 - For many applications, we wish to thin such a continuous gradient image to only return isolated edges, i.e., as single pixels at discrete locations along the edge contours. -This can be achieved by looking for maxima in the edge strength (gradient magnitude) in a direction perpendicular to the edge orientation, i.e., along the gradient direction. -Finding this maximum corresponds to taking a directional derivative of the strength field in the direction of the gradient and then looking for zero crossings. - The desired directional derivative is equivalent to the dot product between a second gradient operator and the results of the first, Thinning the gradient image
  • 9. 3/19/2020 9 -The gradient operator dot product with the gradient is called the Laplacian. The convolution kernel is therefore called the Laplacian of Gaussian (LoG) kernel. This kernel can be split into two separable parts, which allows for a much more efficient implementation using separable filtering. Thinning the gradient image (continued)
  • 10. 3/19/2020 10 [Ch. 14, Practical Image and Video Processing Using MATLAB by Oge Marques]
  • 11. 3/19/2020 11 - Estimate the gray-level gradient at a pixel, which can be approximated by the digital equivalent of the first-order derivative as follows [Marques’ book, p.338]: - The gradients are often computed within a 3×3 neighborhood using convolution: where the Prewitt kernels are given by: Example 1: Prewitt Edge Detector (First-order Detector)
  • 13. 3/19/2020 13 - The Laplacian operator is a straightforward digital approximation of the second-order derivative of the intensity. Although it has the potential for being employed as an isotropic (i.e., omnidirectional) edge detector, it is rarely used in isolation because of two limitations [Marques’ book, p. 343]: • It generates “double edges,” that is, positive and negative values for each edge. • It is extremely sensitive to noise. Example 2: Zero-crossing Edge Detector (Second-order detector)
  • 15. 3/19/2020 15 - The Laplacian of Gaussian (LoG) edge detector works by smoothing the image with a Gaussian low-pass filter (LPF), and then applying a Laplacian edge detector to the result. - David Marr and Ellen Hildreth proposed that LoG filtering explains much of the low-level behavior of the human vision system, since the response profile of an LoG filter approximates the receptive field of retinal cells tuned to respond to edges. Example 3: Laplacian-of-Gaussian Edge Detector (Second-order detector)
  • 18. 3/19/2020 18 1. The input image is smoothed using a Gaussian low-pass filter, with a specified value of σ: large values of σ will suppress much of the noise at the expense of weakening potentially relevant edges. 2. The local gradient (intensity and direction) is computed for each point in the smoothed image. 3. The edge points at the output of step 2 result in wide ridges. The algorithm thins those ridges, leaving only the pixels at the top of each ridge, in a process known as nonmaximal suppression. 4. The ridge pixels are then thresholded using two thresholds Tlow and Thigh: ridge pixels with values greater than Thigh are considered strong edge pixels; ridge pixels with values between Tlow and Thigh are said to be weak pixels. This process is known as hysteresis thresholding. 5. The algorithm performs edge linking, aggregating weak pixels that are 8- connected to the strong pixels. Example 4: Canny Edge Detector
  • 19. 3/19/2020 19 Canny Edge Detection http://www.cse.iitd.ernet.in/~pkalra/csl783/canny.pdf
  • 21. 3/19/2020 21 Study and Comparison of Various Image Edge Detection Techniques Raman Maini, Himanshu Aggarwal http://www.cscjournals.org/cs c/download/issuearchive/IJIP/ volume3/IJIP_V3_I1.pdf
  • 22. 3/19/2020 22 Overview 1.Edge Detection 2.Edge Representation using Chain Codes 3.Line and Circle Detection using Hough Transforms 4.Active contour deformable model (Snakes)
  • 23. 3/19/2020 23 Edge Representation using Chain Codes [Szeliski's Book p.217] - Linked edgel lists can be encoded more compactly using a variety of alternative representations. A chain code encodes a list of connected points lying on an N-8 grid using a three-bit code corresponding to the eight cardinal directions (N, NE, E, SE, S, SW, W, NW) between a point and its successor (Figure 4.34). -While this representation is more compact than the original edgel list (especially if predictive variable-length coding is used), it is not very suitable for further processing. -See: Introduction to Chain Codes http://www.mind.ilstu.edu/curriculum/chain_codes_intro/chain_codes_intro.php
  • 24. 3/19/2020 24 Edge Representation using Chain Codes - Chain code examples http://www.eng.iastate.edu/ee528/sonkamaterial/chapter_3.htm http://www.cs.ru.nl/~ths/rt2/col/h9/9ge biedENG.html
  • 25. 3/19/2020 25 Edge Representation using Arc-Length Parameterization [Szeliski's Book p.217] - A more useful representation is the arc length parameterization of a contour, x(s), where s denotes the arc length along a curve (Figure 4.35).
  • 26. 3/19/2020 26 Edge Representation using Arc-Length Parameterization [Szeliski's Book p.217] - The advantage of the arc-length parameterization is that it makes matching and processing (e.g., smoothing) operations much easier (Figure 4.36). Arc-length parameterization can also be used to smooth curves in order to remove digitization noise.
  • 27. 3/19/2020 27 Overview 1.Edge Detection 2.Edge Representation using Chain Codes 3.Line and Circle Detection using Hough Transforms 4.Active contour deformable model (Snakes)
  • 28. 3/19/2020 28 Points and lines in image and parameter spaces http://books.google.com.eg/books/abou t/Digital_Image_Processing.html?id=jCEi 9MVfxD8C&redir_esc=y [Chapter 9]
  • 30. 3/19/2020 30 Line Detection using Hough Tranform [Szeliski's Book p.221] Motivation: Lines in the real world are sometimes broken up into disconnected components or made up of many collinear line segments. In many cases, it is desirable to group such collinear segments into extended lines. Original Formulation: Each edge point votes for all possible lines passing through it, and lines corresponding to high accumulator or bin values are examined for potential line fits.
  • 31. 3/19/2020 31 Line Detection using Hough Tranform [Szeliski's Book p.222] Alternate Formulation: Use the local orientation information at each edgel to vote for a single accumulator cell.
  • 32. 3/19/2020 32 Line Detection using Hough Tranform [Szeliski's Book p.223]
  • 34. 3/19/2020 34 Hough Transform for General Parametric Curves
  • 35. 3/19/2020 35 Overview 1.Edge Detection 2.Edge Representation using Chain Codes 3.Line and Circle Detection using Hough Transforms 4.Active contour model (Snakes)
  • 36. 3/19/2020 36 Image Segmentation using the Snake Active Contour Model
  • 37. 3/19/2020 37 - The active contour model, or snake, is defined as an energy minimizing spline - The snake's energy depends on its shape and location within the image. - Local minima of this energy then correspond to desired image properties. - Snakes may be understood as a special case of a more general technique of matching a deformable model to an image by means of energy minimization. - Snakes do not solve the entire problem of finding contours in images, but rather, they depend on other mechanisms like interaction with a user, interaction with some higher level image understanding process, or information from image data adjacent in time or space. - This interaction must specify an approximate shape and starting position for the snake somewhere near the desired contour. -A priori information is then used to push the snake toward an appropriate solution. - The energy functional which is minimized is a weighted combination of internal and external forces. - The internal forces emanate from the shape of the snake, while the external forces come from the image and/or from higher level image understanding processes. http://www.engineering.uiowa.edu/~dip/LECTURE/Understanding2.html
  • 39. Deformable contours Given: initial contour (model) near desired object a.k.a. active contours, snakes (Single frame) Fig: Y. Boykov [Snakes: Active contour models, Kass, Witkin, & Terzopoulos, ICCV1987]
  • 40. Deformable contours Given: initial contour (model) near desired object a.k.a. active contours, snakes (Single frame) Fig: Y. Boykov Goal: evolve the contour to fit exact object boundary [Snakes: Active contour models, Kass, Witkin, & Terzopoulos, ICCV1987]
  • 41. Deformable contours initial intermediate final a.k.a. active contours, snakes Fig: Y. Boykov Initialize near contour of interest Iteratively refine: elastic band is adjusted so as to • be near image positions with high gradients, and • satisfy shape “preferences” or contour priors
  • 42. Deformable contours initial intermediate final a.k.a. active contours, snakes Like generalized Hough transform, useful for shape fitting; but Hough Fixed model shape Single voting pass can detect multiple instances Snakes Prior on shape types, but shape iteratively adjusted (deforms) Requires initialization nearby One optimization “pass” to fit a single contour
  • 43. Why do we want to fit deformable shapes? • Non-rigid, deformable objects can change their shape over time, e.g. lips, hands. Figure from Kass et al. 1987
  • 44. Why do we want to fit deformable shapes? • Some objects have similar basic form but some variety in the contour shape. Slides by Kristen Grauman, UT-Austin
  • 45. Deformable contours: intuition Image from http://www.healthline.com/blogs/exercise_fitness/uploaded_images/HandBand2-795868.JPG Figure from Shapiro & Stockman
  • 46. Deformable contours initial intermediate final a.k.a. active contours, snakes How is the current contour adjusted to find the new contour at each iteration? • Define a cost function (“energy” function) that says how good a possible configuration is. • Seek next configuration that minimizes that cost function. What are examples of problems with energy functions that we have seen previously?
  • 47. Snakes energy function The total energy (cost) of the current snake is defined as: externalinternaltotal EEE  A good fit between the current deformable contour and the target shape in the image will yield a low value for this cost function. Internal energy: encourage prior shape preferences: e.g., smoothness, elasticity, particular known shape. External energy (“image” energy): encourage contour to fit on places where image structures exist, e.g., edges.
  • 48. 10))(),(()(  ssysxs Parametric curve representation (continuous case) Fig from Y. Boykov
  • 49. External energy: intuition • Measure how well the curve matches the image data • “Attract” the curve toward different image features – Edges, lines, etc.
  • 50. External image energy Magnitude of gradient - (Magnitude of gradient)  22 )()( IGIG yx  22 )()( IGIG yx  How do edges affect “snap” of rubber band? Think of external energy from image as gravitational pull towards areas of high contrast
  • 51. External image energy • Image I(x,y) • Gradient images and • External energy at a point v(s) on the curve is • External energy for the whole curve: ),( yxGx ),( yxGy )|))((||))((|())(( 22 sGsGsE yxexternal    1 0 ))(( dssEE externalexternal 
  • 53. Internal energy: intuition http://www3.imperial.ac.uk/pls/portallive/docs/1/52679.JPG A priori, we want to favor smooth shapes, contours with low curvature, contours similar to a known shape, etc. to balance what is actually observed (i.e., in the gradient image).
  • 54. Internal energy For a continuous curve, a common internal energy term is the “bending energy”. At some point v(s) on the curve, this is: The more the curve bends  the larger this energy value is. The weights α and β dictate how much influence each component has. Elasticity, Tension Stiffness, Curvature sd d ds d sEinternal 2 2 ))(( 22     1 0 ))(( dssEE internalinternal  Internal energy for whole curve:
  • 55. Dealing with missing data • The smoothness constraint can deal with missing data: [Figure from Kass et al. 1987]
  • 56. Total energy (continuous form) // bending energy // total edge strength under curve externalinternaltotal EEE   1 0 internal ))(( dssEEinternal   1 0 ))(( dssEE externalexternal 
  • 57. Parametric curve representation (discrete form) • Represent the curve with a set of n points 10),(  niyx iii  …
  • 58. Discrete energy function: external term 2 1 0 2 |),(||),(| iiy n i iixexternal yxGyxGE     Discrete image gradients ),( yxGx ),( yxGy • If the curve is represented by n points
  • 59. Discrete energy function: internal term • If the curve is represented by n points Elasticity, Tension Stiffness Curvature 10),(  niyx iii  i1iv ds d     11112 2 2)()(   iiiiiii ds d        1 0 2 11 2 1 2 n i iiiiiinternalE  …
  • 60. Penalizing elasticity • Current elastic energy definition uses a discrete estimate of the derivative, and can be re-written as: Possible problem with this definition? This encourages a closed curve to shrink to a cluster.     1 0 2 n i iinternal LE  2 1 1 0 2 1 )()( ii n i ii yyxx     
  • 61.   21 0 2 1 2 1 )()(     n i iiiiinternal dyyxxE  Penalizing elasticity • To stop the curve from shrinking to a cluster of points, we can adjust the energy function to be: • This encourages chains of equally spaced points. Average distance between pairs of points – updated at each iteration
  • 62. Function of the weights  large  small medium  • weight controls the penalty for internal elasticity     1 0 2 n i iinternal LE  2 1 1 0 2 1 )()( ii n i ii yyxx      Fig from Y. Boykov
  • 63. Optional: specify shape prior • If object is some smooth variation on a known shape, we can use a term that will penalize deviation from that shape: where are the points of the known shape.     1 0 2 )ˆ( n i iiinternalE  }ˆ{ i Fig from Y. Boykov
  • 64. Summary: elastic snake • A simple elastic snake is defined by – A set of n points, – An internal elastic energy term – An external edge based energy term • To use this to locate the outline of an object – Initialize in the vicinity of the object – Modify the points to minimize the total energy How should the weights in the energy function be chosen?
  • 65. Energy minimization • Several algorithms proposed to fit deformable contours, including methods based on – Greedy search – Dynamic programming (for 2d snakes) – (Gradient descent)
  • 66. Energy minimization: greedy • For each point, search window around it and move to where energy function is minimal – Typical window size, e.g., 5 x 5 pixels • Stop when predefined number of points have not changed in last iteration, or after max number of iterations • Note – Convergence not guaranteed – Need decent initialization
  • 67. Values shown in the cells correspond to Etotal 3/19/2020 67 Tiilikainen NP. A Comparative Study of Contour Snakes. 2007.
  • 71. 3/19/2020 71 Assignment 2: Edge and boundary detection (Hough transform and SNAKE) Due time: March 16th, 2020, 11:59 pm For given images (grayscale and color)/you may run on other images A) Tasks to implement For all given images; detect edges using Canny edge detector, detect lines, circles, ellipsed located in these images (if any). Superimpose the detected shapes on the images. For given images; initialize the contour for a given object and evolve the Active Contour Model (snake) using the greedy algorithm. Represent the output as chain code and compute the perimeter and the area inside these contours. B) Report all of the above to TA’s (One Zip file including report, codes, results, etc).