Re: macro help please
Posted by
Gabriel Landini on
Dec 15, 2009; 10:49pm
URL: http://imagej.273.s1.nabble.com/macro-help-please-tp3689867p3689889.html
On Tuesday 15 December 2009 22:28:09 you wrote:
> I'm creating a macro to process a directory of forest canopy images.
> Here's what I've got so far after wrapping a recorded macro for one
> image file:
>
> dir = getDirectory("Choose a Directory ");
> list = getFileList(dir);
> setOption("display labels", true);
> setBatchMode(true);
>
> for (i=0; i<list.length; i++) {
> path = dir+list[i];
> showProgress(i, list.length);
>
> open(path);
>
> run("8-bit");
> setAutoThreshold();
> //run("Threshold...");
> setThreshold(0, 128);
> run("Convert to Mask");
> run("Measure");
>
> close();
> }
>
> My question is that I want each image to get it's own threshold set
> automatically but I'm not sure how to do that to replace the
> setThreshold(0,128) call.
Leave "setAutoThreshold();" and delete the "setThreshold(0,128);"
While recording macros, both commands get recorded because it is not possible
to guess what the user wants, whether the automatic method or the value. You
need the first one, not the 2nd one.
Cheers,
G.