How to apply auto window/level adjust to a new image from within a plugin?

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

How to apply auto window/level adjust to a new image from within a plugin?

Ron Kneusel
I am new to ImageJ and am writing a plugin that creates three new images and
displays them.  I want to automatically adjust the window/level for each
image just as if I had clicked the "Auto" button in the
Image/Adjust/Window/Level dialog box.

I'm sure this is straightforward and that I'm just missing some concepts or
two, but my searching has not found the right way to do it.

Any help appreciated!

Ron

_________________________________________________________________
Like puzzles? Play free games & earn great prizes. Play Clink now.
http://club.live.com/clink.aspx?icid=clink_hotmailtextlink2
Reply | Threaded
Open this post in threaded view
|

Re: How to apply auto window/level adjust to a new image from within a plugin?

Michael Schmid
Hi Ron,

you can try
   new ContrastEnhancer().stretchHistogram(ip, 0.5);
where ip is the ImageProcessor and 0.5 is the percentage of
saturated pixels. Don't forget imp.updateAndDraw(); thereafter
(where imp is the ImagePlus that contains ip).

Michael
________________________________________________________________


On 26 Jun 2007, at 14:21, Ron Kneusel wrote:

> I am new to ImageJ and am writing a plugin that creates three new  
> images and displays them.  I want to automatically adjust the  
> window/level for each image just as if I had clicked the "Auto"  
> button in the Image/Adjust/Window/Level dialog box.
>
> I'm sure this is straightforward and that I'm just missing some  
> concepts or two, but my searching has not found the right way to do  
> it.
>
> Any help appreciated!
>
> Ron
Reply | Threaded
Open this post in threaded view
|

Re: How to apply auto window/level adjust to a new image from within a plugin?

Ron Kneusel
Michael-

Thanks for the tip.  I will certainly give this a try but isn't there a way
to actually call the same functionality as the menu command?  I see in the
plugins tutorial that you can call menu commands but I'm not clear on the
format of the arguments or even what to call.

Ron

>you can try
>   new ContrastEnhancer().stretchHistogram(ip, 0.5);
>where ip is the ImageProcessor and 0.5 is the percentage of
>saturated pixels. Don't forget imp.updateAndDraw(); thereafter
>(where imp is the ImagePlus that contains ip).
>
>Michael

_________________________________________________________________
Make every IM count. Download Messenger and join the i’m Initiative now.
It’s free. http://im.live.com/messenger/im/home/?source=TAGHM_June07
Reply | Threaded
Open this post in threaded view
|

Re: How to apply auto window/level adjust to a new image from within a plugin?

Michael Schmid
Hi Ron,

of course, the Macro recorder gives you an answer more easily!

   run("Enhance Contrast", "saturated=0.5");
For a plugin, this simply translates into
   IJ.run("Enhance Contrast", "saturated=0.5");

In contrast to
   new ContrastEnhancer().stretchHistogram(ip, 0.5);
IJ.run works on the foreground image only.

Michael
________________________________________________________________
On 26 Jun 2007, at 18:21, Ron Kneusel wrote:

> Michael-
>
> Thanks for the tip.  I will certainly give this a try but isn't  
> there a way to actually call the same functionality as the menu  
> command?  I see in the plugins tutorial that you can call menu  
> commands but I'm not clear on the format of the arguments or even  
> what to call.
>
> Ron
>
>> you can try
>>   new ContrastEnhancer().stretchHistogram(ip, 0.5);
>> where ip is the ImageProcessor and 0.5 is the percentage of
>> saturated pixels. Don't forget imp.updateAndDraw(); thereafter
>> (where imp is the ImagePlus that contains ip).
>>
>> Michael