Posted by
Arne Seitz on
Nov 04, 2010; 1:36pm
URL: http://imagej.273.s1.nabble.com/Modified-input-image-tp3686496.html
Dear all,
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.
Can anybody explain me, why the input image is modified and how to avoid this.
Thanks a lot in advance.
Cheers Arne
import ij.ImagePlus;
import ij.WindowManager;
import ij.plugin.PlugIn;
import ij.process.ShortProcessor;
public class test_ implements PlugIn{
public void run(String arg) {
ImagePlus imp=WindowManager.getCurrentImage();
int [] kernel={3,5,3,5,8,5,3,5,3};
imp.setSlice(0);
ShortProcessor ip=new ShortProcessor(imp.getWidth(),imp.getHeight(),(short[]) imp.getProcessor().getPixels(),imp.getProcessor().getColorModel());
ip.convolve3x3(kernel);
ImagePlus newimp=new ImagePlus("Test",ip);
newimp.show();
}
}
---------------------------------------------------------------
Dr. Arne Seitz
Head of Bioimaging and Optics Platform (PT-BIOP)
Ecole Polytechnique Fédérale de Lausanne (EPFL)
Faculty of Life Sciences
Station 15, AI 0241
CH-1015 Lausanne
Phone: +41 21 693 9618
Fax: +41 21 693 9585
http://biop.epfl.ch/---------------------------------------------------------------