Ith fAllhIn the name of Allah -...
Transcript of Ith fAllhIn the name of Allah -...
I th f All hI th f All hIn the name of AllahIn the name of Allahthe compassionate, the mercifulthe compassionate, the mercifulthe compassionate, the mercifulthe compassionate, the merciful
Digital Image ProcessingDigital Image ProcessingDigital Image ProcessingDigital Image Processing
S KasaeiS KasaeiS. KasaeiS. Kasaei
Room CE307, SUTRoom CE307, SUTRoom CE307, SUT Room CE307, SUT EE--Mail: Mail: [email protected]@sharif.edu
Home Page:Home Page: http://ce.sharif.eduhttp://ce.sharif.eduHome Page: Home Page: http://ce.sharif.eduhttp://ce.sharif.eduhttp://ipl.ce.sharif.eduhttp://ipl.ce.sharif.eduhttp://sharif.edu/~skasaeihttp://sharif.edu/~skasaei
KasaeiKasaei 33
Chapter 9Chapter 9Chapter 9Chapter 9
Image AnalysisImage Analysis&&& &
Computer VisionComputer Vision
KasaeiKasaei 44
OutlineOutlineOutline Outline
•• IntroductionIntroduction•• Theory ofTheory of Hough TransformHough TransformTheory of Theory of Hough TransformHough Transform•• Practical Issues Practical Issues •• ExamplesExamples•• ExamplesExamples•• Advantages and DisadvantagesAdvantages and Disadvantages•• Generalizations Generalizations •• ConclusionsConclusions
KasaeiKasaei 66
IntroductionIntroduction
•• Was developed by Paul Hough in 1962. Was developed by Paul Hough in 1962.
•• A special case of the Radon transform.A special case of the Radon transform.A special case of the Radon transform.A special case of the Radon transform.
•• A standard tool in the domain of artificial vision A standard tool in the domain of artificial vision and image analysis to detect straight lines andand image analysis to detect straight lines andand image analysis to detect straight lines, and and image analysis to detect straight lines, and other other parametric curvesparametric curves such as circles, ellipses, such as circles, ellipses, and other shapes.and other shapes.
•• It can also be used to It can also be used to detect boundariesdetect boundaries of an of an arbitrary shaped object if the parameters of thearbitrary shaped object if the parameters of the
KasaeiKasaei 77
arbitrary shaped object if the parameters of the arbitrary shaped object if the parameters of the object are known.object are known.
IntroductionIntroduction
•• Basic concept: an analytical function Basic concept: an analytical function represented in the represented in the Cartesian spaceCartesian space (spatial (spatial d i ) h d l t ti i thd i ) h d l t ti i thdomain) has a dual representation in the domain) has a dual representation in the parameter spaceparameter space..
•• Transforms between the Cartesian space Transforms between the Cartesian space and a parameter space in witch a straight and a parameter space in witch a straight p p gp p gline (or any parameterized curve) can be line (or any parameterized curve) can be defined.defined.
KasaeiKasaei 88
Theory of Line DetectionTheory of Line DetectionTheory of Line DetectionTheory of Line Detection
•• Example: Example: –– straight line:straight line:
•• Equation of a line passing through a point (Equation of a line passing through a point (xxii,y,yii) in ) in the the Cartesian spaceCartesian space::
+ b+ b (( dd b ib i ))yyii = ax= axii + b+ b ((aa andand b variesb varies))(where (where a a is the slope and is the slope and b b is the is the y y --intercept)intercept)
•• Equation of a single line on the Equation of a single line on the parameter spaceparameter space((abab):):
b = b = --xxiia + ya + yii
KasaeiKasaei 99
ii yyii
Theory of Line DetectionTheory of Line DetectionTheory of Line DetectionTheory of Line Detection
Transform from xy to ab:
KasaeiKasaei 1010
Theory of Line DetectionTheory of Line DetectionTheory of Line DetectionTheory of Line Detection
•• Locus of points is described by two parameters: slope Locus of points is described by two parameters: slope and and y y --intercept. intercept.
•• AA lineline in the Cartesian space forms ain the Cartesian space forms a pointpoint ((aa,, bb) in) inA A lineline in the Cartesian space forms a in the Cartesian space forms a pointpoint ((aa, , bb) in ) in the parameter space.the parameter space.
•• Likewise, a Likewise, a pointpoint in the Cartesian space forms a in the Cartesian space forms a lineline in in the parameter spacethe parameter spacethe parameter space.the parameter space.
•• Commonly, the Commonly, the polar coordinatespolar coordinates ((r, θr, θ) is used to ) is used to describe a line: describe a line:
hh h d f h l bh d f h l b–– where where r r is the distance from origin to the line given by a is the distance from origin to the line given by a perpendicular line connecting the origin to the considered line, perpendicular line connecting the origin to the considered line, and and θθ is the angle of this perpendicular line from the horizontal is the angle of this perpendicular line from the horizontal axis.axis.
KasaeiKasaei 1111
axis.axis.
Theory of Line DetectionTheory of Line DetectionTheory of Line DetectionTheory of Line Detection
•• Locus of Locus of pointspoints forming a forming a lineline in the in the image space will form a set of image space will form a set of lineslines in the in the parameter space, whose intersection parameter space, whose intersection pointpointrepresents the parameters of the line in represents the parameters of the line in the image space.the image space.
KasaeiKasaei 1212
Theory of Line DetectionTheory of Line DetectionTheory of Line DetectionTheory of Line Detection
Peak Detection: y b
x a
KasaeiKasaei 1313
Theory of Line DetectionTheory of Line DetectionTheory of Line DetectionTheory of Line Detection
aa
KasaeiKasaei 1414
b
Quantized ((a, ba, b)) parameter space (each block corresponds to a line).
Difficulty of TheoryDifficulty of TheoryDifficulty of TheoryDifficulty of Theory
Y = a x+ bY = a x+ b
For a vertical line:For a vertical line:For a vertical line:For a vertical line:
aa is infinite! is infinite!
KasaeiKasaei 1515
Practical IssuesPractical IssuesPractical Issues Practical Issues
•• Parametric or normal Parametric or normal description of a line:description of a line:
ρ=x cosθ + y sinθ
KasaeiKasaei 1616
Practical IssuesPractical IssuesPractical IssuesPractical Issues
•• Points in the Ca tesian space map to c esPoints in the Ca tesian space map to c es•• Points in the Cartesian space map to curves Points in the Cartesian space map to curves ((i.e.,i.e., sinusoids) in the polar Hough parameter sinusoids) in the polar Hough parameter spacespacespace.space.
KasaeiKasaei 1717
Practical IssuesPractical IssuesPractical Issues Practical Issues ro max
ro
KasaeiKasaei 1818
θθro min
0 pi
Quantized ((r, θr, θ)) parameter space (each block corresponds to a line).
ProcedureProcedureProcedureProcedure
111.1. Threshold the gradient image to provide Threshold the gradient image to provide edge edge pixelspixels..
22 Map each edge pixel into the parameter spaceMap each edge pixel into the parameter space2.2. Map each edge pixel into the parameter space Map each edge pixel into the parameter space by considering several candidate lines in the by considering several candidate lines in the image space and checking if these lines pass by image space and checking if these lines pass by g p g p yg p g p ythe edge pixels. the edge pixels. 1.1. For each edge pixel belonging to a candidate For each edge pixel belonging to a candidate
straight line in the image space the correspondingstraight line in the image space the correspondingstraight line in the image space, the corresponding straight line in the image space, the corresponding bin (bin (r, θr, θ) , or) , or ((a, ba, b),), in the parameter space is in the parameter space is updated.updated.
33 Th bi i h h iTh bi i h h iKasaeiKasaei 1919
3.3. The bin with the maximum count represents The bin with the maximum count represents the parameters of the straight line.the parameters of the straight line.
ProcedureProcedureProcedureProcedure
Canny edge detector. Input image.
KasaeiKasaei 2020
Hough space. De-Houghed image ( threshold of 40%).
Hough Transform FlowchartHough Transform FlowchartHough Transform FlowchartHough Transform Flowchart
KasaeiKasaei 2222
Practical IssuesPractical IssuesPractical Issues Practical Issues
Range of lines
Range of lines by
of lines by robin.
thetabin.
Range of lines
by
KasaeiKasaei 2323
by block size.
Practical IssuesPractical IssuesPractical IssuesPractical Issues
•• Care has to be taken when one quantizes Care has to be taken when one quantizes the parameter space. the parameter space.
•• When the quantization process is not fineWhen the quantization process is not fine•• When the quantization process is not fine When the quantization process is not fine enough, nearly parallel lines in the image enough, nearly parallel lines in the image space domain which are close togetherspace domain which are close togetherspace domain which are close together space domain which are close together will lie in the same bin.will lie in the same bin.
KasaeiKasaei 2424
Advantages and DisadvantagesAdvantages and DisadvantagesAdvantages and Disadvantages Advantages and Disadvantages
•• Advantages: Advantages:
-- PPerforms well in presence of noise. erforms well in presence of noise. e o s e p ese ce o o see o s e p ese ce o o se-- Pixels lying on one line need not to be Pixels lying on one line need not to be
contiguous.contiguous.gg
•• Disadvantages:Disadvantages:Disadvantages: Disadvantages:
Complicated & requires high processing time.Complicated & requires high processing time.
UUnable to detect exact positionnable to detect exact position of lineof line pixelspixels
KasaeiKasaei 2525
UUnable to detect exact positionnable to detect exact position of lineof line pixelspixels..
GeneralizationGeneralizationGeneralizationGeneralization
h f b d d hh f b d d h•• Hough transform can be used to detect shapes in an Hough transform can be used to detect shapes in an image other than straight lines such as image other than straight lines such as circlescircles and and ellipses…ellipses…
•• Used when the shape of object of interest does not Used when the shape of object of interest does not have a have a simple analytic equationsimple analytic equation describing its describing its boundary.boundary.yy
•• Instead of using a parametric equation of the curve, Instead of using a parametric equation of the curve, a a looklook--up tableup table (R(R--table) is used to define the table) is used to define the relationship between the boundary positions and relationship between the boundary positions and e at o s p bet ee t e bou da y pos t o s a de at o s p bet ee t e bou da y pos t o s a dorientations, and the Hough parameters.orientations, and the Hough parameters.
•• The lookThe look--up Rup R--table consists of distance and table consists of distance and direction pairs with respect to a chosen referencedirection pairs with respect to a chosen reference
KasaeiKasaei 2626
direction pairs with respect to a chosen reference direction pairs with respect to a chosen reference point, indexed by the orientation of the object point, indexed by the orientation of the object boundary.boundary.
GeneralizationGeneralizationGeneralizationGeneralization
•• For each point in the Model Description, an For each point in the Model Description, an orientation (gradient) along with the orientation (gradient) along with the
di t t di f thdi t t di f thcorresponding vector extending from the corresponding vector extending from the boundary point to the boundary point to the centroidcentroid is computed is computed and the pair is stored in the lookand the pair is stored in the look--up tableup tableand the pair is stored in the lookand the pair is stored in the look up table.up table.
KasaeiKasaei 2727
Connects the centroid and a tangent point p.
Hough Transform for Circle Hough Transform for Circle ggDetectionDetection
• Parametric equation:
• The parameter space will be 3-dimensional (a, b, r).
With increasing the parameter space dimensional• With increasing the parameter space dimensional
the transform complexity increases.
KasaeiKasaei 2828
ConclusionsConclusionsConclusions Conclusions
•The theory of line detection using Hough transform, problems, bottlenecks ,and
bl d ib dproblems was described.
h f h d l h• The GUI of the proposed algorithm was shown.
•For real-time applications this transform should be implemented on hardware
KasaeiKasaei 3131
should be implemented on hardware.