Boundary tracing

Last updated

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.

Contents

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.

publicvoidGetBoundary(byte[,]image){for(intj=0;j<image.GetLength(1);j++)for(inti=0;i<image.GetLength(0);i++)if(image[i,j]==255)// Found first white pixelSquareTrace(newPoint(i,j));}publicvoidSquareTrace(Pointstart){HashSet<Point>boundaryPoints=newHashSet<Point>();// Use a HashSet to prevent double occurrences// We found at least one pixelboundaryPoints.Add(start);// The first pixel you encounter is a white one by definition, so we go left.// In this example the Point constructor arguments are y,x unlike convention// Our initial direction was going from left to right, hence (1, 0)PointnextStep=GoLeft(newPoint(1,0));Pointnext=start+nextStep;while(next!=start){// We found a black cell, so we go right and don't add this cell to our HashSetif(image[next.x,next.y]==0){next=next-nextStep;nextStep=GoRight(nextStep);next=next+nextStep;}// Alternatively we found a white cell, we do add this to our HashSetelse{boundaryPoints.Add(next);nextStep=GoLeft(nextStep);next=next+nextStep;}}}privatePointGoLeft(Pointp)=>newPoint(p.y,-p.x);privatePointGoRight(Pointp)=>newPoint(-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. [10]

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

Related Research Articles

<span class="mw-page-title-main">Rendering (computer graphics)</span> Process of generating an image from a model

Rendering or image synthesis is the process of generating a photorealistic or non-photorealistic image from a 2D or 3D model by means of a computer program. The resulting image is referred to as the render. Multiple models can be defined in a scene file containing objects in a strictly defined language or data structure. The scene file contains geometry, viewpoint, textures, lighting, and shading information describing the virtual scene. The data contained in the scene file is then passed to a rendering program to be processed and output to a digital image or raster graphics image file. The term "rendering" is analogous to the concept of an artist's impression of a scene. The term "rendering" is also used to describe the process of calculating effects in a video editing program to produce the final video output.

<span class="mw-page-title-main">Flood fill</span> Algorithm in computer graphics to add color or texture

Flood fill, also called seed fill, is a flooding algorithm that determines and alters the area connected to a given node in a multi-dimensional array with some matching attribute. It is used in the "bucket" fill tool of paint programs to fill connected, similarly-colored areas with a different color, and in games such as Go and Minesweeper for determining which pieces are cleared. A variant called boundary fill uses the same algorithms but is defined as the area connected to a given node that does not have a particular attribute.

<span class="mw-page-title-main">Ray tracing (graphics)</span> Rendering method

In 3D computer graphics, ray tracing is a technique for modeling light transport for use in a wide variety of rendering algorithms for generating digital images.

In computer graphics, photon mapping is a two-pass global illumination rendering algorithm developed by Henrik Wann Jensen between 1995 and 2001 that approximately solves the rendering equation for integrating light radiance at a given point in space. Rays from the light source and rays from the camera are traced independently until some termination criterion is met, then they are connected in a second step to produce a radiance value. The algorithm is used to realistically simulate the interaction of light with different types of objects. Specifically, it is capable of simulating the refraction of light through a transparent substance such as glass or water, diffuse interreflection between illuminated objects, the subsurface scattering of light in translucent materials, and some of the effects caused by particulate matter such as smoke or water vapor. Photon mapping can also be extended to more accurate simulations of light, such as spectral rendering. Progressive photon mapping (PPM) starts with ray tracing and then adds more and more photon mapping passes to provide a progressively more accurate render.

<span class="mw-page-title-main">Digital geometry</span> Deals with digitized models or images of objects of the 2D or 3D Euclidean space

Digital geometry deals with discrete sets considered to be digitized models or images of objects of the 2D or 3D Euclidean space. Simply put, digitizing is replacing an object by a discrete set of its points. The images we see on the TV screen, the raster display of a computer, or in newspapers are in fact digital images.

<span class="mw-page-title-main">Image segmentation</span> Partitioning a digital image into segments

In digital image processing and computer vision, image segmentation is the process of partitioning a digital image into multiple image segments, also known as image regions or image objects. The goal of segmentation is to simplify and/or change the representation of an image into something that is more meaningful and easier to analyze. Image segmentation is typically used to locate objects and boundaries in images. More precisely, image segmentation is the process of assigning a label to every pixel in an image such that pixels with the same label share certain characteristics.

<span class="mw-page-title-main">Quadtree</span> Tree data structure in which each internal node has exactly four children, to partition a 2D area

A quadtree is a tree data structure in which each internal node has exactly four children. Quadtrees are the two-dimensional analog of octrees and are most often used to partition a two-dimensional space by recursively subdividing it into four quadrants or regions. The data associated with a leaf cell varies by application, but the leaf cell represents a "unit of interesting spatial information".

Tracing may refer to:

In computer graphics, image tracing, raster-to-vector conversion or raster vectorization is the conversion of raster graphics into vector graphics.

In computer graphics, marching squares is an algorithm that generates contours for a two-dimensional scalar field. A similar method can be used to contour 2D triangle meshes.

<span class="mw-page-title-main">Moore neighborhood</span> Cellular automaton neighborhood consisting of eight adjacent cells

In cellular automata, the Moore neighborhood is defined on a two-dimensional square lattice and is composed of a central cell and the eight cells that surround it.

Digital topology deals with properties and features of two-dimensional (2D) or three-dimensional (3D) digital images that correspond to topological properties or topological features of objects.

Connected-component labeling (CCL), connected-component analysis (CCA), blob extraction, region labeling, blob discovery, or region extraction is an algorithmic application of graph theory, where subsets of connected components are uniquely labeled based on a given heuristic. Connected-component labeling is not to be confused with segmentation.

The generalized Hough transform (GHT), introduced by Dana H. Ballard in 1981, is the modification of the Hough transform using the principle of template matching. The Hough transform was initially developed to detect analytically defined shapes. In these cases, we have knowledge of the shape and aim to find out its location and orientation in the image. This modification enables the Hough transform to be used to detect an arbitrary object described with its model.

<span class="mw-page-title-main">Watershed (image processing)</span> Transformation defined on a grayscale image

In the study of image processing, a watershed is a transformation defined on a grayscale image. The name refers metaphorically to a geological watershed, or drainage divide, which separates adjacent drainage basins. The watershed transformation treats the image it operates upon like a topographic map, with the brightness of each point representing its height, and finds the lines that run along the tops of ridges.

A chain code is a lossless compression based image segmentation method for binary images based upon tracing image contours. The basic principle of chain coding, like other contour codings, is to separately encode each connected component, or "blob", in the image.

Image segmentation strives to partition a digital image into regions of pixels with similar properties, e.g. homogeneity. The higher-level region representation simplifies image analysis tasks such as counting objects or detecting changes, because region attributes can be compared more readily than raw pixels.

In mathematics, an abstract cell complex is an abstract set with Alexandrov topology in which a non-negative integer number called dimension is assigned to each point. The complex is called “abstract” since its points, which are called “cells”, are not subsets of a Hausdorff space as is the case in Euclidean and CW complexes. Abstract cell complexes play an important role in image analysis and computer graphics.

Vladimir Antonovich Kovalevsky is a physicist. His research interests include digital geometry, digital topology, computer vision, image processing and pattern recognition.

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 (March 2016). "Fast Contour-Tracing Algorithm Based on a Pixel-Following Method for Image Sensors". Sensors. 16 (3): 353. Bibcode:2016Senso..16..353S. doi: 10.3390/s16030353 . PMC   4813928 . PMID   27005632.
  4. Contour Tracing Algorithms
  5. Abeer George Ghuneim: square tracing algorithm
  6. Abeer George Ghuneim: The Radial Sweep algorithm
  7. 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
  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
  10. 1 2 Reddy, P.Rajashekar; V., Amarnadh; Mekala, Bhaskar (January 2012). "Evaluation of Stopping Criterion in Contour Tracing Algorithms". International Journal of Computer Science and Information Technologies. 3 (3): 3888–3894. ISSN   0975-9646.