Re: Modified input image
Posted by dscho on
URL: http://imagej.273.s1.nabble.com/Modified-input-image-tp3686496p3686497.html
Hi Arne,
On Thu, 4 Nov 2010, Seitz Arne wrote:
> when I run (Windows7, ImageJ 1.44i, Java 1.6.6_19(32 bit))the below
> attached Plugin everything is fine and I receive as expected a new
> (filtered) image. If I run the Plugin a second time on the same image
> also my input image is modified. This is something which I do not
> understand, because to my opinion the input image should not be changed.
> If the input image is an image stack you can even see that the input
> image is changed after the first run of the plugin if you scroll through
> the different images of the stack.
I think the problem is that you haven't duplicated the processor, and as
such, you are reusing the very same pixels. You do not see that they
already changed after the first run right away, because you did not call
imp.updateAndDraw();
> ShortProcessor ip=new ShortProcessor(imp.getWidth(),imp.getHeight(),(short[]) imp.getProcessor().getPixels(),imp.getProcessor().getColorModel());
I'd write this as
ShortProcessor ip = imp.getProcessor().duplicate();
Ciao,
Johannes