Measure cracks on shingles

Sample image and/or code

Background

The image represent a roof asphalt shingle with a crack (the black line on the center).

Analysis goals

I’m trying to isolate the cracks we see on the image and to measure the total length.

Challenges

The challenge is to isolate the crack over all the granules. I’ m probably too new with ImageJ to find the right recipe!

Hi
@Tessar1981

Welcome to this forum.

I invite you to read this:Concrete Crack Width Detection
You will have other possibilities of reading by using the search engine with the keywords:concret crack

I give you a result.

Check that you have the RGB to CMYK plug-in


macro "Measure cracks on shingles"
{

requires("1.53e");
setBackgroundColor(0,0,0);
setOption("BlackBackground",true);
img=getImageID();
// Start batch mode
setBatchMode(true);
selectImage(img);
run("Duplicate...", "title=1");
close("\\Others");
run("Duplicate...", "title=2");
selectImage("1");
// Start processing
run("Enhance Contrast...", "saturated=10 equalize");
run("Invert");
run("RGB to CMYK");
selectWindow("CMYK_1");
run("Stack to Images");;
close("M");
close("Y");
close("K");
//setTool("wand");
doWand(385, 385, 0.1, "Legacy");
roiManager("Add");
roiManager("Select", 0);
selectImage("2");
run("Restore Selection");
// End of processing
// End of batch mode
setBatchMode(false);
exit("End");
}

Hope this helps.

Thanks @Mathew.

Yes it helps. I also read the topic on concrete crack. And I apologize for my ignorance since I’m just beginning to use the software deeper. The macro is running pretty well. The only thing remaining to do is t measure a total length of a, lets say, a centerline of the ROI.

Again, thanks a lot!

@Tessar1981
What does “[quote= “Tessar1981, post:3, topic:43470”]
measure a total length of a, lets say, a centerline of the ROI
[/quote]”
mean to you?
Maybe this?


If so then let the me know.

@Mathew,
My explanation was probably not so clear :thinking:. My need is something more like the yellow path on the picture. Cracks on a shingle can have many different forms. It can be straight, curved, in circle or, like on our example, have various forms. The interest is to have a single length of the combine branch which could be like the yellow lines. I know the “skeletonize” function, but the tests I did was not convincing…

It may be worthwhile looking at MorpholibJ. Measurements such as geodesic diameter may be relevant to your problem.

@Tessar1981

Check that you have the “Ridge detection” plug-in.
I get this with your registered image.

I am using this macro. It is not very clean. (It works for me on the forum image).I’ll leave it to you to clean it up. Sorry. I can come back within 3 days.

requires("1.53e");
setBackgroundColor(0,0,0);
setOption("BlackBackground",true);
img=getImageID();
selectImage(img);
run("Duplicate...", "title=1");
close("\\Others");
run("Duplicate...", "title=2");
run("Duplicate...", "title=3");
selectImage("2");
run("Duplicate...", "title=Temp");
// Start processing
selectImage("Temp");
run("32-bit");
run("Enhance Contrast...", "saturated=20");
run("Gaussian Blur...", "sigma=5");
run("Invert");
run("Find Maxima...", "prominence=100 output=List");
x=getResult("X",0);
y=getResult("Y",0);
close("Results");
close("Temp");
selectImage("1");
run("Enhance Contrast...", "saturated=10 equalize");
run("Invert");
run("RGB to CMYK");
selectImage("CMYK_1");
run("Stack to Images");;
close("M");
close("Y");
close("K");
//setTool("wand");
doWand(x, y, 0.1, "Legacy");
roiManager("Add");
roiManager("Select", 0);
close("1");
selectImage("2");
run("Restore Selection");
run("Make Band...", "band=40");
setBackgroundColor(0, 0, 0);
run("Clear Outside");
setBackgroundColor(255, 255, 255);
run("Clear", "slice");
run("Select None");
close("C");
roiManager("Reset");
run("8-bit");
setOption("BlackBackground", true);
run("Convert to Mask");
run("Fill Holes");
run("Skeletonize");
run("Ridge Detection", "line_width=10 high_contrast=230 low_contrast=87 displayresults add_to_manager make_binary method_for_overlap_resolution=NONE sigma=3.39 lower_threshold=0 upper_threshold=0.85 minimum_line_length=30 maximum=100000");
roiManager("Select", newArray(5,6,7,8,9,10));
roiManager("Delete");
selectImage("3");
roiManager("Show All");
run("Tile");
selectImage("3");
roiManager("Show All with labels");
selectWindow("Summary");
selectWindow("ROI Manager");
// End of processing