Login  Register

Re: macro help please

Posted by Gabriel Lapointe-2 on Dec 15, 2009; 10:51pm
URL: http://imagej.273.s1.nabble.com/macro-help-please-tp3689867p3689868.html

Hi Larry,
The macro recorder put a counter productive setThreshold(min, max)
command after the set autoThreshold function. Just remove (or comment
out //) the line and it should work fine.

Good luck
Gabbriel

Gabriel Lapointe, MSc.
Laboratoire de Luc DesGroseillers, PhD.
Pavillon Roger-Gaudry Local A-538
Département de biochimie
Faculté de Médecine de l'Université de Montréal
2900 boul. Édouard-Montpetit,
Montréal, Qc, H3T 1J4
[hidden email]


On Tue, 2009-12-15 at 16:28 -0600, Larry Nolan 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.  What I want is to open each image, convert  
> to greyscale, do an autothreshold, then convert to Binary and do the  
> Measure function to calculate the percentage of black pixel which  
> represent the canopy.  I think I'm close but would appreciate a review  
> of what I've done so far.
>
>   thanks,
>
> Larry