On Oct 26, 2011, at 5:08 AM, Tony Shepherd wrote:
> Dear all,
>
> I create an ImageStack in a plugin, fill it with pixel values, give it to an ImagePlus and display.
> By looping through the stack slices I can 'get', 'find' and 'set' the minimum and maximum pixel value associated with that slice and there is also a method to 'resetMinAndMax()' that I believe is used when transforming pixel values to display values.
>
> Is it possible to set a different display contrast for each slice in a stack separately? This information should be retained when scrolling through the slices. For example,
>
> * slice 1 has values in the range 0.0 to 100.0, so the look-up table should make 0 display as 'blackest' and 100.0 display as 'whitest'.
>
> * slice 2 has values in the range -25.0 to 10.5, so the look-up table should make -25.0 display as 'blackest' and 10.5 display as 'whitest'.
>
> * After using 'display()' to put this ImagePlus on screen, I don't want to keep going to 'image --> adjust --> brightness/contrast --> auto' every time I change the slice being displayed.
You can have a different display range for each image in a stack by using a CompositeImage. Here is a JavaScript example:
imp = IJ.createImage("Untitled","32-bit Ramp",512,512,2);
stack = imp.getStack();
ip = stack.getProcessor(1);
ip.multiply(100);
ip = stack.getProcessor(2);
ip.multiply(35.5);
ip.subtract(25);
mode = CompositeImage.GRAYSCALE;
imp = new CompositeImage(imp,mode);
imp.setSlice(1);
imp.setDisplayRange(0,100);
imp.setSlice(2);
imp.setDisplayRange(-25,10.5);
imp.setSlice(1);
imp.show();
-wayne