Login  Register

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

Posted by Michael Schmid on Jun 26, 2007; 5:53pm
URL: http://imagej.273.s1.nabble.com/How-to-apply-auto-window-level-adjust-to-a-new-image-from-within-a-plugin-tp3699000p3699003.html

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