Plugin distorts original images

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Plugin distorts original images

aelalaily
I have a plugin that takes as input DICOM images as input and does certain operations, that include cropping and removing voxels.

However I wish to have the original images left unchanged. I have tried copying the stack I get as input to another variable, but this still doesn't change the distortion done to the original images.


public class test implements PlugInFilter {
        ImagePlus imp;
       
        public void run(ImageProcessor ip) {
               
                ImageStack inputstack = imp.getStack();
                ImageStack stack = new ImageStack();
                stack = inputstack;
                ....
        }
       
        ...
}

Whether or not I use another ImageStack variable doesn't change the outcome. Is there a way around this?

Any help will be much appreciated.

Cheers
Reply | Threaded
Open this post in threaded view
|

Re: Plugin distorts original images

José María Mateos
2013/8/2 aelalaily <[hidden email]>:
>                 ImageStack inputstack = imp.getStack();
>                 ImageStack stack = new ImageStack();
>                 stack = inputstack;

Note that by assigning your variables this way, this is equivalent to:

ImageStack inputstack = imp.getStack();
ImageStack stack = new ImageStack();

So, both variables are pointing to the same object (the original
image). You are not actually duplicating your original stack, which I
guess is what you intended to do. Probably this can be solved this
way:

ImageStack inputstack = imp.getStack();
ImagePlus target = imp.duplicate();
ImageStack stack = target.getStack();

Now you are duplicating your original image and the modifications you
make on the "stack" object will not affect it.

Best,

José.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Plugin distorts original images

aelalaily
Perfect. Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Plugin distorts original images

aelalaily
In reply to this post by José María Mateos
Perfect. Thank you.



--
View this message in context: http://imagej.1557.x6.nabble.com/Plugin-distorts-original-images-tp5004278p5004282.html
Sent from the ImageJ mailing list archive at Nabble.com.

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html