Pls check the macro step by step.
The Distance Map shows for every pixel (point) inside the crack the distance to its outer contour (edge of the crack). ok?
Obviously this distance has its maximum in the middle of crack. (see image ‘dist’). This maximum values are interesting for you because they show the distance of the middle line to the counter (or in other words the half width of crack) along the crack.
So how to find the maximum line?
This can easily be done with the function Skeletonize. Skeletonize exactly delivers this maximum line.
But the skeleton image only shows the position of the line and does not contain distance information. Therefore I changed the skeleton image to a binary image with intensity 0 for background and intensity 1 for points on the line (this is done by run(“Divide…”) ).
Then I multiplied the distance information in ‘dist’ with the line position in ‘skel’. So all the background and all values of the crack are eliminated (multiplied by 0) and only the values of the middle line/maxmimum line remain unmodified in the image (multiplied by 1).
The resulting image shows the distance (half width of crack) along the middle line of the crack.
How can you analyse the data?
All the information can be derived from the image histogram.
- The number of pixels with intensity > 0 are a representation of the cracks length.
- The maximum of the histogram is a representation of the maximum of the half-width of the crack.
The mean value of all pixels with intensity > 0 is a representation of the mean value of the half-width of the crack.
Those values can be calculated from the histogram array in the macro and can be used to compare the different cracks. ok?
(For more information on how to work with macro and arrays please see the macro examples and macro language documentation.)
(Advanced: Even the progression of the width along the crack could be calculated from this kind of result images.)