Login  Register

Re: Windowing an Image without cloning it

Posted by Wayne Rasband on Feb 20, 2006; 7:10pm
URL: http://imagej.273.s1.nabble.com/Windowing-an-Image-without-cloning-it-tp3703658p3703659.html

> Does anybody knows a way to "window" an ImagePlus, without
> creating a new  Image every time?
> By now I am do this like that:
>
> ------------------------------------------------------------------
> Imageplus image;
> ImageProcessor imageProcessor;
>
> this.imageProcessor = image.getProcessor();
> this.imageProcessor.setMinAndMax(windowMin, windowMax);
> this.image = new ImagePlus("ResultImage", this.imageProcessor);
> -------------------------------------------------------------------
>
> This way is very CPU and Memory consuming, as I have to
> copy the image every time.

The Brightness/Contrast and Window/Level tools in ImageJ "window"  
this way:

     ImagePlus imp;
     ImageProcessor ip;

     ip = imp.getProcessor();
     ip.setMinAndMax(windowMin, windowMax);
     imp.updateAndDraw();

The souce code for these tools is at:

   http://rsb.info.nih.gov/ij/developer/source/ij/plugin/frame/ 
ContrastAdjuster.java.html

-wayne