A collection of files for path tracing is intended for detecting an external border of spots ? simply connected black pixels sets, computing various data for each spot and for the whole image, extracting spots and fragmentation an image.
A c c e p t data: a file with an image or an appropriate array. If accept image (file) 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.
Main o u t p u t: two matrices of n columns. Each column contains coordinates of spot border pixels (the first matrix is one of the first coordinates and the second one is of the second coordinates), where n is a count of spots, image files with separate spots (with a size of minimal rectangle) and group of spots (a size of file is equal to the one of a source image).
Other o u t p u t s:
for each spot:
o coordinates (position in input array) of points of optimal location (centers of mass) for a spot and a spot border (the mass of each pixel are supposed to be all equal). Optimal location means that sum of distances from all points under consideration to this point is minimal;
o border length as number of external edges of border pixels;
o perimeter as length of line connected centers of border pixels;
o coordinates (position in output arrays) of the most remote pixels and distance between them;
o a number of black pixels in a spot and its border;
o coordinates of ends of diagonal of minimal rectangle which includes a spot (sides of rectangle are supposed to be parallel to axes).
For all spots:
o coordinates (position in input array) of point of optimal location (center of mass) for all spots and for all spots? borders;
o borders length as number of external edges of all border pixels;
o sum of perimeters as sum of lengths of lines connecting centers of border pixels;
o coordinates of the most remote pixels and distance between them for image;
o a number of black pixels of all spots and their borders.
Any type of image fragmentation is available with use of logical operations.
There are options for some types of fragmentation of an image:
to get an image file for each spot (with a size of minimal rectangle);
to get an image file with a group of spots:
o delete first k spots, save the rest and each spot;
o save image with spots from #k to #k + m, m>=0.
Single pixel spots in image are ignored.
If there are ?rays? ? single pixel?s width lines are connected or not connected to borders you are advised to delete them by virtue of specific procedure. 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.
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 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.
There some details below:
[X Y]=digisn(alfa) - alfa - string, name of the image file with spots or 2D-array, or 3D-array (color).
X, Y - matrices of spots? borders coordinates;
[X, Y, C]=digisn(...) - C - matrix of measurements? results (n+1)x15; n -is a number of spots (which is detected during computation); C(i, : ) is for a spot number i, i = 1, 2, ..., n; C(n+1, : ) is for whole image.
For more details type ?help digisn? in matlab command window after loading the collection of files into appropriate directory.
Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.