Re: Can't Recover ImagePlus after Stack Rotate
Posted by
dscho on
URL: http://imagej.273.s1.nabble.com/Can-t-Recover-ImagePlus-after-Stack-Rotate-tp3687248p3687249.html
Hi,
On Fri, 13 Aug 2010, kacollins wrote:
> I am writing a plugin that involves, amoung other things, rotating a
> stack. I have included the pertinent code below related to my problem.
> In ImageJ 1.42q, the code preserves the ImagePlus variable "imp" in line
> four (i.e. it is not null, and it contains the rotated data). In ImageJ
> 1.43u, the resulting value of imp is null. The only change is moving
> from 1.42q to 1.43u. I have gone back and forth and the problem only
> happens in 1.43u. How can I recover the imp related to s2 in version
> 1.43u?
>
> ------------------------
>
> StackProcessor sp = new StackProcessor(imp.getStack(), ip);
> ImageStack s2 = null;
> s2 = sp.rotateLeft();
> imp.setStack(null, s2);
>
> if (imp == null)
> IJ.log("imp = null");
>
> -------------------------
Probably I have put some different glue code around it, but it works here,
with ImageJA 1.44e:
-- snipsnap --
import ij.IJ;
import ij.ImagePlus;
import ij.ImageStack;
import ij.plugin.PlugIn;
import ij.process.ImageProcessor;
import ij.process.StackProcessor;
public class Rotate_Test implements PlugIn {
public void run(String arg) {
ImagePlus imp = IJ.getImage();
ImageProcessor ip = imp.getProcessor().duplicate();
StackProcessor sp = new StackProcessor(imp.getStack(), ip);
ImageStack s2 = null;
s2 = sp.rotateLeft();
imp.setStack(null, s2);
if (imp == null)
IJ.log("imp = null");
}
}