version 1.0.0.0 (73.2 KB) by
Eduard Polityko

Path tracing for 1- and 2-connected pixel sets. Elimination of intersection points and dead ends.

Path Tracing, Measurements, Fragmentation for Doubly-Connected Spot

A collection of files for path tracing is intended for detecting external and internal borders of spot ? doubly-connected black pixels set, computing various data for it and its borders. Traces are built without intersections thus they contain only different points except for the first and the last ones. If it is impossible to trace borders without intersections an output contains path tracing results after elimination of intersection points and dead ends. Input data might be both an image and a numeric matrix. If input data are a simply-connected spot a warning would appear and an output contains data of a single border tracing.

I n p u t data: a file with an image or an appropriate array. If input image (array) is color or grayscale one (has values not only 0 and 1), then Path Tracing application transforms it into logical (binary) one. Threshold for binarization is mean intensity value (default) or one of a user choice just as use of specific procedure for stand alone pixels and one pixel width lines elimination.

Main o u t p u t: 1) a matrix of four columns and n strings. The first column contains the first coordinates of external border pixels, the second one contains second coordinates and the third and the fourth columns contain the same of internal border. n is a number of pixels of the longest border (the last point is taken in account). The shortest border coordinates are zero-padded to n.

Other o u t p u t s:

1. for each border:

1.1 coordinates (position in input array) of points of optimal location (centers of mass where the mass of each border pixel are supposed to be all equal). Optimal location means that sum of distances from all points under consideration to this point is minimal;

2.1 perimeter number of external (internal) edges of border pixels;

3.1 perimeter as length of line connecting centers of border pixels;

4.1 coordinates (position in appropriate columns of output matrix) of the most remote pixels and distance between them;

5.1 a number of black pixels in border;

6.1 coordinates of ends of diagonal of minimal rectangle which includes a border (sides of rectangle are supposed to be parallel to axes).

2. For spot:

1.2 coordinates (position in input array) of point of optimal location (center of mass);

2.2 a number of spot pixels

3.2 coordinates (position in appropriate columns of output matrix) of the most remote pixels of internal and external border and distance between them;

4.2 the same for the proximal points of borders and distance between them. This distance might be considered as distance between two sets.

3. An array containing fragments of binarized image. They are traced part and binarized image without this part, dead ends and intersection points.

The application could be used in image processing, image recognition, measurements etc. and does not require an Image Processing Toolbox.

In order to find the first point of spot external border (starting pixel) we move from the image matrix left upper corner along the first column until the value of matrix element is not equal zero. If there is no zero elements in the first column then repeat detecting for the second one and so on. Then we move along the border clockwise. It means that we move along black pixels and must always have a white pixel on the left hand side.

If starting pixel is a part of dead end a tracing is impossible and use of specific procedure is needed. This procedure does not delete vertices of polygons as it does "spur" option of "bwmorf" function of Image Processing Toolbox. Time of path tracing significantly increases.

There are some details below:

[A B C]=rzrzc(alfa) - alfa - string, name of the image file with spots or 2D-array, or 3D-array (color).

A - matrix nx4 of spot borders coordinates; n - is a number of the longest border pixels (which is detected during computation);

B - matrix 15x3 of measurements? results;

C - a copy of input image matrix without points of intersection and dead ends.

[?]=rzrc(alfa,?,1) ? for use of "cleaning" procedure.

For more details type:

help rzrzc

(in matlab command window after loading the collection of files into appropriate directory).

Eduard Polityko (2020). Path Tracing, Measurements, Fragmentation for Doubly-Connected Spot (https://www.mathworks.com/matlabcentral/fileexchange/14830-path-tracing-measurements-fragmentation-for-doubly-connected-spot), MATLAB Central File Exchange. Retrieved .

Created with
R2006a

Compatible with any release

**Inspired by:**
Spot Border Detection, Path Tracing, Measuarement, Fragmentation, Calculation of distance between strings, Calculation of Pareto points

**Inspired:**
Spot Border Detection, Path Tracing, Measuarement, Fragmentation, Calculation of distance between strings, Calculation of Pareto points

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!Create scripts with code, output, and formatted text in a single executable document.