problems upgrading ImageStack

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

problems upgrading ImageStack

Nicola B.
I see that a possible solution is reassociate stack to imagePlus object,
but now problably because I'm too meticolous, I will be crazy for
another thing...
I try with follow WORKING code and ALSO with IJ.run("Add Slice"), but
every time when code finish is execution a process still alilve.
It seems appens every time a ImageStack Object will be istantiated, also
if final instruction is "stack=null";
Any suggest?
Regards,
    Nicola

-------------------------------------------------------------
        int width = 200;
        int height = 200;
       
        ImageStack stack = null;
        ImagePlus imp = null;
       
        ColorProcessor cp1 = new ColorProcessor(width,height);
        ColorProcessor cp2 = new ColorProcessor(width,height);
        cp2.setColor(Color.GREEN);
        cp2.fill();
       
        stack = new ImageStack(width,height);
        stack.addSlice("uno", cp1, 0);
       
        imp = new ImagePlus("image stack", stack);
        imp.show();
       
        stack.addSlice("due", cp2, 1);
        imp.setStack("",stack);
        //imp = new ImagePlus("image stack", stack);
        stack = null;
       
        imp.updateAndDraw();
--------------------------------------------------------------------


Hi all
I'm developing an interactive plugin and I have some problems upgrading
imageStack.
To understand working mode I try a simple code: (   I prefer if code not
use IJ.run("Add slice")    )
-----------------------------------------------------------------
int width = 200;
int height = 200;
ImageStack stack = null;
ImagePlus imp = null;

stack = new ImageStack(width, height);
ColorProcessor cp1 = new ColorProcessor(width,height);
stack.addSlice("", cp1, 0);
imp = new ImagePlus("", stack);

imp.show();

ColorProcessor cp2 = new ColorProcessor(width,height);
cp2.setColor(Color.RED);
cp2.fill();

//stack.addSlice("", cp2, 1);
imp.getImageStack().addSlice("", cp2,1);
imp.updateAndRepaintWindow();
-----------------------------------------------------------------

Code works ONLY if I call "imp.show();"  at the end but this is a
problem because I would show first slice and UPDATE stack when other
slide will be added.
PS: I prefer if code not use IJ.run("Add slice")

Thanks a lot
   -Nicola B.