Macro: Processing Images in a Stack

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

Macro: Processing Images in a Stack

McAuley, Grant (LLU)
Hello List,

I am trying to write a macro that will automatically enhance the contrast for each image in the stack.  The code below seems to apply the contrast window determined for the first image to all the following images in the stack.  

How can I enhance the contrast for each image individually in the stack?  Is there a sample 'Stack' macro that shows how to process stack images individually?

Here is my macro code:

for(slice = 1; slice < nSlices(); slice++) {
     if (nSlices > 1) run("Set Slice...", "slice=" + slice);
     run("Enhance Contrast", "saturated=0.5");
}
Reply | Threaded
Open this post in threaded view
|

Re: Macro: Processing Images in a Stack

Wayne Rasband
Add the 'normalize' keyword and the macro will work as expected.

   for(slice = 1; slice < nSlices; slice++) {
      setSlice(slice);
      run("Enhance Contrast", "saturated=0.5 normalize");
   }

-wayne

On Jan 16, 2007, at 12:34 PM, McAuley, Grant (LLU) wrote:

> Hello List,
>
> I am trying to write a macro that will automatically enhance the
> contrast for each image in the stack.  The code below seems to apply
> the contrast window determined for the first image to all the
> following images in the stack.
>
> How can I enhance the contrast for each image individually in the
> stack?  Is there a sample 'Stack' macro that shows how to process
> stack images individually?
>
> Here is my macro code:
>
> for(slice = 1; slice < nSlices(); slice++) {
>      if (nSlices > 1) run("Set Slice...", "slice=" + slice);
>      run("Enhance Contrast", "saturated=0.5");
> }
>