Login  Register

Re: Is there a way to disable this automatic adjustment of brightness contrast that happens when I open an image?

Posted by Wayne Rasband on Oct 27, 2009; 7:17pm
URL: http://imagej.273.s1.nabble.com/Is-there-a-way-to-disable-this-automatic-adjustment-of-brightness-contrast-that-happens-when-I-open--tp3690641p3690642.html

 > I'm taking many sets of images as a series of images in
 > three different colors that correspond to three different
 > stains and get saved as an image stack.  Unfortunately,
 > when I open each image stack in ImageJ, it automatically
 > sets the Minimum and Maximum Intensity  values based on the
 > top image.  I would like to be able to open images with the
 > Minimum set to zero and the Max to 4095 (the max value for
 > my 12 bit camera). It's a real pain to have to go through
 > all my images and readjust every time I open one! So, is
 > there a way to disable this automatic adjustment of
 > brightness contrast that happens when I open an image?

Save the attached plugin in the plugins folder as
"Display_Range_Listener.java", compile it using Plugins>Compile and
Run, add

    macro "AutoRun" {
       run("Display Range Listener");
    }

to the beginning of ImageJ/macros/StartupMacros.txt, and restart ImageJ.

-wayne

// Display_Range_Listener.java
import ij.*;
import ij.plugin.*;
public class Display_Range_Listener implements PlugIn, ImageListener {
        public void run(String arg) {
                ImagePlus.addImageListener(this);
        }
        public void imageOpened(ImagePlus imp) {
                if (imp.getBitDepth()==16) {
                        imp.setDisplayRange(0, 4095);
                        imp.updateAndDraw();
                }
        }
        public void imageClosed(ImagePlus imp) { }
        public void imageUpdated(ImagePlus imp) { }
}