Parametric curves such as Bézier and B-splines, originally developed for the design of automobile bodies, are now also used in image processing and computer vision. For example, reconstructing an object shape in an image, including different translations, scales, and orientations, can be performed using these parametric curves. For this, Bézier and B-spline curves can be generated using a point set that belongs to the outer boundary of the object. The resulting object shape can be used in computer vision fields, such as searching and segmentation methods and training machine learning algorithms. The prerequisite for reconstructing the shape with parametric curves is to obtain sequentially the points in the point set. In this study, a novel algorithm has been developed that sequentially obtains the pixel locations constituting the outer boundary of the object. The proposed algorithm, unlike the methods in the literature, is implemented using a filter containing weights and an outer circle surrounding the object. In a binary format image, the starting point of the tracing is determined using the outer circle, and the next tracing movement and the pixel to be labeled as the boundary point is found by the filter weights. Then, control points that define the curve shape are selected by reducing the number of sequential points. Thus, the Bézier and B-spline curve equations describing the shape are obtained using these points. In addition, different translations, scales, and rotations of the object shape are easily provided by changing the positions of the control points. It has also been shown that the missing part of the object can be completed thanks to the parametric curves.

Computer graphics and geometric modeling are based on curves [

Reconstruction of an object in an image, with a different translation, scaling, or orientation can be performed using parametric curves such as Bézier and B-splines. For this, curve equations need to be revealed using the set of points representing the object’s shape. The points that will be used to define the parametric curve that reconstructs the object shape must be sequential. Traditional edge detection algorithms find object edges, but the resulting points are often not sequential. In this study, a novel contour tracing algorithm has been developed that sequentially obtains the object boundary points. The proposed algorithm, unlike the methods in the literature, is implemented using a filter containing weights and a circle surrounding the object in the image. The contributions of this study to the literature can be summarized as follows:

Since the control points used in parametric curves such as Bézier and B-splines must be sequential, a new contour tracing algorithm has been developed that sequentially obtains the object boundary points to reconstruct the object shape,

The proposed algorithm introduces a new approach by using a filter that generates unique values for the algorithm to determine the boundary points and the next direction of movement,

For tracing an entire object boundary consisting of more than one open curve, a circle is used that surrounds the object, providing a starting point for each segment,

Bézier and B-spline curves are defined using the sequential outer boundary points obtained with the developed contour tracing algorithm,

The performances of Bézier and B-spline curves in reconstructing the object shape with a different translation, scaling, or orientation and the superiority of B-spline have been experimentally demonstrated,

It has been shown that the deformations on the outer boundary of the object in the image due to different reasons can be eliminated using parametric curves such as Bézier and B-splines.

Our proposed algorithm obtained better tracing results than Moore’s method while close to the findContours algorithm.

Parametric representations can be considered as the movement of a point in a certain time interval. Therefore, in the definition of such a curve, the curve is a set of positions based on the continuous time variable. Parametric curves do not require much memory as well as provide convenience in manipulating the surface shapes. For these reasons, parametric curves and surfaces are highly preferred in surface modeling, especially in the field of Computer-Aided Design (CAD) and Computer Aided Manufacturing (CAM) [

Bézier curves were first developed by Paul de Faget de Casteljau and Pierre Bézier to obtain smooth surfaces suitable for modeling automobiles [_{i}_{0}, P_{1}, P_{2},_{3}

The B-spline proposal for curves and surfaces was first introduced by Isaac Jacob Schoenberg and developed by Richard Riesenfeld, pioneering its use in CAD and CAM [

The appropriate order (

The mathematical representation of B-spline curves is given in

B-spline curves are calculated using Cox-de Boor functions.

In order to define an object shape with a curve equation, the points belonging to the outer boundary must be obtained sequentially depending on the neighborhood relations. Widely used edge detection methods such as Canny, Sobel, and Prewitt [

In scoring method, the input is a binary image with a background and object consisting of black (value 0) and white (value 1) pixels, respectively. The calculation of the unique

Contour tracing is basically a morphological image processing concept and deals with tracing the boundaries generally in binary images. In such tracing algorithms, defining start-stop criteria, labeling boundary points, and determining the next moving directions are the main issues to be considered. Problems with identifying neighboring pixels, unnecessary and repetitive movement, and detecting stop criteria are the main challenges in these algorithms. In this study, the binary image to be processed has intensity values of 0 and 1 for the background and object pixels, respectively. While processing the image, an intensity value of 0.5 was assigned to the detected contour points. In a particular filter position, each point at the 2 × 2 region may have one of the three density values as 0, 1, or 0.5. Therefore, 3^{4 }= 81 different neighborhood cases occur, some of which are shown in

There are two terms related to tracing action: tracing direction and tracing movement. Tracing direction refers to the main path of tracing, such as clockwise (CW) and counterclockwise (CCW). Tracing movement, on the other hand, determines the next pixel to be traced in the right, down, left, or up direction while at a certain position in the image. Determining the next movement and the pixel to be labeled depends on the tracing direction. CW and CCW are the two tracing directions. Most neighborhood cases at filter locations were not encountered during contour tracing. Therefore, possible encountered 2 × 2 image pixel values for four tracing movements (right, down, left, and up) and stopping cases in CW and CCW tracing are given in

Two arrays, named SCOREandINDEX and DRCandLBL, were used to maximize the computational speed of simultaneous tracing and labeling. The structures of the arrays used in the tracing algorithm are shown in

CW | Right | 1, 2, 6, 10, 18, 22, 26, 34, 42 |

Down | 4, 8, 24, 40, 72, 88, 104, 168 | |

Left | 16, 32, 33, 96, 97, 160, 161, 162 | |

Up | 64, 128, 129, 130, 132, 133, 134, 136, 138 | |

CWW | Right | 64, 128, 132, 144, 148, 160, 164, 168 |

Down | 1, 2, 18, 34, 66, 82, 130, 146, 162 | |

Left | 4, 8, 9, 10, 72, 73, 74, 136, 138 | |

Up | 16, 32, 33, 36, 37, 40, 41, 42 | |

Stop | 5, 17, 20, 21, 25, 65, 68, 69, 70, 80, 81, 84, 100, 145 |

Movement direction | Index | Tracing step | Pixel position to label | ||||
---|---|---|---|---|---|---|---|

CW | CCW | ||||||

Row | Column | Row | Column | Row | Column | ||

Right | 0 | 0 | 1 | 1 | 1 | 0 | 1 |

Down | 1 | 1 | 0 | 1 | 0 | 1 | 1 |

Left | 2 | 0 | −1 | 0 | 0 | 1 | 0 |

Up | 3 | −1 | 0 | 0 | 1 | 0 | 0 |

In the closed-loop path case, the tracing is executed CW or CCW along the outer boundary and ends when the starting point is reached. In the open-loop path case, tracing is mostly performed in two steps, as the starting point may not be the first point of the boundary. Therefore, tracing is done for the first part of the path until the stopping criterion is met, and then the remaining part is followed in the reverse direction from the starting point. Thus, in any open-loop case, the boundary points can be obtained sequentially, no matter which point is chosen as the starting point. In

The scoring algorithm fails in case of more than one discontinuity caused by deformation at the outer boundaries of objects due to reflection or different shooting angles. As seen in the result in

We suggested that possible starting points of object boundary segments could be reached from the outside of the object in a circular manner with certain angle intervals. The circle surrounding the object and the search directions to find the first edge points are shown in

The radius (_{x}_{y}_{x}_{y}

Correct positioning of the filter window for the starting point is crucial for proper tracing. The leftmost point of the filter window should be located at (_{0}_{0}

Although the angular search method can be used for tracing purposes as well as starting point detection, it produces incomplete results for hard samples, similar to the scoring method. Therefore, we used the angular approach only for detecting the starting points of segments. It is seen in

In this section, experiments for reconstructing the object shape with Bézier and B-spline curves using the object boundary points obtained sequentially by our contour tracing algorithm are explained. If the original image containing the object to be traced is a color image, then the image is first converted to gray, and then a Gaussian filter is used to smooth out sharp transitions and remove noise. In addition, the image is converted to binary format using a threshold. Since the proposed contour tracing algorithm is developed by assuming that the object has white pixels, the negative of the image with white background and black object color are taken. After the pre-processing operations, the outer boundary points of the object were obtained sequentially with their positions by following the border points of the object with the proposed algorithm. Then diluting the sequential points, the object’s shape was reconstructed using Bézier and B-spline curves with these positions. These curves were compared in terms of their ability to represent the object’s shape. The flowchart of the preprocessing and reconstruction steps is given in

In this study, the object shape is reconstructed using the border points obtained by the proposed boundary tracing method as control points in parametric curves. The reconstructed and original objects were compared with the area similarity ratio (

The contour tracing algorithm we developed has been compared with other commercially used algorithms. For this, the ratio of boundary points detected by the tracing algorithm to the points of the original object boundary is used. The intersection ratio (

For the first reconstruction experiment, we used a 2D binary image [

By the proposed contour tracing algorithm, the border points of the objects in the image were obtained sequentially. These obtained points were diluted by 90% and 50% and determined as control points for B-spline and Bézier curves, respectively. Using these control points, the shapes of the objects were reconstructed with the parametric curves. The reconstructed object shapes of B-spline and Bézier are given in

Sample | NBP* in tracing algorithm output | NBP (control points) used to create curves | |
---|---|---|---|

B-spline | Bézier | ||

500 | 50 | 250 | |

510 | 51 | 255 | |

410 | 41 | 205 | |

550 | 55 | 275 |

Note: *Number of boundary points.

One of the methods used to measure the similarity between two closed curves is area similarity. In this study, in order to compare the area similarity, first, the object boundary points were obtained from the original object images (

Object sample | Tracing algorithm | B-spline curve | Bézier curve | ||||
---|---|---|---|---|---|---|---|

NP* | NP | (AS%) | NP | (AS%) | NP | (AS%) | |

7864 | 7864 | 100 | 7688 | 97.76 | 7258 | 92.29 | |

11327 | 11327 | 100 | 11163 | 98.55 | 10774 | 95.12 | |

6504 | 6504 | 100 | 6335 | 97.4 | 6033 | 92.76 | |

10383 | 10383 | 100 | 10128 | 97.54 | 9489 | 91.39 | |

Average | 100 | 97.81 | 92.59 | ||||

Standard deviation | 0 | 1.51 | 1.59 |

Note: *Number of points in the area.

In computer vision, it may be necessary to segment objects and reconstruct them in different scales and orientations. Using parametric curves, reconstruction operations, including a different translation, scaling, and rotation can be easily performed with less memory requirement. Translation, scaling, and rotation operations are performed by changing the locations of the control points selected from the boundary points. Scaling is a linear transformation that enlarges or reduces images by a scale factor that is the same in all directions. In this context, it is realized by moving the control points away from or closer to the object center. In the process of rotation, as in the scaling process, all control points are rotated with a certain angle relative to the object center. In the translation process, control points are simply shifted to a certain pixel distance. In this study, the reconstruction results obtained by applying scaling and rotation together of an object [

Deformations may occur at the borders of the objects in the image due to different reasons, such as reflection or shooting angles. In this study, firstly, B-spline and Bézier curves were created by using the control points selected as linearly distributed from the object boundary obtained by the algorithm we proposed. Then, manually created boundary deformation was eliminated by using these curves.

The shape reconstruction process has some challenging issues. The main challenges are:

To reconstruct the shape with parametric curves such as B-spline and Bézier, the object boundary points must be sequential. The outputs of the existing commercial contour tracing functions are not sequential. Therefore, in this study, an algorithm that obtains the boundary points sequentially has been developed.

The resulting points should belong to the outer boundaries that determine the object’s shape. Since most of the existing functions also find points belonging to the internal texture of the object, the points obtained by these functions cannot be used as control points for parametric curves.

Compared to the original, it requires a certain number of points to reconstruct the shape with satisfactory quality. The fewer control points used, the less representativeness of the reconstructed shape. On the other hand, using more points will increase the computational and memory cost.

In order to determine the processing time performance of the algorithm we developed, it was compared with findContours [

To measure the boundary tracing performance of the proposed algorithm, 250 cancer cell images [

Object sample | Moore | findContours | Proposed algorithm | |||
---|---|---|---|---|---|---|

NBP* | NBP | (IP%)** | NBP | (IP%) | NBP | (IP%) |

462 | 227 | 49.13 | 460 | 99.57 | 461 | 99.78 |

381 | 192 | 50.39 | 381 | 100.00 | 381 | 100.00 |

711 | 696 | 97.89 | 709 | 99.72 | 710 | 99.86 |

415 | 414 | 99.76 | 413 | 99.52 | 414 | 99.76 |

429 | 428 | 99.77 | 427 | 99.53 | 428 | 99.77 |

478 | 477 | 99.79 | 477 | 99.79 | 477 | 99.79 |

500 | 499 | 99.80 | 500 | 100.00 | 500 | 100.00 |

379 | 379 | 100.00 | 379 | 100.00 | 379 | 100.00 |

463 | 463 | 100.00 | 463 | 100.00 | 463 | 100.00 |

240 | 240 | 100.00 | 240 | 100.00 | 240 | 100.00 |

Average | - | 89.65 | - | 99.81 | - | |

Standard deviation | - | 21.03 | - | 0.21 | - | |

Average of 250 pictures | - | 90.43 | - | 99.97 | - | |

Standard deviation | 23.90 | 0.10 |

Note: *NBP = Number of boundary points.

Parametric curves are frequently preferred in many fields, such as image processing, CAD, and CAM, especially computer graphics. Parametric curves such as Bézier and B-spline are defined by a series of points called control points. The sequence of these control points also determines the shape of the curve. Therefore, a new contour tracing algorithm is proposed to sequentially obtain the points of the outer boundary of the object. The proposed algorithm, unlike the methods in the literature, is implemented by using a filter containing weights and a circle surrounding the object in the image. The algorithm consists of three main parts: detecting the starting points of tracing, following the boundary, and stopping the tracing. The starting point for tracing is determined by scanning along a line in the direction of the center from the circle surrounding the object, and then contour tracing is performed with the scoring method. The computational time of the contour tracing algorithm was dramatically reduced as all possible values generated by filtering and the corresponding moving direction and labeling information are pre-recorded in an array. With the proposed algorithm, the boundary points of the objects were obtained sequentially, and these points were diluted to form control points for Bézier and B-spline. Finally, the object shapes were reconstructed using B-spline and Bézier, including a different translation, scaling, and orientation.

According to the developed tracing algorithm results, the tracing algorithm can successfully follow the entire boundary of the object even in the presence of more than one discontinuity. The areas formed by the curves obtained using B-spline and Bézier were compared with the original object area. B-spline results were found to represent the object better than Bézier. It has also been demonstrated that B-spline requires much fewer control points for reconstruction compared to Bézier. In addition, the reconstruction outputs obtained with the Bézier showed more deformation at the boundaries compared to the B-spline. While B-spline can provide local change, Bézier allows only global control. Operations such as adding, deleting, or relocating a control point to the curve affect the entire curve in Bézier but only a small part of the curve in B-spline. Therefore, Bézier curves cause much loss in the boundary details of the object, while B-spline curves better represent the object boundary. On the other hand, it has been shown that the deformations caused by different reasons on the border of the object can be eliminated by using Bézier and B-splines, which are created using the control points obtained with the boundary tracing algorithm. According to the comparison results made with findContours and Moore algorithms in the OpenCV library, which are widely used in computer vision applications, our algorithm performs better than the Moore method and is close to the findContours algorithm in terms of border tracing.

The authors received no specific funding for this study.

The authors declare that they have no conflicts of interest to report regarding the present study.