deleteSlice(1) deletes the second image of a stack

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

deleteSlice(1) deletes the second image of a stack

JiHO-2
Hello everyone,

I am probably doing something wrong, otherwise this looks like a bug:

import ij.*;
import ij.process.*;
import ij.gui.*;
import java.awt.*;
import ij.plugin.*;
import ij.plugin.filter.PlugInFilter;

public class Delete_First implements PlugInFilter {

     ImagePlus im;
     ImageStack stack;

     public int setup(String arg, ImagePlus im) {
         this.im = im;
         return DOES_ALL+STACK_REQUIRED;
     }

     public void run(ImageProcessor ip) {

         // Delete first slice of the stack
         stack = im.getStack();
         stack.deleteSlice(1);

         im.updateAndDraw();
     }
}

This deletes the second image of the stack. stack.deleteSlice(0) gives  
an array out of bounds error.

Thanks in advance for your help. Sincerely,

JiHO
---
http://maururu.net
Reply | Threaded
Open this post in threaded view
|

Re: deleteSlice(1) deletes the second image of a stack

dscho
Hi,

On Wed, 24 Jun 2009, JiHO wrote:

> Hello everyone,
>
> I am probably doing something wrong, otherwise this looks like a bug:
>
> import ij.*;
> import ij.process.*;
> import ij.gui.*;
> import java.awt.*;
> import ij.plugin.*;
> import ij.plugin.filter.PlugInFilter;
>
> public class Delete_First implements PlugInFilter {
>
>    ImagePlus im;
>    ImageStack stack;
>
>    public int setup(String arg, ImagePlus im) {
>        this.im = im;
>        return DOES_ALL+STACK_REQUIRED;
>    }
>
>    public void run(ImageProcessor ip) {
>
>        // Delete first slice of the stack
>        stack = im.getStack();
>        stack.deleteSlice(1);

Just like in the "Delete Slice" function, you need to

        im.setStack(null, stack);

here.

>
>        im.updateAndDraw();
>    }
> }
>
> This deletes the second image of the stack. stack.deleteSlice(0) gives an
> array out of bounds error.

Ciao,
Dscho