Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an...

29
Course 8 Contours

Transcript of Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an...

Page 1: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

Course 8 Contours

Page 2: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

Course 8 Contours

Def: edge list

---- ordered set of edge point or fragments.

Def: contour

---- an edge list or expression that is used to represent the curve.

A contour can be open or closed.

Page 3: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

1.Digital Curve.

(1) Curve length:

(2) K-slope: the (angle) direction vector between points with k edge points apart.

n

iiiii yyxxs

2

21

21 )()(

iki

iki

xx

yy

1tan

Page 4: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

(3) K-curvature: the difference between left k-slope and right k-slope at a digital curve point:

rl

Page 5: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

2. Curve Representations

1) Chain code

Chain code quantities a space to 8 directions and encodes a contour at each edge point with the directions in an ordered sequence.

------- Chain code has compact description.

------- Chain code cannot express branched curves.

Page 6: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

s2) plot:

For a digital curve, compute curve length and

slope from a beginning edge point. Then plot the

obtained curve length and slop in space.

------ Line segment in curve; horizontal line in plot.

------ Circular arc in curve; line segment of some direction in space.

------ Using plot can easily segment a curve at discontinuous point of plot.

s

s

ss

s

s

Page 7: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.
Page 8: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

3) Graph representation:

Establish topology relations among edge list points. Each edge point is a graph node.

Struct Node { int node_number; int curve_number; int x, y; // position char type; int link[8]; //link relation int link_direction[8]; //heading or ending char flag; //process flag } node;

Page 9: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

------ Digital description of curve.------ Can handle branched curves.------ Easy in operation.------ Use more memories, but it can be simplified. e.g. to remove nodes that have type=2.

Struct link { int curve_number; int link_length; int node_list[]; char flag; //process flag } link;

Page 10: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

3. Polyline representationRepresent an edge list by a set of joined line segments. The edge data not being the joint point will be neglected.

Page 11: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

1). Recursive splitting method:

Consider a curve with endpoint A and B

(a) connect end-points A and B

(b) along the curve , compute normalized distance

to chord . find the edge point say c with maximum .

(c) if , the preset threshold, insert a vertex at edge point c.

The curve is then subdivided into two curves.

(d) For each curve, repeat the process a)—c) until no vertex can be inserted.

BA

ABsdd /ˆ

Td ˆ

Page 12: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

2). Sequential method:

(a)  Starting with an endpoint of a curve tracing the curve, calculate the distance between the curve and the chord from the starting point to moving point.

(b) If the distance is greater than a preset threshold, put a vertex there.

(c) Take the vertex as a

new starting point.

Repeat the operation a) and

(d) until it complete the curve.

Page 13: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

3) . Area based sequential method:

The same as the above method. But the criteria to insert a vertex is

where is the area between the curve and chord.

is the length of chord.

 

L

Ad

A

L

Page 14: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

4). Break-point detection:

Sequential polyline methods have advantage of easy and fast operations. But they are error-based operations, Corner positions usually cannot accurately located. One way to solve the problem is to detect break point first. Then polylinelize the curve piecewise.

To detect break point:

a) Calculate K-curvature along a curve.

b) Plot the curve’s curvatures in plane.

Where ---curvature, s---curve length.

s

Page 15: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

c) Do Gaussian smooth to the plot to remove noise of the plot.

d) Corners of original curve will correspond to peaks in plot, arcs to plateaus, threshold the value

in plot will get break points.

s

s

Page 16: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

5). Hop-Along algorithm:

Hop-along method approximate a contour by a sequence of line segments, doing split and merge in short subsets of edge points.

a) Start with the first K edge points from edge list.

b) Fit line segment (say, using least- square method) between the first and the last edge points of the sub list.

c) If normalized maximum error is too large, shorten the sub list at the point of maximum error. Return step b).

Page 17: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

d) If the line fit succeeds, compare the orientation of the current line segment with that the previous line segments. If two line segments have similar orientation, replace the two line segments with a single line segment.

e) Make the current line segment the previous line segment and advance the window of edges so that there are K edge points in the sub list. Return to step b).

Page 18: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

3. Curve fitting Curve fitting is trying to find a smooth curve expression

of mathematic form from curve’s polyline expression.

1) Conic sections:

To determine a conic section is to determine parameters a, b, c, d, e, f from 3 edge points, although there are classic method. We will introduce a “guided form” method.

0),( 22 feydxcybxyaxyxf

Page 19: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

a) Select knot position from each polyline segment.

where

1)1( iiiii VvVvK

1

ii

iiv

Page 20: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

b) Form lines of guided frame:

KiVi+1:

Vi+1Ki+1:

KiKi+1:

Then: the conic intersection is:

where is control parameter.

0210 yaxaa

0210 ybxbb0210 yuxuu

2210210210 )())(( yuxuuybxbbyaxaa

Page 21: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

2) Cubic Spline:

Cubic spline represents a curve piecewise by 3rd-order polynomials joined smoothly at knots of the curve.

Between two knots:

where

There are 8 parameters and need 8 constraints to determine the 8 parameters.

33

2210))(),(()( uauauaauyuxup >

]1,0[),,( uaaa yixii

Page 22: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

Positions of first and last edge points give 4 constraints.

The continuity of the curve with its neighboring curves gives another 2 constraints.

• Orientation of edge at knot provides one constraint.

• or

where , tangent direction at knot introduces two equations and one additional unknown . All the parameters and can be solved.

0)0()1(1 ii PP 0)(34 111 iiiii PPttt

iii tt ˆi

i

Page 23: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

4. Regression 1) Least Squares Regretion Using all edge point in an edge list to compute the model of curve, minimizing the distances between data points to the curve.

For a straight edge:

Then: call least square

to solve for and .

0cossin yx

i

ii yx min)cossin( 22

Page 24: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

Note:

If outlier points in edge list, it can pull the solution away from the true one.

Page 25: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

2) Least-Median-Square Regression:

It claim that the algorithm can handle out 50% of outlines in edge list:

Algorithm:

a) Choose p points randomly from the set of n data points.

b)  Compute the fit model to the p points.

c)  Compute the median of the residual squares.

d) The fitting procedure is repeated until a fit is found with sufficiently small median of residual squares, or processes reached preset steps.

Page 26: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

5. Hough Transform --- Voting based method: a point on a curve votes several combinations of curve parameters. --- Edge point not necessary in an ordered list.

Consider a straight Line in x-y space:

are variables and are parameters.If given only a point , it can draw infinite number lines passing through point with different slope and intercept . The relation between and appears to be a line in space.

cmxy yx, cm,

),( yx),( yx

mcm

ccm

mxyc yx, ( are fixed)

Page 27: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

This indicates that a point in x-y space corresponds to a line in m-c space. If all data points come from a straight line in x-y space, their corresponding lines in m-c space will intersect at a point. The corresponding values of m and c of the intersection gives the parameters of the line in x-y space.

c

m

Page 28: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

In practice, we use polar form of a line to avoid the problem of vertical lines.

Given a set of points

Find the parameters and .

Algorithm:

(a)  Quantize the parameters space

(b) Each cell in parameter space is an

accumulator.

Initialize all cells to zero.

sincos yx

.,,2,1),,( niyx ii

Page 29: Course 8 Contours. Def: edge list ---- ordered set of edge point or fragments. Def: contour ---- an edge list or expression that is used to represent.

(c) For each data point in image space, increment by 1 each of the accumulator that satisfy the equation.(d) Maximize in the accumulator array correspond to the parameters of the model (line).

),( yx

---- When several curves in images, there will be several peaks in parameter space. It may be difficult to determine which peaks are significant. ---- When the number of parameter increases, the size of parameters space will increase quickly. It will reduce computation speed.