简体   繁体   中英

Changing contrast with ImageJ plugin

The objective of the plugin is to take a slice from a stack and then create a new stack with multiple images of the same slice but with different contrasts.

I wrote a for loop, but the results are not what I intended. The new stack is created but it's always the same image in every slice. What am I missing here?

public void run(ImageProcessor ip) {
    ImageProcessor ip2 = ip.duplicate();
    ImageStack nstack = new ImageStack(stack.getWidth(),stack.getHeight());
    ip2.snapshot();
        for(int i=0; i<256; i=i+10){
        ip2.setMinAndMax(0,i);
        nstack.addSlice("Contrast "+i, ip2);
        ip2.reset();
        }

    ImagePlus imp2= new ImagePlus("teste", nstack);
    imp2.show();
    }}

As pointed out by Michael Schmid on the ImageJ mailing list ,

the Brightness & Contrast settings determine how the data are displayed, they do not affect the actual data

In case of 8-bit images, you can use the applyLut() method of the ByteProcessor class after setting the contrast:

ip2.setMinAndMax(0,i);
ip2.applyLut();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM