Re: how to update ImagePlus in Python
Posted by
Rasband, Wayne (NIH/NIMH) [E] on
Feb 25, 2015; 7:55pm
URL: http://imagej.273.s1.nabble.com/how-to-update-ImagePlus-in-Python-tp5011768p5011775.html
On Feb 25, 2015, at 10:40 AM, Aryeh Weiss <
[hidden email]> wrote:
>
> I have an ImagePlus that was created by loading a stack from a file.
> I am trying to remove a single slice as follows:
>
> # this stack has 6 slices
> inputStack = impInput.getImageStack()
> inputStack.deleteSlice(6)
>
> impInput.show()
>
> print impInput.getNChannels()
> # this command now prints 5
>
> dupStack = inputStack.duplicate()
> impTest = ImagePlus("lksdfj", dupStack)
> impTest.show()
>
> The original image (impInput), appears with on slice missing (as expected, but it is the wrong slice, and the information overthe image is not completely correct (it shows 5 slices, but still thins it has 6 channels).
>
> The duplicated stack (dupStack) was used to create a new imp (impText). This image is shown correctly, with the correct slice removed.
> However, it still says c:5/6 over the image..
>
> What is the correct way to manipulate an ImageStack, and then update the ImagePlus and ImageProcessr?
Get the stack, delete or add slices, set the stack. Here is a JavaScript example:
img = IJ.openImage("
http://imagej.nih.gov/ij/images/t1-rendering.zip");
img.show();
stack = img.getStack();
stack.deleteSlice(20);
img.setStack(stack);
-wayne
> I looked in the tutorials (which are very nice), but the examples I found had the stacks being built "fresh". My confusion is how to deal with an existing imp. I suppose I could create a new imp each time I do something, but that does not seem to be the right way.
>
> Thanks in advance.
> --aryeh
>
> --
> Aryeh Weiss
> Faculty of Engineering
> Bar Ilan University
> Ramat Gan 52900 Israel
>
> Ph: 972-3-5317638
> FAX: 972-3-7384051
>
> --
> ImageJ mailing list:
http://imagej.nih.gov/ij/list.html--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html