Hi,
I have the following image:
And with this script
open("/Users/pdubois/Desktop/cont1_01_crop1.tif")
run("8-bit");
run("Set Scale...", "distance=0.44 known=1 pixel=1 unit=um");
run("Despeckle");
run("Morphological Filters", "operation=Closing element=Disk radius=5");
setAutoThreshold("Minimum dark");
setThreshold(157, 255);
run("Analyze Particles...", "display clear include summarize add");
saveAs("Jpeg", "/Users/pdubois/Desktop/cont1_01_crop1-Closing.jpg");
saveAs("Results", "/Users/pdubois /Desktop/Results.xls");
Which produces this:
I have no problem calculating the area that yield the result with size 44318.182.
But when I tried with Python:
from ij import IJ
# Open Image
imp = IJ.openImage("/Users/pdubois/Desktop/cont1_01_crop1.tif");
IJ.run(imp, "8-bit", "");
IJ.run(imp, "Set Scale...", "distance=0.44 known=1 pixel=1 unit=um");
IJ.run(imp, "Despeckle", "");
#It seems that Morphological Filters doesn't work.
IJ.run(imp, "Morphological Filters", "operation=Closing element=Disk radius=5");
IJ.setAutoThreshold(imp, "Minimum dark");
IJ.setThreshold(imp, 157, 255);
IJ.run(imp, "Analyze Particles...", "display clear include summarize add")
IJ.selectWindow("Results")
IJ.saveAs("Results", "/Users/pdubois/Desktop/Results.xls");
IJ.run("Close");
IJ.selectWindow("ROI Manager")
IJ.run("Close");
IJ.saveAs(imp, "Jpeg", "/Users/pdubois/Desktop/cont1_01_crop1_segm.jpg");
IJ.run("Close");
The result is wrong (29307.852), I believe this is caused by Morphological filters doesn’t get executed.
This produces this:
How can I do it properly in Python?
I really need to get the Python version running to integrate with my other larger program.