Distinguishing between two types of soil

Yes, I think it is acceptable. But with the comparison of areas in metric units will give me a clear idea of the incertitude.

Hi
@Userfiji
Here is the macro reviewed but whose results are in% but but measuring the area in px.
Good luck

requires( "1.52t" );
setBackgroundColor(0, 0, 0);
setOption("BlackBackground", true);
img=getImageID();

run("Set Measurements...", "area bounding limit display add redirect=None decimal=2");
//setTool("wand");
doWand(40, 628,0,"Legacy");
run("Fit Circle");
run("Enlarge...", "enlarge=-25");
roiManager("Add");
setBackgroundColor(255, 255, 255);
run("Clear Outside");
run("Select None");

// Duplicate the section
run("Duplicate...", "title=1");
run("Duplicate...", "title=2");
run("Tile");

// Measure Area of your section
selectWindow("1");
run("32-bit");
setAutoThreshold("Huang");
waitForUser("Measure Section Area,\nIt's Circle red?\nIt's OK?");
//run("Threshold...");
run("Convert to Mask");
run("Measure");
Asection=getResult("Area", 0);
print("Asection="+Asection) ;

// Measure Area of the crown of your section
run("Invert");
run("Create Selection");
run("Measure");
Acrown= getResult("Area", 1);
print("Acrown="+Acrown) ;
waitForUser("Measure Crown Area,\nIt'scrown select?\nIt's OK?");
close();

// Make original image in stack CMYK
selectWindow("2");
run("RGB to CMYK");
selectWindow("CMYK_2");
run("Stack to Images");
run("Tile");

// All that is green on your picture
selectWindow("C");
roiManager("Select", 0);
setBackgroundColor(255, 255, 255);
run("Clear Outside");
setAutoThreshold("Default dark");

waitForUser("Compare image 2 with C,\nIt's all green in original image select?\nIt's OK?");
setOption("BlackBackground", true);
run("Convert to Mask");
roiManager("Select", 0);
roiManager("Measure");
Agreen= getResult("Area", 2);
print("Agreen="+Agreen) ;
close("C");
pourcGreen=(Agreen/Asection)*100;
print("pourcGreen="+pourcGreen+"%");

// All that is red on your picture
selectWindow("M");
roiManager("Select", 0);
setBackgroundColor(255, 255, 255);
run("Clear Outside");
setAutoThreshold("Yen dark");

waitForUser("Compare image image 2 with M,\nIt's all red in original image select?\nIt's OK?");
setOption("BlackBackground", true);
run("Convert to Mask");
roiManager("Select", 0);
run("Measure");

Ared= getResult("Area", 3);
print("Ared="+Ared) ;
close("M");
pourcRed=(Ared/Asection)*100;
print("pourcRed="+pourcRed+"%");
// Make original image in stack RGB
selectWindow("2");
run("Duplicate...", "title=2-1");
run("RGB Stack");
run("Stack to Images");
selectWindow("Blue");
setAutoThreshold("Otsu dark");
//setThreshold(182, 255);

waitForUser("Compare image image 2 with Blue,\nIt's all purple in original image select?\nIt's OK?");
setOption("BlackBackground", true);
run("Convert to Mask");
roiManager("Select", 0);
roiManager("Measure");

Apurple= getResult("Area", 4);
print("Apurple="+Apurple) ;
close("blue");
pourcPurple=(Apurple/Asection)*100;
print("pourcPurple="+pourcPurple+"%");

Atotal=Apurple+Ared+Agreen;
print("Atotal="+Atotal);
pourcAtotal=(Atotal/Asection)*100;
print("pourcAtotal="+pourcAtotal+"%");
run("Close All");
close("Results");
close("ROI Manager");
selectWindow("Log");
setLocation(30,30);

if(Atotal>0.94*Asection&&Atotal<1.06*Asection)
{
exit("It's Over");
}
else{
exit("The results is wrong");
}
1 Like

Hi @Mathew
Thank you very much.
I’m testing on other images.
I hope it works.
Best regards