Copying an 8-bit image

Posted by Florian Leitner on
URL: http://imagej.273.s1.nabble.com/Copying-an-8-bit-image-tp3686474.html

Hi everybody,

I wrote a plugin. One part of the plugin copies the current image and

does some transformations to the copied image. Everything works as

it is supposed to work but if the original image is an 8-bit image

all the transformations to the copied image will also be applied

to the original image.

e.g.:
1. open an image, convert it to 8-bit
2. execute Test_BDP.java [1]
3. go to e.g. process -> binary -> make binary
4. save the original image - it'll be a binary picture
5. repeat steps 1.-4. with e.g. a 16-bit image


I tried it with different ImageJ versions and OS.

Thanks for your help.
 Florian


[1]:

import ij.*;

public class Test_BDP {

        public Test_BDP() {

                ImagePlus imageCopy;  

                ImagePlus imp = WindowManager.getCurrentImage();
                imageCopy = copyImage(imp);
// imageCopy = copyImage2(imp);
                imageCopy.show();
        }
 
  ImagePlus copyImage(ImagePlus imp) {
                ImagePlus newImage;
   
                newImage = imp.createImagePlus();
                newImage.setStack("Copy " + imp.getTitle(), imp.getStack());    
                return newImage;
        }


        ImagePlus copyImage2(ImagePlus imp) {
                ImageProcessor ip = imp.getProcessor();
                return new ImagePlus("Copy " + imp.getTitle(), ip);
        }

}