http://imagej.273.s1.nabble.com/Issue-about-ImagePlus-tp5024349p5024353.html
> Happy new year for everybody (hoping that it will be better than the last one)!
The window is not closed in the second example because the ‘imp1’ variable points to a different ImagePlus, a non-displayed hyperstack version of the original image. It is the HyperStackConverter.toHyperStack() method that is static, not the ImagePlus it returns.
> So the following code is working as expected (i.e. the imp1 gets closed as expected):
> public class My_Plugin1 implements PlugIn {
> ImagePlus imp1, imp2, imp3;
> public void run(String arg) {
> imp1 = IJ.openImage("
https://imagej.net/images/bat-cochlea-volume.zip");
> imp1.show();
> imp2 = HyperStackConverter.toHyperStack(imp1, 2, 3, 19, "default", "Grayscale");
> imp3 = SubHyperstackMaker.makeSubhyperstack(imp2, "1", "1-3", "1-19");
> imp3.show();
> imp1.close();
> imp2.close();
> }
> }
> But with the following code:
> public class My_Plugin2 implements PlugIn {
> ImagePlus imp1, imp3;
> public void run(String arg) {
> imp1 = IJ.openImage("
https://imagej.net/images/bat-cochlea-volume.zip");
> imp1.show();
> imp1 = HyperStackConverter.toHyperStack(imp1, 2, 3, 19, "default", "Grayscale");
> imp3 = SubHyperstackMaker.makeSubhyperstack(imp1, "1", "1-3", "1-19");
> imp3.show();
> imp1.close();
> }
> }
> the imp1 window isn't closed.
> Is this because the HyperStackConverter.toHyperStack method is creating a static ImagePlus and not a ImagePlus?
> I thank you very much in advance for your lighting on this.
> My best regards,
> Philippe