0% found this document useful (0 votes)
10 views

Shape Detection

The document discusses shape detection techniques including line detection, polynomial and circle fitting using the Hough transform. The Hough transform works by finding patterns in a parameter space rather than the image space and is effective for detecting simple shapes like lines and circles even with occlusions.

Uploaded by

Toản Lê
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Shape Detection

The document discusses shape detection techniques including line detection, polynomial and circle fitting using the Hough transform. The Hough transform works by finding patterns in a parameter space rather than the image space and is effective for detecting simple shapes like lines and circles even with occlusions.

Uploaded by

Toản Lê
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

Introduction to Computer Vision

(ME-4201)

Shape Detection
Shape Detection
Line detection

Shape Detection |2
Shape Detection
Line fitting
Given: Many ( xi , yi )pairs y
y = mx + c
Find: Parameters (m, c) ( xi , yi )

Minimize: Average square distance:


yi − mxi − c
( yi − mxi − c) 2
E= x
i N
Using:
E E c = y −m x
=0 & =0
m c
 ( x − x)( y − y)
i i
Note:
y x m= i

y= i
i
x= i
i
 ( x − x) i
2

N N i
Shape Detection |3
Shape Detection
Line fitting
y

Line that minimizes E!!

Solution: Use a different parameterization


(same as the one we used in computing Minimum Moment of Inertia)

1
E=
N
 (
i
 − xi cos  + yi sin  ) 2

Note: Error E must be formulated carefully!


Shape Detection |4
Shape Detection
Polynomial fitting
y
Find Polynomial:

y = f ( x) = ax3 + bx 2 + cx + d
that best fits the given points ( xi , yi )
Minimize:
x
1
 i − + + +
3 2 2
[ y ( axi bxi cxi d )]
N i

Using: E E E E
=0 , =0 , =0 , =0
a b c d

Note: f (x) is LINEAR in the parameters (a, b, c, d)

Shape Detection |5
Shape Detection
Circle fitting
Find Circle:

that best fits the given points ( xi , yi )


Minimize:

Using:

𝜕𝐸 𝜕𝐸 𝜕𝐸
= 0, = 0, =0
𝜕𝑎 𝜕𝑏 𝜕𝑟

Shape Detection |6
Shape Detection
Detection?

Slide credit: David Jacobs

Shape Detection |7
Hough Transform
Parameter space and voting

y = mx + c y
Equation of Line: y = mx + c
Find: (m, c)

Consider point: ( xi , yi ) ( xi , yi )
x
Image Space
yi = mxi + c or c = − xi m + yi
m
Parameter space also called Hough Space

(m, c)
c
Shape Detection |8
Hough Transform
Parameter space and voting
• A point can belong to many lines.
• If there is a line crosses many points, that is the line we are looking for.

c
Shape Detection |9
Hough Transform
Hough Line fitting y
Algorithm:

• Quantize Parameter Space (m, c)


(m, c)
• Create Accumulator Array A(m, c)
x
• Set A(m, c) = 0 m, c Parameter Space
A(m, c)
• For each image edge ( xi , yi ) increment: 1 1
1 1
A(m, c) = A(m, c) + 1 1 1
2
• If (m, clies
) on the line: 1 1
1 1
c = − xi m + yi 1 1

• Find local maxima in A(m, c)

Shape Detection |10


Hough Transform
Hough Line fitting
NOTE: −  m   y
Large Accumulator ( xi , yi )
More memory and computations

Improvement: (Finite Accumulator Array Size)


x
Line equation:  = − x cos + y sin  Image Space

Here 0    2 
0     max
Given points ( xi , yi ) find (  , ) ?

Hough Space Sinusoid


Hough Space

Shape Detection |11
Hough Transform
Hough Line fitting

Image space Votes

Horizontal axis is θ,
vertical is rho.
Shape Detection |12
Hough Transform
Hough Line fitting

Image votes
space

Shape Detection |13


Hough Transform
Hough Line fitting

Image votes
space

Shape Detection |14


Hough Transform
Hough Line fitting

Shape Detection |15


Hough Transform
Hough Line fitting
Move to the center
𝑛𝑐𝑜𝑙 𝑛𝑟𝑜𝑤𝑠
𝑟= 𝑥− cos 𝜃 + 𝑦 − sin 𝜃
2 2
𝜃: 0 → 180𝑜
1 2 2
𝑟: 0 → 𝑛𝑐𝑜𝑙 + 𝑛𝑟𝑜𝑤
2

Shape Detection |16


Hough Transform
Hough Circle fitting
Equation of Circle:

( xi − a) 2 + ( yi − b) 2 = r 2

If radius is known: (2D Hough Space)

Accumulator Array A(a, b)

Shape Detection |17


Hough Transform
Hough Circle fitting

Equation of Circle:

( xi − a) 2 + ( yi − b) 2 = r 2

If radius is not known: 3D Hough Space!


Use Accumulator array A(a, b, r )

What is the surface in the hough space?

Shape Detection |18


Hough Transform
Hough Circle fitting

Edge Location ( xi , yi )
Edge Direction i

Assume radius is known:

a = x − r cos 
b = y − r sin 

Need to increment only one point in Accumulator!!


Shape Detection |19
Hough Transform
General Hough Transform
• Model Shape NOT described by equation

Shape Detection |20


Hough Transform
General Hough Transform
• Model Shape NOT described by equation

Shape Detection |21


Hough Transform
General Hough Transform
Find Object Center ( xc , yc ) given edges ( xi , yi , i )
Create Accumulator Array A( xc , yc )
Initialize: A( xc , yc ) = 0 ( xc , yc )
For each edge point ( xi , yi , i )
For each entry rki in table, compute:

xc = xi + rki cos  ki
yc = yi + rki sin  ki
Increment Accumulator: A( xc , yc ) = A( xc , yc ) + 1
Find Local Maxima in A( xc , yc )
Shape Detection |22
Hough Transform
General Hough Transform

Shape Detection |23


Hough Transform
General Hough Transform

• Works on Disconnected Edges

• Relatively insensitive to occlusion

• Effective for simple shapes (lines, circles, etc)

• Trade-off between work in Image Space and Parameter Space

• Handling inaccurate edge locations:

• Increment Patch in Accumulator rather than a single point

Shape Detection |24

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy