Boundary tracing explained

Boundary tracing, also known as contour tracing, of a binary digital region can be thought of as a segmentation technique that identifies the boundary pixels of the digital region. Boundary tracing is an important first step in the analysis of that region.Boundary is a topological notion. However, a digital image is no topological space. Therefore, it is impossible to define the notion of a boundary in a digital image mathematically exactly. Most publications about tracing the boundary of a subset S of a digital image I describe algorithms which find a set of pixels belonging to S and having in their direct neighborhood pixels belonging both to S and to its complement I - S. According to this definition the boundary of a subset S is different from the boundary of the complement I – S which is a topological paradox.

To define the boundary correctly it is necessary to introduce a topological space corresponding to the given digital image. Such space can be a two-dimensional abstract cell complex. It contains cells of three dimensions: the two-dimensional cells corresponding to pixels of the digital image, the one-dimensional cells or “cracks” representing short lines lying between two adjacent pixels, and the zero-dimensional cells or “points” corresponding to the corners of pixels. The boundary of a subset S is then a sequence of cracks and points while the neighborhoods of these cracks and points intersect both the subset S and its complement I – S.

The boundary defined in this way corresponds exactly to the topological definition and corresponds also to our intuitive imagination of a boundary because the boundary of S should contain neither elements of S nor those of its complement. It should contain only elements lying between S and the complement. This are exactly the cracks and points of the complex.

This method of tracing boundaries is described in the book of Vladimir A. Kovalevsky[1] and in the web site.[2]

Algorithms

Types

Examples

Algorithms used for boundary tracing:[4]

Marching squares extracts contours by checking all corners of all cells in a two-dimensional field. It does not use an initial position and does not generate the contour as an ordered sequence so it does not 'trace' the contour. Has to check each cell corner for all four neighbors but since the checks are independent performance can be easily improved with parallel processing

Square tracing algorithm

The square tracing algorithm is simple, yet effective. Its behavior is completely based on whether one is on a black, or a white cell (assuming white cells are part of the shape). First, scan from the upper left to right and row by row. Upon entering your first white cell, the core of the algorithm starts. It consists mainly of two rules:

Keep in mind that it matters how you entered the current cell, so that left and right can be defined.

public void GetBoundary(byte[,] image)

public void SquareTrace(Point start)

private Point GoLeft(Point p) => new Point(p.y, -p.x);private Point GoRight(Point p) => new Point(-p.y, p.x);

Radial sweep

The Radial Sweep algorithm, often discussed in literature alongside its more commonly known counterpart, Moore-Neighbor Tracing, presents a seemingly straightforward approach to contour tracing in image processing. While the algorithm's nomenclature may evoke a sense of complexity, its underlying principle aligns closely with the familiar Moore-Neighbor Tracing technique.

Moore-Neighbor Tracing, a prevalent method for delineating boundaries within digital images, navigates the Moore neighborhood of a designated boundary pixel in a predetermined direction, typically clockwise. Upon encountering a black pixel, it designates this pixel as the new boundary point and proceeds iteratively.

However, the Radial Sweep algorithm, while functionally equivalent to Moore-Neighbor Tracing, introduces a novel perspective on identifying the next black pixel within the Moore neighborhood of a given boundary point.

The algorithm's innovation lies in its approach to pinpointing the subsequent boundary pixel. Upon identifying a new boundary pixel, denoted as P, the algorithm establishes it as the current point of interest. It then constructs an imaginary line segment connecting point P to the preceding boundary pixel. Subsequently, the algorithm systematically rotates this segment about point P in a clockwise direction until it intersects with a black pixel within P's Moore neighborhood.[10] Effectively, this rotational movement mirrors the process of inspecting each pixel surrounding point P in the Moore neighborhood.

By employing this method, the Radial Sweep algorithm offers a distinctive strategy for traversing boundary pixels within digital images. While fundamentally akin to Moore-Neighbor Tracing, its emphasis on rotational exploration introduces an intriguing perspective on contour tracing techniques in image analysis and computer vision applications.

Theo Pavlidis' Algorithm

Theo Pavlidis' Algorithm is a well-known method for contour tracing in binary images proposed, designed to methodically detect and follow the boundaries of related components. The technique starts by locating an initial boundary pixel, which is usually the first black pixel seen while scanning the image from top to bottom and left to right. It begins by examining the vicinity of the current pixel to locate the next boundary pixel, often going in a clockwise orientation to find the next black pixel that makes up the boundary.[11]

The program traces the contour by moving from one border pixel to the next, ensuring that each boundary pixel is only visited once. This systematic technique promotes computing efficiency. The tracing process continues until the algorithm returns to the first border pixel, completing the contour of the item. The approach is reasonably simple to implement, making it a popular choice for a variety of applications such as object detection, shape analysis, and pattern recognition in computer vision and image processing tasks.

Theo Pavlidis' algorithm is renowned for its simplicity, efficiency, and resilience. It can handle a wide range of object shapes and sizes within binary images, making it useful for a variety of image processing applications.

See also

Notes and References

  1. Kovalevsky, V., Image Processing with Cellular Topology, Springer 2021, ISBN 978-981-16-5771-9
  2. http://www.kovalevsky.de, Lecture "Tracing Boundaries in 2D Images"
  3. Seo . Jonghoon . Chae . Seungho . Shim . Jinwook . Kim . Dongchul . Cheong . Cheolho . Han . Tack-Don . Fast Contour-Tracing Algorithm Based on a Pixel-Following Method for Image Sensors . Sensors . March 2016 . 16 . 3 . 353 . 10.3390/s16030353. free . 27005632 . 4813928 . 2016Senso..16..353S .
  4. http://www.imageprocessingplace.com/downloads_V3/root_downloads/tutorials/contour_tracing_Abeer_George_Ghuneim/alg.html Contour Tracing Algorithms
  5. http://www.imageprocessingplace.com/downloads_V3/root_downloads/tutorials/contour_tracing_Abeer_George_Ghuneim/square.html Abeer George Ghuneim: square tracing algorithm
  6. http://www.imageprocessingplace.com/downloads_V3/root_downloads/tutorials/contour_tracing_Abeer_George_Ghuneim/ray.html Abeer George Ghuneim: The Radial Sweep algorithm
  7. http://www.imageprocessingplace.com/downloads_V3/root_downloads/tutorials/contour_tracing_Abeer_George_Ghuneim/theo.html Abeer George Ghuneim: Theo Pavlidis' Algorithm
  8. Vector Algebra Based Tracing of External and Internal Boundary of an Object in Binary Images, Journal of Advances in Engineering Science Volume 3 Issue 1, January–June 2010, PP 57–70 http://www.publishingindia.com/GetBrochure.aspx?query=UERGQnJvY2h1cmVzfC80NTgucGRmfC80NTgucGRm
  9. Graph theory based segmentation of traced boundary into open and closed sub-sections, Computer Vision and Image Understanding, Volume 115, Issue 11, November 2011, pages 1552–1558 http://www.sciencedirect.com/science/article/pii/S1077314211001676
  10. Reddy . P.Rajashekar . V. . Amarnadh . Mekala . Bhaskar . Evaluation of Stopping Criterion in Contour Tracing Algorithms . International Journal of Computer Science and Information Technologies. January 2012 . 3 . 3 . 3888-3894 . 0975-9646. https://citeseerx.ist.psu.edu/document?repid=rep1&type=pdf&doi=f53cfed7c3584e6e73269ffa83940439ffe3afc9
  11. Reddy . P.Rajashekar . V. . Amarnadh . Mekala . Bhaskar . Evaluation of Stopping Criterion in Contour Tracing Algorithms . International Journal of Computer Science and Information Technologies. January 2012 . 3 . 3 . 3888-3894 . 0975-9646. https://citeseerx.ist.psu.edu/document?repid=rep1&type=pdf&doi=f53cfed7c3584e6e73269ffa83940439ffe3afc9