SlideShare a Scribd company logo
1 of 61
Image Features I
Edges, Lines, Circles
Elsayed Hemayed
Overview
• Origin of Edges
• Edge Detectors
– Gradient Operators (Roberts, Prewitt, Sobel).
– Zero Crossing (Canny Edge Detector)
• Detecting Lines and Circles using Hough Transform
Image Features I 2
Edge detection
• Convert a 2D image into a set of curves
– Extracts salient features of the scene
– More compact than pixels 3
Origin of Edges
• Edges are caused by a variety of factors
depth discontinuity
surface color discontinuity
illumination discontinuity
surface normal discontinuity
Image Features I 4
Edge detection
• How can you tell that a pixel is on an
edge?
Image Features I 5
Characterizing edges
• An edge is a place of rapid change in the
image intensity function
image
intensity function
(along horizontal scanline) first derivative
edges correspond to
extrema of derivative6
Edge detection
1. Detection of short linear edge segments
(edgels)
2. Aggregation of edgels into extended
edges
(maybe parametric description such as
line, circle, …)
Image Features I 7
Image gradient
• The gradient of an image:
• The gradient points in the direction of most rapid change in intensity
The gradient direction is given by:
• how does this relate to the direction of the edge?
The edge strength is given by the gradient magnitude
Image Features I 8
The gradient direction is given by:
How does this relate to the direction of the edge?
The edge strength is given by the gradient magnitude
Simple image gradient
How would you implement this as a filter?
9
perpendicular
or various
simplifications
0 -1 1
Sobel operator
-1 0 1
-2 0 2
-1 0 1
-1 -2 -1
0 0 0
1 2 1
Magnitude:
Orientation:
In practice, it is common to
use:
Sobel operator
Original OrientationMagnitude
Gradient operators
(a): Roberts’ cross operator (b): 3x3 Prewitt operator
(c): Sobel operator (d) 4x4 Prewitt operator
Image Features I 12
Roberts and Prewitt
Image Features I 13
Image Features I 14
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? 15
Where is the edge?
Solution: smooth first
Look for peaks in
16
Derivative theorem of convolution
• This saves us one operation:
Image Features I 17
Laplacian of Gaussian (LoG)
• Consider
Laplacian of Gaussian
operator
Where is the edge? Zero-crossings of bottom graph
18
2D edge detection filters
• is the Laplacian operator:
Laplacian of Gaussian
Gaussian derivative of Gaussian
Image Features I 19
Edge detection by subtraction
smoothed (5x5 Gaussian)
original
Original - smoothedImage Features I 20
Difference of Gaussians (DoG)
Image Features I 21
DoG LoG
Canny edge detector
• The Canny operator gives single-pixel-wide images
with good continuation between adjacent pixels
• It is the most widely used edge operator today; no
one has done better since it came out in the late
80s. Many implementations are available.
• It is very sensitive to its parameters, which need to
be adjusted for different application domains.
J. Canny, A Computational Approach To Edge Detection, IEEE
Trans. Pattern Analysis and Machine Intelligence, 8:679-714, 1986.
Source: L. Fei-Fei
22
Steps:
1. Convolve image f with a Gaussian G of
scale σ
2. Filter with Sobel kernel in both horizontal
(gx) and vertical direction (gy)
3. Estimate the local edge gradient for
each pixel.
Canny Edge Detector
Image Features I 23
4. Find the location of the edge using zero
crossing
5. Compute the magnitude of the edge at
that location using
Canny Edge Detector
0*2
2


 fG
n
Image Features I 24
5. Threshold edges with hysteresis to avoid
“streaking problem” (breaking up of the edge
contour caused by operator fluctuating above
and below the threshold).
Thresholding with hysteresis:
1. Two thresholds are set, T1 and T2, T1<T2
2.Responses above T2 are actual edges
3.Responses below T1 are not edges
4.Responses between T1 and T2 are edges if
they are connected to any edges of the strong
response.
Canny Edge Detector
25
Guidelines
Sigma Size of Mask
0.5 3x3
1 5x5
2 9x9
3 13x13
4 19x19
15 69 114 69 15
35 155 255 155 35
0 0 0 0 0
-35 -155 -255 -155 -35
-15 -69 -114 -69 -15
15 35 0 -35 -15
69 155 0 155 69
114 255 0 -255 -114
69 155 0 155 69
15 35 0 35 15
x-mask
y-mask
Sigma=1
26
• Guidelines for Use:
The effect of the Canny operator is
determined by three parameters:
– the width of the Gaussian kernel used in the
smoothing phase (σ)
– the upper threshold of hysterisis
– and the lower threshold used by the tracker.
Canny Edge Detector
Image Features I 27
• Guidelines for Use:
Increasing the width of the Gaussian
kernel reduces the detector's sensitivity to
noise, at the expense of losing some of
the finer detail in the image.
The localization error in the detected
edges also increases slightly as the
Gaussian width is increased.
Canny Edge Detector
Image Features I 28
• Usually, the upper tracking threshold can
be set quite high, and the lower threshold
quite low for good results.
• Setting the lower threshold too high will
cause noisy edges to break up.
• Setting the upper threshold too low
increases the number of spurious and
undesirable edge fragments appearing in
the output.
Canny Edge Detector
29
Effect of  (Gaussian kernel size)
Canny with Canny withoriginal
The choice of depends on desired behavior
• large detects large scale edges
• small detects fine features 30
Canny Edge Detector
Original image St. dev. 1.0
Upper, lower thr.
of 255 and 1
Notice:
Most of the major
edges are detected
 lots of details have
been picked out well
note that this may be
too much detail for
subsequent processing.
Image Features I 31
Canny Edge Detector
lowering the upper thr. to 128.
The lower threshold and the
Gaussian st. dev. remains the same
faint edges are detected along
with some short `noisy' fragments
Gaussian used has a st. dev. 2.0.
Same thresholds
Much of the detail on the wall
are no longer detected,
but most of the strong edges remain.
Edges are also smoother and less noisy.
32
Image Features I 33
fine scale
high
threshold
Image Features I 34
coarse
scale,
high
threshold
Image Features I 35
coarse
scale
low
threshold
Image Features I 36
An edge is not a line...
How can we detect lines ?
Image Features I 37
Original Image Edge Image
Finding Curves With Specific
Shape
Target Lines
Image Features I 38
Finding lines in an image
• Option 1:
– Search for the line at every possible
position/orientation
– What is the cost of this operation?
• Option 2:
– Use a voting scheme: Hough transform
Image Features I 39
Line Grouping Problem
– It is not feasible to check all combinations of features by fitting a model to each
possible subset
– Only some parts of the curve are present
40
• Goal:
To find a curve of specific shape (line, circle, … etc) in
an edge image.
• Edges need not be connected
• Key Idea: Edges VOTE for the possible curve
• Computational Complexity:
With n points to find the line connecting each two:
Complexity = n x (n-1)
= n2
Hough transform is computationally attractive!
HoughTransform
Image Features I 41
Image and Hough Spaces
cmxy 
),( ii yx
y
x
Equation of Line:
Find:
Consider point:
cmxy 
),( cm
),( ii yx
iiii ymxcorcmxy 
m
),( cm
Image Space
Hough (Parameter) Space
- Every pair of points will form a line
(m, c) and add a vote in the cell
indexed by (m, c)
- The number of votes at (m, c)
Corresponds to the number of points
that lie on the line (m, c). 42
c
• Connection between image (x,y) and Hough (m,b)
spaces
– A line in the image corresponds to a point in Hough
space
– To go from image space to Hough space:
• given a set of points (x,y), find all (m,b) such that y = mx + b
x
y
m
b
m0
b0
image space Hough space
Finding lines in an image
43
1. Parameter space is divided into accumulator
cells A, all, initially, set to zero.
2. For every point p(x,y) in image, change m in the
range and calculate c. c=-xm+y
3. A(m, c) = A(m, c) + 1
At the end the value of A(mi, cj) corresponds to the number
of points that lie on the line:
y = - mi x + cj
Algorithm: Hough Transform for line
detection
Image Features I 44
• Accuracy of co-linearity is determined by the
size of subdivisions.
• Having m subdivisions, computational
complexity is now
n x m
where m is the number of subdivisions
i.e. linear in n.
Algorithm: Hough Transform for line
detection (cont.)
Image Features I 45
Hough Transform Line Detection Example
Original Image
Notice: many non-
belonging edges
Edge ImageOriginal Image Edge Image
Image Features I 46
Parameter Space Detected Lines
Hough Transform Line Detection Example
Image Features I 47
Hough Transform Line Detection Example
Original Image Original Image with
superimposed Lines
Detected Lines
Example:
Image Features I 48
Better Parameterization
(Hough Space Sinusoid)
NOTE:
• Large Accumulator
• More memory and computations
Improvement:
Line equation:
Here
Given points find
 m
 sincos yxR 
max0
0
RR 
 
(Finite Accumulator Array Size)
),( ii yx ),( R
x
Image Space
R
Hough Space
?
y
R is the perpendicular distance from the line to the origin
 is the angle this perpendicular makes with the x axis
Image Features I 49
Hough transform algorithm
1. Initialize H[R, ]=0
2. for each edge point I[x,y] in the image
for  = 0 to 180
H[R, ] += 1
3. Find the value(s) of (R, ) where H[R, ] is
maximum
4. The detected line in the image is given by
 sincos yxR 
 sincos yxR 
Image Features I 50
Image space
Votes
Horizontal axis is θ,
vertical is R.
Hough Space Sinusoid Example
51Image Features I
Note: Axis of R-θ parameter space is rotated 90o !
Hough Transform Line Detection
Example
52
Mechanics of the Hough
Transform
• Difficulties
– how big should the cells be? (too big, and we merge
quite different lines; too small, and noise causes lines
to be missed)
• How many lines?
– Count the peaks in the Hough array
– Treat adjacent peaks as a single peak
• Which points belong to each line?
– Search for points close to the line
– Solve again for line and iterate
Demo: http://www/dai.ed.ac.uk/HIPR2/houghdemo.html 53
• If looking for circles, instead of lines the
analytic expression is:
• As there are 3 parameters then the
accumulator data structure must be three
dimensional, i.e. the accumulator cell is
A(a,b,r).
Hough Transform for Circle Detection
22)(2)( rbyax 
Image Features I 54
Finding Circles by Hough Transform
Equation of Circle:
222
)()( rbyax ii 
If radius is known:
),( baAAccumulator Array
(2D Hough Space)
Image Features I 55
• Again the Hough transform is applied to each point
whose edge magnitude exceeds a certain threshold.
• The processing results correspond to points of local
maxima of accumulator cells in the parameter space a,b
of the center point of the circle and the radius r.
• If the length of the radius of the circle searched is known
then we can deal with a 2-dimensional parameter space
(for center point coordinates a,b).
Algorithm: Hough Transform for Circle
Detection
Image Features I 56
Demo:Hough Transform
Original Circle
●
●●
● point on circle
circles passing through point
loci of centers of circles passing through point
Intersection of circles
specifies center of original
circle
● point on circle
circles passing through point
57
Finding Coins
Original Edges (note noise)
58
Hough Space For Coins
Penny Quarters
Image Features I 59
Detected Coins
Note that because the quarters
and penny are different sizes, a
different Hough transform (with
separate accumulators) was
used for each circle size.
For Hough Applet see
http://www.markschulze.net/java/hough/
60
Hough Transform: Comments
• Works on Disconnected Edges
• Relatively insensitive to occlusion
• Effective for simple shapes (lines, circles,
etc)
• Handling inaccurate edge locations
Image Features I 61

More Related Content

What's hot

Image Texture Analysis
Image Texture AnalysisImage Texture Analysis
Image Texture Analysislalitxp
 
Edge Detection algorithm and code
Edge Detection algorithm and codeEdge Detection algorithm and code
Edge Detection algorithm and codeVaddi Manikanta
 
04 image enhancement edge detection
04 image enhancement edge detection04 image enhancement edge detection
04 image enhancement edge detectionRumah Belajar
 
COM2304: Digital Image Fundamentals - I
COM2304: Digital Image Fundamentals - I COM2304: Digital Image Fundamentals - I
COM2304: Digital Image Fundamentals - I Hemantha Kulathilake
 
Edge linking in image processing
Edge linking in image processingEdge linking in image processing
Edge linking in image processingVARUN KUMAR
 
Edge Detection and Segmentation
Edge Detection and SegmentationEdge Detection and Segmentation
Edge Detection and SegmentationA B Shinde
 
Image feature extraction
Image feature extractionImage feature extraction
Image feature extractionRushin Shah
 
Edge detection of video using matlab code
Edge detection of video using matlab codeEdge detection of video using matlab code
Edge detection of video using matlab codeBhushan Deore
 
Basics of edge detection and forier transform
Basics of edge detection and forier transformBasics of edge detection and forier transform
Basics of edge detection and forier transformSimranjit Singh
 
Edge Detection Using Fuzzy Logic
Edge Detection Using Fuzzy LogicEdge Detection Using Fuzzy Logic
Edge Detection Using Fuzzy LogicIJERA Editor
 
Seminar report on edge detection of video using matlab code
Seminar report on edge detection of video using matlab codeSeminar report on edge detection of video using matlab code
Seminar report on edge detection of video using matlab codeBhushan Deore
 
Study and Comparison of Various Image Edge Detection Techniques
Study and Comparison of Various Image Edge Detection TechniquesStudy and Comparison of Various Image Edge Detection Techniques
Study and Comparison of Various Image Edge Detection TechniquesCSCJournals
 
Notes on image processing
Notes on image processingNotes on image processing
Notes on image processingMohammed Kamel
 

What's hot (20)

Image Texture Analysis
Image Texture AnalysisImage Texture Analysis
Image Texture Analysis
 
Edge Detection algorithm and code
Edge Detection algorithm and codeEdge Detection algorithm and code
Edge Detection algorithm and code
 
04 image enhancement edge detection
04 image enhancement edge detection04 image enhancement edge detection
04 image enhancement edge detection
 
COM2304: Digital Image Fundamentals - I
COM2304: Digital Image Fundamentals - I COM2304: Digital Image Fundamentals - I
COM2304: Digital Image Fundamentals - I
 
Edge linking in image processing
Edge linking in image processingEdge linking in image processing
Edge linking in image processing
 
Edge Detection and Segmentation
Edge Detection and SegmentationEdge Detection and Segmentation
Edge Detection and Segmentation
 
Image feature extraction
Image feature extractionImage feature extraction
Image feature extraction
 
Edge detection of video using matlab code
Edge detection of video using matlab codeEdge detection of video using matlab code
Edge detection of video using matlab code
 
Basics of edge detection and forier transform
Basics of edge detection and forier transformBasics of edge detection and forier transform
Basics of edge detection and forier transform
 
LN s11-machine vision-s2
LN s11-machine vision-s2LN s11-machine vision-s2
LN s11-machine vision-s2
 
Edge Detection Using Fuzzy Logic
Edge Detection Using Fuzzy LogicEdge Detection Using Fuzzy Logic
Edge Detection Using Fuzzy Logic
 
Edge detection-LOG
Edge detection-LOGEdge detection-LOG
Edge detection-LOG
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Image segmentation
Image segmentationImage segmentation
Image segmentation
 
Seminar report on edge detection of video using matlab code
Seminar report on edge detection of video using matlab codeSeminar report on edge detection of video using matlab code
Seminar report on edge detection of video using matlab code
 
Study and Comparison of Various Image Edge Detection Techniques
Study and Comparison of Various Image Edge Detection TechniquesStudy and Comparison of Various Image Edge Detection Techniques
Study and Comparison of Various Image Edge Detection Techniques
 
Notes on image processing
Notes on image processingNotes on image processing
Notes on image processing
 
Lec09 hough
Lec09 houghLec09 hough
Lec09 hough
 
Line Detection
Line DetectionLine Detection
Line Detection
 
Image segmentation
Image segmentation Image segmentation
Image segmentation
 

Similar to Detect Lines and Circles Using Hough Transform

10 cie552 image_featuresii_corner
10 cie552 image_featuresii_corner10 cie552 image_featuresii_corner
10 cie552 image_featuresii_cornerElsayed Hemayed
 
Chapter10 image segmentation
Chapter10 image segmentationChapter10 image segmentation
Chapter10 image segmentationasodariyabhavesh
 
Line Detection using Hough transform .pptx
Line Detection using Hough transform .pptxLine Detection using Hough transform .pptx
Line Detection using Hough transform .pptxshubham loni
 
image segmentation by ppres.pptx
image segmentation by ppres.pptximage segmentation by ppres.pptx
image segmentation by ppres.pptxmohan134666
 
Module-5-1_230523_171754 (1).pdf
Module-5-1_230523_171754 (1).pdfModule-5-1_230523_171754 (1).pdf
Module-5-1_230523_171754 (1).pdfvikasmittal92
 
11 cie552 image_featuresii_sift
11 cie552 image_featuresii_sift11 cie552 image_featuresii_sift
11 cie552 image_featuresii_siftElsayed Hemayed
 
Image enhancement
Image enhancementImage enhancement
Image enhancementAyaelshiwi
 
image segmentation image segmentation.pptx
image segmentation image segmentation.pptximage segmentation image segmentation.pptx
image segmentation image segmentation.pptxNaveenKumar5162
 
Edge Drawing - An Heuristic Approach to Robust Real-Time Edge Detection
Edge Drawing - An Heuristic Approach to Robust Real-Time Edge DetectionEdge Drawing - An Heuristic Approach to Robust Real-Time Edge Detection
Edge Drawing - An Heuristic Approach to Robust Real-Time Edge Detectioncihantopal2
 
Basics of Linear Hough Transform
Basics of Linear Hough TransformBasics of Linear Hough Transform
Basics of Linear Hough TransformRaj Rana
 
Spatial Filtering in intro image processingr
Spatial Filtering in intro image processingrSpatial Filtering in intro image processingr
Spatial Filtering in intro image processingrkumarankit06875
 
DIP Notes Unit-1 PPT.pdf
DIP Notes Unit-1 PPT.pdfDIP Notes Unit-1 PPT.pdf
DIP Notes Unit-1 PPT.pdfGaurav Sharma
 

Similar to Detect Lines and Circles Using Hough Transform (20)

PPT s06-machine vision-s2
PPT s06-machine vision-s2PPT s06-machine vision-s2
PPT s06-machine vision-s2
 
10 cie552 image_featuresii_corner
10 cie552 image_featuresii_corner10 cie552 image_featuresii_corner
10 cie552 image_featuresii_corner
 
Chapter10 image segmentation
Chapter10 image segmentationChapter10 image segmentation
Chapter10 image segmentation
 
Line Detection using Hough transform .pptx
Line Detection using Hough transform .pptxLine Detection using Hough transform .pptx
Line Detection using Hough transform .pptx
 
2. filtering basics
2. filtering basics2. filtering basics
2. filtering basics
 
Edge Detection
Edge Detection Edge Detection
Edge Detection
 
cv1.ppt
cv1.pptcv1.ppt
cv1.ppt
 
image segmentation by ppres.pptx
image segmentation by ppres.pptximage segmentation by ppres.pptx
image segmentation by ppres.pptx
 
Module-5-1_230523_171754 (1).pdf
Module-5-1_230523_171754 (1).pdfModule-5-1_230523_171754 (1).pdf
Module-5-1_230523_171754 (1).pdf
 
11 cie552 image_featuresii_sift
11 cie552 image_featuresii_sift11 cie552 image_featuresii_sift
11 cie552 image_featuresii_sift
 
Image enhancement
Image enhancementImage enhancement
Image enhancement
 
image segmentation image segmentation.pptx
image segmentation image segmentation.pptximage segmentation image segmentation.pptx
image segmentation image segmentation.pptx
 
Edge Drawing - An Heuristic Approach to Robust Real-Time Edge Detection
Edge Drawing - An Heuristic Approach to Robust Real-Time Edge DetectionEdge Drawing - An Heuristic Approach to Robust Real-Time Edge Detection
Edge Drawing - An Heuristic Approach to Robust Real-Time Edge Detection
 
OpenCV.pdf
OpenCV.pdfOpenCV.pdf
OpenCV.pdf
 
Basics of Linear Hough Transform
Basics of Linear Hough TransformBasics of Linear Hough Transform
Basics of Linear Hough Transform
 
Spatial Filtering in intro image processingr
Spatial Filtering in intro image processingrSpatial Filtering in intro image processingr
Spatial Filtering in intro image processingr
 
Mvs adas
Mvs adasMvs adas
Mvs adas
 
Segmentation Techniques -I
Segmentation Techniques -ISegmentation Techniques -I
Segmentation Techniques -I
 
Mk slides.ppt
Mk slides.pptMk slides.ppt
Mk slides.ppt
 
DIP Notes Unit-1 PPT.pdf
DIP Notes Unit-1 PPT.pdfDIP Notes Unit-1 PPT.pdf
DIP Notes Unit-1 PPT.pdf
 

More from Elsayed Hemayed

14 cie552 camera_calibration
14 cie552 camera_calibration14 cie552 camera_calibration
14 cie552 camera_calibrationElsayed Hemayed
 
12 cie552 object_recognition
12 cie552 object_recognition12 cie552 object_recognition
12 cie552 object_recognitionElsayed Hemayed
 
08 cie552 image_segmentation
08 cie552 image_segmentation08 cie552 image_segmentation
08 cie552 image_segmentationElsayed Hemayed
 
07 cie552 image_mosaicing
07 cie552 image_mosaicing07 cie552 image_mosaicing
07 cie552 image_mosaicingElsayed Hemayed
 
06 cie552 image_manipulation
06 cie552 image_manipulation06 cie552 image_manipulation
06 cie552 image_manipulationElsayed Hemayed
 
05 cie552 image_enhancement
05 cie552 image_enhancement05 cie552 image_enhancement
05 cie552 image_enhancementElsayed Hemayed
 
04 cie552 image_filtering_frequency
04 cie552 image_filtering_frequency04 cie552 image_filtering_frequency
04 cie552 image_filtering_frequencyElsayed Hemayed
 
03 cie552 image_filtering_spatial
03 cie552 image_filtering_spatial03 cie552 image_filtering_spatial
03 cie552 image_filtering_spatialElsayed Hemayed
 
02 cie552 image_andcamera
02 cie552 image_andcamera02 cie552 image_andcamera
02 cie552 image_andcameraElsayed Hemayed
 
Csci101 lect04 advanced_selection
Csci101 lect04 advanced_selectionCsci101 lect04 advanced_selection
Csci101 lect04 advanced_selectionElsayed Hemayed
 
Csci101 lect10 algorithms_iii
Csci101 lect10 algorithms_iiiCsci101 lect10 algorithms_iii
Csci101 lect10 algorithms_iiiElsayed Hemayed
 
Csci101 lect09 vectorized_code
Csci101 lect09 vectorized_codeCsci101 lect09 vectorized_code
Csci101 lect09 vectorized_codeElsayed Hemayed
 
Csci101 lect08b matlab_programs
Csci101 lect08b matlab_programsCsci101 lect08b matlab_programs
Csci101 lect08b matlab_programsElsayed Hemayed
 
Csci101 lect08a matlab_programs
Csci101 lect08a matlab_programsCsci101 lect08a matlab_programs
Csci101 lect08a matlab_programsElsayed Hemayed
 
Csci101 lect07 algorithms_ii
Csci101 lect07 algorithms_iiCsci101 lect07 algorithms_ii
Csci101 lect07 algorithms_iiElsayed Hemayed
 
Csci101 lect06 advanced_looping
Csci101 lect06 advanced_loopingCsci101 lect06 advanced_looping
Csci101 lect06 advanced_loopingElsayed Hemayed
 
Csci101 lect05 formatted_output
Csci101 lect05 formatted_outputCsci101 lect05 formatted_output
Csci101 lect05 formatted_outputElsayed Hemayed
 
Csci101 lect03 algorithms_i
Csci101 lect03 algorithms_iCsci101 lect03 algorithms_i
Csci101 lect03 algorithms_iElsayed Hemayed
 
Csci101 lect02 selection_andlooping
Csci101 lect02 selection_andloopingCsci101 lect02 selection_andlooping
Csci101 lect02 selection_andloopingElsayed Hemayed
 

More from Elsayed Hemayed (20)

14 cie552 camera_calibration
14 cie552 camera_calibration14 cie552 camera_calibration
14 cie552 camera_calibration
 
12 cie552 object_recognition
12 cie552 object_recognition12 cie552 object_recognition
12 cie552 object_recognition
 
08 cie552 image_segmentation
08 cie552 image_segmentation08 cie552 image_segmentation
08 cie552 image_segmentation
 
07 cie552 image_mosaicing
07 cie552 image_mosaicing07 cie552 image_mosaicing
07 cie552 image_mosaicing
 
06 cie552 image_manipulation
06 cie552 image_manipulation06 cie552 image_manipulation
06 cie552 image_manipulation
 
05 cie552 image_enhancement
05 cie552 image_enhancement05 cie552 image_enhancement
05 cie552 image_enhancement
 
04 cie552 image_filtering_frequency
04 cie552 image_filtering_frequency04 cie552 image_filtering_frequency
04 cie552 image_filtering_frequency
 
03 cie552 image_filtering_spatial
03 cie552 image_filtering_spatial03 cie552 image_filtering_spatial
03 cie552 image_filtering_spatial
 
02 cie552 image_andcamera
02 cie552 image_andcamera02 cie552 image_andcamera
02 cie552 image_andcamera
 
01 cie552 introduction
01 cie552 introduction01 cie552 introduction
01 cie552 introduction
 
Csci101 lect04 advanced_selection
Csci101 lect04 advanced_selectionCsci101 lect04 advanced_selection
Csci101 lect04 advanced_selection
 
Csci101 lect10 algorithms_iii
Csci101 lect10 algorithms_iiiCsci101 lect10 algorithms_iii
Csci101 lect10 algorithms_iii
 
Csci101 lect09 vectorized_code
Csci101 lect09 vectorized_codeCsci101 lect09 vectorized_code
Csci101 lect09 vectorized_code
 
Csci101 lect08b matlab_programs
Csci101 lect08b matlab_programsCsci101 lect08b matlab_programs
Csci101 lect08b matlab_programs
 
Csci101 lect08a matlab_programs
Csci101 lect08a matlab_programsCsci101 lect08a matlab_programs
Csci101 lect08a matlab_programs
 
Csci101 lect07 algorithms_ii
Csci101 lect07 algorithms_iiCsci101 lect07 algorithms_ii
Csci101 lect07 algorithms_ii
 
Csci101 lect06 advanced_looping
Csci101 lect06 advanced_loopingCsci101 lect06 advanced_looping
Csci101 lect06 advanced_looping
 
Csci101 lect05 formatted_output
Csci101 lect05 formatted_outputCsci101 lect05 formatted_output
Csci101 lect05 formatted_output
 
Csci101 lect03 algorithms_i
Csci101 lect03 algorithms_iCsci101 lect03 algorithms_i
Csci101 lect03 algorithms_i
 
Csci101 lect02 selection_andlooping
Csci101 lect02 selection_andloopingCsci101 lect02 selection_andlooping
Csci101 lect02 selection_andlooping
 

Recently uploaded

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 

Recently uploaded (20)

Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 

Detect Lines and Circles Using Hough Transform

  • 1. Image Features I Edges, Lines, Circles Elsayed Hemayed
  • 2. Overview • Origin of Edges • Edge Detectors – Gradient Operators (Roberts, Prewitt, Sobel). – Zero Crossing (Canny Edge Detector) • Detecting Lines and Circles using Hough Transform Image Features I 2
  • 3. Edge detection • Convert a 2D image into a set of curves – Extracts salient features of the scene – More compact than pixels 3
  • 4. Origin of Edges • Edges are caused by a variety of factors depth discontinuity surface color discontinuity illumination discontinuity surface normal discontinuity Image Features I 4
  • 5. Edge detection • How can you tell that a pixel is on an edge? Image Features I 5
  • 6. Characterizing edges • An edge is a place of rapid change in the image intensity function image intensity function (along horizontal scanline) first derivative edges correspond to extrema of derivative6
  • 7. Edge detection 1. Detection of short linear edge segments (edgels) 2. Aggregation of edgels into extended edges (maybe parametric description such as line, circle, …) Image Features I 7
  • 8. Image gradient • The gradient of an image: • The gradient points in the direction of most rapid change in intensity The gradient direction is given by: • how does this relate to the direction of the edge? The edge strength is given by the gradient magnitude Image Features I 8
  • 9. The gradient direction is given by: How does this relate to the direction of the edge? The edge strength is given by the gradient magnitude Simple image gradient How would you implement this as a filter? 9 perpendicular or various simplifications 0 -1 1
  • 10. Sobel operator -1 0 1 -2 0 2 -1 0 1 -1 -2 -1 0 0 0 1 2 1 Magnitude: Orientation: In practice, it is common to use:
  • 12. Gradient operators (a): Roberts’ cross operator (b): 3x3 Prewitt operator (c): Sobel operator (d) 4x4 Prewitt operator Image Features I 12
  • 13. Roberts and Prewitt Image Features I 13
  • 15. 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? 15
  • 16. Where is the edge? Solution: smooth first Look for peaks in 16
  • 17. Derivative theorem of convolution • This saves us one operation: Image Features I 17
  • 18. Laplacian of Gaussian (LoG) • Consider Laplacian of Gaussian operator Where is the edge? Zero-crossings of bottom graph 18
  • 19. 2D edge detection filters • is the Laplacian operator: Laplacian of Gaussian Gaussian derivative of Gaussian Image Features I 19
  • 20. Edge detection by subtraction smoothed (5x5 Gaussian) original Original - smoothedImage Features I 20
  • 21. Difference of Gaussians (DoG) Image Features I 21 DoG LoG
  • 22. Canny edge detector • The Canny operator gives single-pixel-wide images with good continuation between adjacent pixels • It is the most widely used edge operator today; no one has done better since it came out in the late 80s. Many implementations are available. • It is very sensitive to its parameters, which need to be adjusted for different application domains. J. Canny, A Computational Approach To Edge Detection, IEEE Trans. Pattern Analysis and Machine Intelligence, 8:679-714, 1986. Source: L. Fei-Fei 22
  • 23. Steps: 1. Convolve image f with a Gaussian G of scale σ 2. Filter with Sobel kernel in both horizontal (gx) and vertical direction (gy) 3. Estimate the local edge gradient for each pixel. Canny Edge Detector Image Features I 23
  • 24. 4. Find the location of the edge using zero crossing 5. Compute the magnitude of the edge at that location using Canny Edge Detector 0*2 2    fG n Image Features I 24
  • 25. 5. Threshold edges with hysteresis to avoid “streaking problem” (breaking up of the edge contour caused by operator fluctuating above and below the threshold). Thresholding with hysteresis: 1. Two thresholds are set, T1 and T2, T1<T2 2.Responses above T2 are actual edges 3.Responses below T1 are not edges 4.Responses between T1 and T2 are edges if they are connected to any edges of the strong response. Canny Edge Detector 25
  • 26. Guidelines Sigma Size of Mask 0.5 3x3 1 5x5 2 9x9 3 13x13 4 19x19 15 69 114 69 15 35 155 255 155 35 0 0 0 0 0 -35 -155 -255 -155 -35 -15 -69 -114 -69 -15 15 35 0 -35 -15 69 155 0 155 69 114 255 0 -255 -114 69 155 0 155 69 15 35 0 35 15 x-mask y-mask Sigma=1 26
  • 27. • Guidelines for Use: The effect of the Canny operator is determined by three parameters: – the width of the Gaussian kernel used in the smoothing phase (σ) – the upper threshold of hysterisis – and the lower threshold used by the tracker. Canny Edge Detector Image Features I 27
  • 28. • Guidelines for Use: Increasing the width of the Gaussian kernel reduces the detector's sensitivity to noise, at the expense of losing some of the finer detail in the image. The localization error in the detected edges also increases slightly as the Gaussian width is increased. Canny Edge Detector Image Features I 28
  • 29. • Usually, the upper tracking threshold can be set quite high, and the lower threshold quite low for good results. • Setting the lower threshold too high will cause noisy edges to break up. • Setting the upper threshold too low increases the number of spurious and undesirable edge fragments appearing in the output. Canny Edge Detector 29
  • 30. Effect of  (Gaussian kernel size) Canny with Canny withoriginal The choice of depends on desired behavior • large detects large scale edges • small detects fine features 30
  • 31. Canny Edge Detector Original image St. dev. 1.0 Upper, lower thr. of 255 and 1 Notice: Most of the major edges are detected  lots of details have been picked out well note that this may be too much detail for subsequent processing. Image Features I 31
  • 32. Canny Edge Detector lowering the upper thr. to 128. The lower threshold and the Gaussian st. dev. remains the same faint edges are detected along with some short `noisy' fragments Gaussian used has a st. dev. 2.0. Same thresholds Much of the detail on the wall are no longer detected, but most of the strong edges remain. Edges are also smoother and less noisy. 32
  • 37. An edge is not a line... How can we detect lines ? Image Features I 37
  • 38. Original Image Edge Image Finding Curves With Specific Shape Target Lines Image Features I 38
  • 39. Finding lines in an image • Option 1: – Search for the line at every possible position/orientation – What is the cost of this operation? • Option 2: – Use a voting scheme: Hough transform Image Features I 39
  • 40. Line Grouping Problem – It is not feasible to check all combinations of features by fitting a model to each possible subset – Only some parts of the curve are present 40
  • 41. • Goal: To find a curve of specific shape (line, circle, … etc) in an edge image. • Edges need not be connected • Key Idea: Edges VOTE for the possible curve • Computational Complexity: With n points to find the line connecting each two: Complexity = n x (n-1) = n2 Hough transform is computationally attractive! HoughTransform Image Features I 41
  • 42. Image and Hough Spaces cmxy  ),( ii yx y x Equation of Line: Find: Consider point: cmxy  ),( cm ),( ii yx iiii ymxcorcmxy  m ),( cm Image Space Hough (Parameter) Space - Every pair of points will form a line (m, c) and add a vote in the cell indexed by (m, c) - The number of votes at (m, c) Corresponds to the number of points that lie on the line (m, c). 42 c
  • 43. • Connection between image (x,y) and Hough (m,b) spaces – A line in the image corresponds to a point in Hough space – To go from image space to Hough space: • given a set of points (x,y), find all (m,b) such that y = mx + b x y m b m0 b0 image space Hough space Finding lines in an image 43
  • 44. 1. Parameter space is divided into accumulator cells A, all, initially, set to zero. 2. For every point p(x,y) in image, change m in the range and calculate c. c=-xm+y 3. A(m, c) = A(m, c) + 1 At the end the value of A(mi, cj) corresponds to the number of points that lie on the line: y = - mi x + cj Algorithm: Hough Transform for line detection Image Features I 44
  • 45. • Accuracy of co-linearity is determined by the size of subdivisions. • Having m subdivisions, computational complexity is now n x m where m is the number of subdivisions i.e. linear in n. Algorithm: Hough Transform for line detection (cont.) Image Features I 45
  • 46. Hough Transform Line Detection Example Original Image Notice: many non- belonging edges Edge ImageOriginal Image Edge Image Image Features I 46
  • 47. Parameter Space Detected Lines Hough Transform Line Detection Example Image Features I 47
  • 48. Hough Transform Line Detection Example Original Image Original Image with superimposed Lines Detected Lines Example: Image Features I 48
  • 49. Better Parameterization (Hough Space Sinusoid) NOTE: • Large Accumulator • More memory and computations Improvement: Line equation: Here Given points find  m  sincos yxR  max0 0 RR    (Finite Accumulator Array Size) ),( ii yx ),( R x Image Space R Hough Space ? y R is the perpendicular distance from the line to the origin  is the angle this perpendicular makes with the x axis Image Features I 49
  • 50. Hough transform algorithm 1. Initialize H[R, ]=0 2. for each edge point I[x,y] in the image for  = 0 to 180 H[R, ] += 1 3. Find the value(s) of (R, ) where H[R, ] is maximum 4. The detected line in the image is given by  sincos yxR   sincos yxR  Image Features I 50
  • 51. Image space Votes Horizontal axis is θ, vertical is R. Hough Space Sinusoid Example 51Image Features I
  • 52. Note: Axis of R-θ parameter space is rotated 90o ! Hough Transform Line Detection Example 52
  • 53. Mechanics of the Hough Transform • Difficulties – how big should the cells be? (too big, and we merge quite different lines; too small, and noise causes lines to be missed) • How many lines? – Count the peaks in the Hough array – Treat adjacent peaks as a single peak • Which points belong to each line? – Search for points close to the line – Solve again for line and iterate Demo: http://www/dai.ed.ac.uk/HIPR2/houghdemo.html 53
  • 54. • If looking for circles, instead of lines the analytic expression is: • As there are 3 parameters then the accumulator data structure must be three dimensional, i.e. the accumulator cell is A(a,b,r). Hough Transform for Circle Detection 22)(2)( rbyax  Image Features I 54
  • 55. Finding Circles by Hough Transform Equation of Circle: 222 )()( rbyax ii  If radius is known: ),( baAAccumulator Array (2D Hough Space) Image Features I 55
  • 56. • Again the Hough transform is applied to each point whose edge magnitude exceeds a certain threshold. • The processing results correspond to points of local maxima of accumulator cells in the parameter space a,b of the center point of the circle and the radius r. • If the length of the radius of the circle searched is known then we can deal with a 2-dimensional parameter space (for center point coordinates a,b). Algorithm: Hough Transform for Circle Detection Image Features I 56
  • 57. Demo:Hough Transform Original Circle ● ●● ● point on circle circles passing through point loci of centers of circles passing through point Intersection of circles specifies center of original circle ● point on circle circles passing through point 57
  • 58. Finding Coins Original Edges (note noise) 58
  • 59. Hough Space For Coins Penny Quarters Image Features I 59
  • 60. Detected Coins Note that because the quarters and penny are different sizes, a different Hough transform (with separate accumulators) was used for each circle size. For Hough Applet see http://www.markschulze.net/java/hough/ 60
  • 61. Hough Transform: Comments • Works on Disconnected Edges • Relatively insensitive to occlusion • Effective for simple shapes (lines, circles, etc) • Handling inaccurate edge locations Image Features I 61