How to auto-adjust brightness/contrast from a plugin?

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

How to auto-adjust brightness/contrast from a plugin?

DwightBart
Under the "Image" menu there is the "Adjust" submenu from which you can
choose "Brightness/Contrast".  From the Brightness/Contrast window you
can click the "Auto" button.

 

Okay, say within a plugin I've just created an image.  Before I display
this image I want to perform this auto-brightness/contrast adjustment.
Is there an easy way to do this?

 

Sincerely,

Dwight Bartholomew
Reply | Threaded
Open this post in threaded view
|

Re: How to auto-adjust brightness/contrast from a plugin?

Wayne Rasband
> Under the "Image" menu there is the "Adjust" submenu from
> which you can choose "Brightness/Contrast".  From the
> Brightness/Contrast window you can click the "Auto" button.
>
> Okay, say within a plugin I've just created an image.  Before I
> display this image I want to perform this auto-brightness/contrast.
> adjustment Is there an easy way to do this?

Here is one way

     new ContrastEnhancer().stretchHistogram(ip, 0.5);

where ip is an ImageProcessor. Or display the image and run the  
Process>Enhance Contrast command using

     IJ.run("Enhance Contrast", "saturated=0.5");

In a macro, use

     run("Enhance Contrast", "saturated=0.5");

-wayne