1 / 50

CONTOURING

CONTOURING. By Ashish V. Deshpande Electrical Engineering Department The University of Texas at Arlington June 21 st 2004. OVERVIEW. Geometry of Curves Contour Properties Curve Fitting. CONTOUR. Edges are linked into a representation for a region boundary called contour

carmela
Download Presentation

CONTOURING

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CONTOURING By Ashish V. Deshpande Electrical Engineering Department The University of Texas at Arlington June 21st 2004

  2. OVERVIEW • Geometry of Curves • Contour Properties • Curve Fitting

  3. CONTOUR • Edges are linked into a representation for a region boundary called contour • Closed Contour • correspond to region boundaries • Open Contour • part of a region boundary • gap in boundary : Edge detection threshold too high , weak contrast

  4. Representing a Contour • Criteria for good representation • Efficiency: Simple, compact representation. • Accuracy: Fit image features accurately. • Effectiveness: Suitable for the operations performed in the later stages of the application • Two ways • Ordered list of edges • Curve (mathematical model of contour eg.Line segments , Cubic splines etc.)

  5. Representing a Contour • Ordered List • Efficiency : least compact & simplest • Accuracy : as accurate as estimate of edge locations • Effectiveness : not good • Curves • Efficiency : increases • Accuracy : as errors in edge detection are averaged • Effectiveness : increases

  6. Some Definitions • A curve interpolates a set of points if it passes through the points • Approximation is fitting a curve passing close to the points but not necessarily through the points • 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.

  7. Geometry of Curves Representing a point Explicit form y = f(x) Implicit form f(x,y)=0 Parametric form (x(u), y(u)) u is the parameter Length of an arc

  8. Contour Properties • Let pi = (xi ,yi) be the coordinates of edge i in the edge list • Estimate the slope using edge points that are not adjacent : • Left k-slope: direction from pi-k to pi • Right k-slope: direction from pi to pi+k • K-curvature: diff. between the left and right k-slopes. • Length of digital curve • Distance between end points • S/D ratio (covered in curve fitting)

  9. Representation using lists • Chain Codes : specifies direction of contour at each edge along the edge list • Directions are quantized • Starting at first edge and going clockwise around the contour the direction is specified using one of the directions

  10. Chain Codes • Example • Limitations • Limited set of directions • Sensitive to noise

  11. Slope Representation • Continuous version of Chain code , also called y-s plot • Algorithm: • Start at the first edge and go clockwise • Estimate slope (y) and arc length (s) • Plot the slope Versus the arc length • Horizontal line segments in y-s space correspond to segments in the contour • Line segments at other orientations correspond to circular arcs • Portions of the plot that are not straight line segments correspond to other curve primitives

  12. An Example

  13. Centroidal Profile Representation • Plot the distance from the centroid to the boundary as a function of angle

  14. Curve Fitting • Four Models • Line Segments • Circular arcs • Conic sections • Cubic splines • Note: We proceed with the basic assumption that the edge locations are sufficiently accurate that selected edge points can be used to determine the fit. We will later consider methods based on approximation that can handle such errors.

  15. Goodness of a fit • Let di be the distance of edge point i from line. • Maximum absolute error : measures how much the points deviate from the curve in the worst case. • Mean squared error : gives an overall measure of the deviation of the curve from the edge points.

  16. Goodness of a fit contd… • 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 ,i.e unitless ). • Ratio of curve length to the end point distance: a good measure of the complexity of the curve. • Number of Sign Changes: in the error is a good indicator of the appropriateness of the curve as a model for the edges in the contour.

  17. Curve fitting methods • The use of straight line segments (polylines) is appropriate if the image consists of straight lines. It is the starting point for fitting other models. • Circular arcs are a useful representation for estimating curvature • Conic sections provide a convenient way to represent sequences of line segments and circular as well as elliptic and hyperbolic arcs . • Cubic splines are good to model smooth curves

  18. 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. • A quick revision • Equation of line passing from two points (x1, y1), (x2, y2): • Distance d of edge point (u, v) from the line: • D is the distance between (x1, y1) and (x2, y2).

  19. Polyline Representation types • Splitting • Merging • Split and Merge Algorithm • Hop-Along Algorithm

  20. Splitting (Top Down) • Algorithm : (1) 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) (2) Find the farthest edge point from the line segment (3) 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) (4)Repeat the same procedure for each of the two subsegments until the error is very small.

  21. Example (Open Contour)

  22. Example (Closed Contour)

  23. Merging (Bottom Up) • Algorithm : (1) Use the first two edge points to define a line segment. (2) Add a new edge point if it does not deviate too far from the current line segment. (3) Update the parameters of the line segment using least- squares. (4) Start a new line segment when edge points deviate too far from the line segment.

  24. Tolerance Band • Algorithm: (1) Two line segments that are parallel to the line segment approximating the edge at a distance e from the center are computed. (2) Edges are added to the current line segment as long as the new edges are inside the tolerance band. (3) The parameters of the line segment are recomputed as the edges are added to the segment. (4) The vertex at the end of the segment is the starting point for the next segment

  25. Example

  26. Split and Merge • The accuracy of line segment approximations can be improved by interleaving merge and split operations. • Algorithm: (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.

  27. Example

  28. Hop Along Algorithm 1. Start with the first k edges from the list. 2. Fit a line segment between the first and the last edges in the sub list. 3. If the normalized maximum error is too large, shorten the sub list to the point of maximum error. Return to step 2. 4. 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. 5. Make the current line segment the previous line segment and advance the window of edges so that there are k edges in the sublist. Return to step 2.

  29. Circular arcs • Subsequences of the line segments can be replaced by circular arcs if desired. Replacing by arcs involves fitting circular arcs through the end points of two or more line segments, i.e. fitting is done on vertices in the polyline • The circular arc is a fit between the first and last end points and one other point. There can be several methods depending on how the middle point is chosen .

  30. Replacing line segments with arcs • Algorithm: 1.Initialize the window of vertices to the 3 end points of the first 2 line segments in the polyline. 2.Compute the ratio of the length of the part of the contour corresponding to the 2 line segments to the distance between the end points. If the ratio is large 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 3 vertices. 4.Calculate the normalized error and number of sign changes.

  31. Contd… 5. If the normalized maximum error is too large or the number of sign changes is too small then leave the first line segment unchanged, advance the window of vertices and return to step 2. 6.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 sub-summed by this circular arc. 7.Advance the window to the next 3 polyline vertices after the end of the circular arc and return to step 2.

  32. Error Calculation • To calculate error in fitting a circular arc , define distance of point Q (x1, y1) from the circle along a line passing through the center (x0, y0) • q = The distance from Q to the circular arc is d=q - r

  33. Conic Sections & 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. • Conic sections can be fit between three vertices in the polyline approximation.

  34. Conic section between three points

  35. Curve Approximation • 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. (3) If grouping cannot be done easily using edge linking or following methods , then cluster analysis techniques like Hough transform are used

  36. 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.

  37. Some math…(solution to the regression problem)

  38. Limitations • It works well for cases where the noise follows a Gaussian distribution. • It does not work well when there are outliers (edge points incorrectly linked to the contour) in the data (e.g., due to errors in edge linking ).

  39. Robust Regression • 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.

  40. Least - Median Suares Regression • Algorithm: (assume that there are n data points and p parameters in the model) (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.

  41. Hough Transform • Voting mechanism • Each point on the curve votes for several combinations of parameters, the parameters that win a majority of votes are winners • This technique assumes that a primitive edge detection is already performed on an image

  42. The technique • Consider the equation of a straight line y= mx +c • Rewriting the equation c= y – mx • Let us assume that m and c are variables of interest and x and y are constants. The above equation represents a line in m-c space. • A point (x,y) corresponds to line in m-c space • If there are n points lying on the straight line (in x-y plane), then these will correspond to a family of lines in parameter space all passing through (m,c). This point gives parameters of original straight line

  43. Hough Transform Algorithm • Quantize the parameter space appropriately • Assume that each cell in the parameter space is an accumulator. Initialize all cells to zero. • For each point (x,y) in the image space , increment by 1 each of the accumulators that satisfy the equation • Maxima in the accumulator array correspond to the parameters of model instances • If the peak in the parameter space covers more than 1 accumulator then the centroid of the region gives an estimate of the parameters

  44. A Demonstration • The data is given on the left. The result of the Hough transform is a bright orange box on the right of the figure (the Hough space) which is the result of a large number of counts for that accumulator.

  45. Limitations • Size of discrete parameter space increases exponentially as number of parameters increases hence Hough transform may be computationally very inefficient for complex models

  46. 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 • DFT • IDFT

  47. Fourier Descriptors (contd..) • The complex coefficients a(k) are called Fourier descriptors (FD) of the boundary • Low resolution approximation • Only first M coefficients are used

  48. Summary Contour Representation Using Interpolation Using Edge list Using Curve fitting Using Approximation Using Regression Using Hough Transform Using Fourier Descriptors

  49. References • Rafael C. Gonzalez, Digital Image Processing • Ramesh C. Jain, et al.,Machine Vision • Adrian Low, Introductory Computer Vision and Image Processing

  50. Thank You !!

More Related