Trouble with writing a macro: setThreshold

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Trouble with writing a macro: setThreshold

Rob Camp
Hi,

I'm trying to write a macro that will determine the gray value 3.5 standard deviations higher than the mean, from a selected region of the image. Apparently, this was possible on an older version of ImageJ running on Mac OS 9, but I'm using OS X and the macro language has changed. I have no previous experience writing macros, so please bear with me.

The problem I'm having is with setting the lower limit on the threshold. I'd like it to be a variable equal to the parameters given above, "3.5*StdDev + Mean" (actually, rounded to the next integer), but I don't really know how to go about defining such a variable.

Thanks very much in advance.
Reply | Threaded
Open this post in threaded view
|

Re: Trouble with writing a macro: setThreshold

Wayne Rasband
> Hi,
>
> I'm trying to write a macro that will determine the gray value 3.5
> standard
> deviations higher than the mean, from a selected region of the image.
> Apparently, this was possible on an older version of ImageJ running on
> Mac
> OS 9, but I'm using OS X and the macro language has changed. I have no
> previous experience writing macros, so please bear with me.
>
> The problem I'm having is with setting the lower limit on the
> threshold. I'd
> like it to be a variable equal to the parameters given above,
> "3.5*StdDev +
> Mean" (actually, rounded to the next integer), but I don't really know
> how
> to go about defining such a variable.

Use the getRawStatistics() macro function to get the standard deviation
and setThreshold() to set the Threshold. Here is an example:

   getRawStatistics(nPixels, mean, min, max, stdDev);
   t1 = 3.5*stdDev+mean;
   t2 = max;
   setThreshold(t1, t2);

-wayne
Reply | Threaded
Open this post in threaded view
|

Re: Trouble with writing a macro: setThreshold

Rob Camp
Use the getRawStatistics() macro function to get the standard deviation
and setThreshold() to set the Threshold. Here is an example:

   getRawStatistics(nPixels, mean, min, max, stdDev);
   t1 = 3.5*stdDev+mean;
   t2 = max;
   setThreshold(t1, t2);

-wayne
Wow, it worked. And I thought I even tried that, but I guess I went about it in some other [incorrect] way. In any case, thank you very much, this will make things much easier for me!
Reply | Threaded
Open this post in threaded view
|

BatchMode problem

Du, Guanghua
Dear ImageJ users,
I am tring to draw strings in the slices. Everything works fine in the
normal mode, but when I switch to batch mode, then only in one slice the
   text string is drawn, namely the first slice, and all the other
slices in the image stack is empty.

here is the detail, I create a stack ObjVilFileName; in a seperate
image: objectImageTitle, I write the strings; then I copy this image and
paste it to the stack;

when the setBatchMode command is deleted, everything works, but not with
  it.

// setBatchMode(true);

                selectWindow(objectImageTitle);
                drawString(filename, 10,20);
                drawString("Obj: "+objectNumber, 10, 40);
                updateDisplay();
                run("Copy");
                selectWindow(ObjVisFileName);
                Stack.setSlice(i+1);
                run("Paste");
                updateDisplay();



Thanks a lot!! and a late Happy New Year!

Guanghua Du
TUM, Physik Dept.
Germany