problems upgrading ImageStack

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

problems upgrading ImageStack

Nicola B.
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.
Reply | Threaded
Open this post in threaded view
|

Re: problems upgrading ImageStack

Volker Baecker
Hello Nicola,
you can call

imp.setStack(imp.getTitle(), imp.getStack());

after you added the second slice.

Volker

Nicola B. a écrit :

> 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.
>

--
passerelle antivirus du campus CNRS de Montpellier
--