CONTOURS

Post on 25-Feb-2016

35 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

CONTOURS. BY, Jayesh Raghavan Electrical Engineering Department The University of Texas at Arlington. OVERVIEW. GEOMETRY OF CURVES CONTOUR PROPERTIES CURVE FITING. CONTOUR. Edges : - Significant local changes in image, occur on the boundary between 2 different regions in an image. - PowerPoint PPT Presentation

Transcript

CONTOURS

04/22/23 1Computer Vision

OVERVIEW

GEOMETRY OF CURVESCONTOUR PROPERTIESCURVE FITING

04/22/23 2Computer Vision

CONTOUR

Edges : - Significant local changes in image, occur on the boundary between 2 different regions in an image. Edges are linked into a representation for a region boundary called contour.

The contours correspond to region boundaries.

04/22/23 3Computer Vision

CONTOUR (contd….)

• Can be classified in two ways :-

Closed Contour :-- Correspond to a region boundaries.

Open Contour :-- Part of a region boundary.

04/22/23 4Computer Vision

BIT MORE ON CONTOUR

• A contour is a sequence of 8 – connected pixels in an image where each pixel can be reached from any other pixel in the contour.

• An open contour has two end pixels each with only one neighbor, and zero or more interior pixels, each with exactly two neighbors.

• A closed contour has no end pixels. All pixels in a closed contour have exactly two neighbor

04/22/23 5Computer Vision

BIT MORE ON CONTOUR

• The length of a contour is computed from the sum of distances between adjacent pixels in the contour.

• Two adjacent pixels that lie horizontally or vertically are considered to be apart by 1 pixel. All other adjacent pixels are considered to be apart by 2 pixels.

04/22/23 6Computer Vision

CRITERIA TO REPRESENT A GOOD CONTOUR

• Efficiency – Simple, compact representation.• Accuracy – Fit images features accurately.• Effectiveness – Suitable for the operation

performed in the later stages of the application.

• Accuracy of estimating of edge locations.• Performance of the curve fitting algorithm.

04/22/23 7Computer Vision

WAYS OF REPRESENTING A CONTOUR

• Ordered List:-The simplest representation of contour.

Efficiency – Least compact & simplest. Accuracy – Depends on how accurately edge locations are estimated.

• Curves:-The most powerful representation as it involves fitting a curve having some

analytical description ( Polygonal – curves, lines segments etc…) More compact. Efficient and Accurate.

04/22/23 8Computer Vision

-- FEW DEFINITIONS -- • An Edge list is an ordered set of edge points.• A contour is an edge list or the curve that has

been used to represent the edge list.• A boundary is the closed contour that surrounds

a region.• A curve interpolates a list of points if it passes

through the points.• A curve approximates a list of points if it passes

close to the edge points, but not necessarily passing exactly through them.

04/22/23 9Computer Vision

INTERPOLATION Vs APPROXIMATION

04/22/23 10Computer Vision

INTERPOLATION Vs APPROXIMATION

• A curve interpolates a list of points if it passes through the points.

• A curve approximates a list of points if it passes close to the points, but not necessarily passing exactly through the points.

• Curve interpolation methods are more appropriate when the edges have been extracted accurately.

• In practice, curve approximation methods yield better results because the edge locations can not be extracted very accurately.

04/22/23 11Computer Vision

GEOMETRY OF CURVES

1.Representing a point- Explicit form y = f(x)- Implicit form f(x,y)=0- Parametric form (x(u), y(u))

u is the parameter

2.Length of an arc

2

1

22u

u

dududy

dudx

04/22/23 12Computer Vision

DIGITAL CONTOURS

• The length of a digital contour p1 = (x1, y1), p2 = (x2, y2), ..., pi = (xi, yi) can be approximated by adding the lengths of the individual segments between edge points:

• Distance between end points can be calculated as:

n

iiiii yyxxS

2

21

21 )()(

21

21 )()( xxyyD nn

04/22/23 13Computer Vision

DIGITAL CONTOURS• Slope (tangent) and curvature are difficult to compute

precisely since the angle between neighboring edge pixels is quantized to 45 degrees increments.

• The idea is to compute the slope using edge points that are not adjacent:- left k-slope: the direction between points pi-k and pi- right k-slope: the direction between points pk and pi+k- k-curvature: the difference between the left and right k-slopes.

04/22/23 14Computer Vision

SIMPLE METHODS

• Chain Codes• Crack Codes• Slope Representation• Slope Density Function• Centroidal Profile Representation

04/22/23 15Computer Vision

CHAIN CODES

• Chain-code representationSpecifies the direction of each edge point along the contour.

1)Start at the first edge point and go clockwise around the contour.

2)The direction to the next edge point is specified using one of the four or eight quantized directions.

04/22/23 16Computer Vision

CHAIN CODES

04/22/23 17Computer Vision

CHAIN CODES

chain code: 0033333...0104/22/23 18Computer Vision

LIMITATIONS OF CHAIN CODES

• Chain code of a boundary depends on the starting point.

• Limited set of directions. • Sensitive to noise

04/22/23 19Computer Vision

CRACK CODES

• An alternative to the chain code for contour encoding is to use neither the contour pixels associated with the object nor the contour pixels associated with background but rather the line, the "crack", in between them.

• Directions are quantized into 4 directions.

04/22/23 20Computer Vision

SLOPE REPRESENTATION

• Its an continuous version of chain code.1)Start at the first edge point and go clockwise

around the contour.2)Estimate the slope(y) and arc length(s) using

the formulas given previously for digital contours.

3)Plot the slope versus the arc-length.

04/22/23 21Computer Vision

SLOPE REPRESENTATION

4) Horizontal line in the y-s space correspond to segments in the contour .

5) Line segments at the other orientations correspond to circular arcs.

6) Portions of the plot that are not straight line segments correspond to other curve primitives.

04/22/23 22Computer Vision

SLOPE REPRESENTATION

04/22/23 23Computer Vision

FEW COMMENTS

• Different starting points cause a shift in the s-axis.

• Rotations cause a shift in the Ψ axis.• Not very tolerant to noise.• For a closed contour this plot is periodic.

04/22/23 24Computer Vision

SLOPE DENSITY FUNCTION

• Histogram of the slopes along the contour.• Orientation can be determined using

correlation of slope histograms.• Can be very useful for object recognition.

04/22/23 25Computer Vision

EXAMPLES

00 9090180180270270 360360AngleAngle

Den

sity

Den

sity

00 9090180180270270 360360AngleAngle

Density

Density

SquareSquare DiamondDiamond

00 9090180180270270 360360AngleAngle

Den

sity

Den

sity

00 9090180180270270 360360AngleAngle

Density

Density

CircleCircle EllipseEllipse

00

9090

180180

270270

04/22/23 26Computer Vision

CENTROIDAL PROFILE REPRESENTATION

Plot the distance from the centroid to the boundary as a function of angle.

04/22/23 27Computer Vision

CONTOUR REPRESENTATION USING CURVE FITTING (INTERPOLATION)

• The main assumption when using interpolation is that the edge points have been extracted accurately.

• Errors in edge locations can be handled better using curve-fitting based on approximation.

04/22/23 28Computer Vision

EVALUATING THE GOODNESS OF THE FIT

• Maximum absolute error: measures how much the points deviate from the curve in the worst case.

MAE = maxi |di |

• Mean squared error: gives an overall measure of the deviation of the curve from the edge points.

04/22/23 29Computer Vision

EVALUATING THE GOODNESS OF THE FIT

• Normalized maximum absolute error: the ratio of the maximum absolute error to the length of the curve (error becomes independent of the length of the curve).

NMAE = maxi |di |/L

• Ration of curve length to the end point distance: a good measure of the complexity of the curve.

04/22/23 30Computer Vision

POLYLINE REPRESENTATION

A polyline is a sequence of line segments joined end to end. The ends of each line are edge points in the original edge list. The points where line segments are joined are called vertices.

04/22/23 31Computer Vision

DISTANCE OF POINT FROM LINE

• Equation of line passing from two points (x1, y1), (x2, y2):x(y1 - y2) + y(x1 - x2) + y2 x1 - y1 x2 = 0

• Distance d of edge point (u, v) from the line:d =r/D

• r=u(y1 - y2) + v(x1 - x2) + y2 x1 - y1 x2• D is the distance between (x1, y1) and (x2, y2).

04/22/23 32Computer Vision

CURVE FITTING MODELS

• Straight line segments• Circular arcs• Conic sections• Cubic splines

04/22/23 33Computer Vision

POLYLINE REPRESENTATION TYPES

• Splitting• Merging• Split and Merge Algorithm• Hop-Along Algorithm

04/22/23 34Computer Vision

SPLIT ALGORITHM(top-down) Take the line segment connecting the end points of the

contour (if the contour is closed, consider the line segment connecting the two farthest points).

Find the farthest edge point from the line segment.

If the normalized maximum error of that point from the line segment is above a threshold, split the segment into two segments at that point (i.e., new vertex).

Repeat the same procedure for each of the two sub segments until the error is very small.

04/22/23 35Computer Vision

EXAMPLE (Open Contour)

04/22/23 36Computer Vision

EXAMPLE (Closed Contour)

04/22/23 37Computer Vision

MERGE ALGORITHM (Bottom-Up)Use the first two edge points to define a line segment.

Add a new edge point if it does not deviate too far from the current line segment.

Update the parameters of the line segment using least-squares.

Start a new line segment when edge points deviate too far from the line segment.

04/22/23 38Computer Vision

EXAMPLE

04/22/23 39Computer Vision

SPLIT AND MERGE ALGORITHM• The accuracy of line segment approximations can be

improved by interleaving merge and split operations.

1. After recursive subdivision (split), allow adjacent segments to be replaced by a single segment (merge).

2. Alternate applications of split and merge until no segments are merged or split.

04/22/23 40Computer Vision

EXAMPLE

04/22/23 41Computer Vision

HOP – ALONG ALGORITHMStart with the first k edges from the list.

Fit a line segment between the first and the last edges in the sub list.

If the normalized maximum error is too large, shorten the sub list sub list to the point of maximum error. Return to step 2.

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

04/22/23 42Computer Vision

HOP – ALONG ALGORITHM

Make the current line segment the previous line segment and advance the window of edges so that there are k edges in the sub list. Return to step 2.

04/22/23 43Computer Vision

CIRCULAR ARCS

• Once an edge list has been approximated by line segments, subsequences of the line segments can be replaced by circular arcs.

• This involves fitting circular arcs through the endpoints of two or more line segments.

04/22/23 44Computer Vision

CIRCULAR ARCS (ALGO….)1. Initialize the window of vertices to the three

endpoints of the first two line segments in the polygonal approximation.

2. Compute the ratio of the length of the part of the contour corresponding to the two line segments to the distance between the end points. If the ratio is small, then leave the first line segment unchanged, advance the window of vertices by one vertex, and repeat this step.

3. Fit a circle through the three vertices.

04/22/23 45Computer Vision

CIRCULAR ARCS (ALGO…..)4. If the fit is not good (i.e., normalized maximum error

is too large), then leave the first line segment unchanged, advance the window of vertices, and return to step 2.

5. If the circle fit succeeds, then try to include the next line segment in the circular arc. Repeat this step until no more line segments can be subsumed by this circular arc.

6. Advance the window to the next three polygon vertices after the end of the circular arc and return to step 2.

04/22/23 46Computer Vision

CONIC SECTIONS AND CUBIC SPLINES

• Conic sections correspond to hyperbolas, parabolas, and ellipses (2nd degree polynomials).

• Cubic splines correspond to 3rd degree polynomials.

• Conic sections and cubic splines allow more complex contours to be represented using fewer segments.

04/22/23 47Computer Vision

CONTOUR REPRESENTATION USING CURVE FITTING

• Higher accuracy can be obtained by computing an approximation that is not forced to pass through particular edge points.

• Approximation-based methods use all the edge points to find a good fit (this is contrast to the previous methods that use only the interpolated edge points).

• Methods to approximate curves depend on the reliability with which edge points can be grouped into contours. (1) Least-squares regression can be used if it is certain that the edge points grouped together belong to the same contour.(2) Robust regression is more appropriate if there are some grouping errors.

04/22/23 48Computer Vision

LEAST – SQUARES LINE FIT

• Linear regression fits a line to the edge points by minimizing the sum of squares of the perpendicular distances of the edge points from the line being fit.

i

ii yxX 22 )cossin(

04/22/23 49Computer Vision

• The solution to the linear regression problem is:-

where,

04/22/23 50Computer Vision

LIMITATIONS

• It works well for cases where the noise follows a Gaussian distribution.

• It does not work well when there are outliers in the data (e.g., due to errors in edge linking).

04/22/23 51Computer Vision

ROBUST REGRESSION METHODS

• Outliers can pull the regression line far away from its correct location.

• Robust regression methods try various subsets of the data points and choose the subset that provides the best fit.

04/22/23 52Computer Vision

LEAST – MEDIAN SQUARES REGRESSION

(1) Choose p points at random from the set of n data points.

(2) Compute the fit of the model to the p points.(3) Compute the median of the square of the residuals.(4) Repeat until the median squared error is less than

some threshold, or take the best median error result after some number of runs.

This algorithm can handle up to 50% outliers in the data set.

04/22/23 53Computer Vision

FOURIER DESCRIPTORS

• Fourier coefficients are used to represent a closed contour since they are periodic.

• Boundary of an object is expressed as a sequence of coordinates

• We can represent each co ordinate pair as a complex number so that

• For a closed curve u(n) is periodic

)](),([)( nynxnu

1,....2,1,0),()()( Nnnjynxnu

04/22/23 54Computer Vision

FOURIER DESCRIPTORS • The DFT is given by:

• The inverse DFT is given by:

• The complex coefficients a(k) are called Fourier descriptors (FD) of the boundary

1

0

/2 10,)()(N

k

Nknj Nnekanu

1

0

2

10,)(1)(N

n

Nnkj

NnenuN

ka

04/22/23 55Computer Vision

FOURIER DESCRIPTORS

• Low resolution approximationOnly first M coefficients are used

1

0

2

10,)()(M

k

Nknj

Nnekanu

04/22/23 56Computer Vision

REFERENCES

• Rafael C. Gonzalez, Digital Image Processing• Ramesh C. Jain, et al., Machine Vision

04/22/23 Computer Vision 57

THANK YOU!!!!

04/22/23 58Computer Vision

top related