ImageStack iteration

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

ImageStack iteration

Dimiter Prodanov
Dear All,

Can anybody tell me how to achieve iteration over Slices during
processing of an ImageStack in a PlugInFilter?
So far I tried with DOES_STACKS flag but the outcome is that only the
first slice is processed.
May be it is quite trivial question but so fat I never entered this domain.

best regards

Dimiter Prodanov
Reply | Threaded
Open this post in threaded view
|

Re: ImageStack iteration

dscho
Hi,

On Mon, 29 May 2006, Dimiter Prodanov wrote:

> Can anybody tell me how to achieve iteration over Slices during processing of
> an ImageStack in a PlugInFilter?

Try something like this:

ImageStack stack = image.getStack();
for (int i = 1; i <= stack.getSize(); i++) {
        ImageProcessor ip = stack.getProcessor(i);
        // do your thing on the ip
}

Of course, this expects you to have a "ImagePlus image" member in that
class, which is assigned in the setup() method, since the run() method
only gets an ImageProcessor (I think that was your problem to begin with).

Hth,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: ImageStack iteration

seb-7
In reply to this post by Dimiter Prodanov
Dimiter Prodanov wrote:
> Dear All,
>
> Can anybody tell me how to achieve iteration over Slices during
> processing of an ImageStack in a PlugInFilter?
> So far I tried with DOES_STACKS flag but the outcome is that only the
> first slice is processed.
> May be it is quite trivial question but so fat I never entered this domain.

Hi Dimiter,
You can use stack.getPixels(i) where i is the index of a slice and stack
  an ImageStack object.
See ImageStack at
http://rsb.info.nih.gov/ij/developer/api/index.html
and for instance the StackAverage source code
http://rsb.info.nih.gov/ij/plugins/tutorial.html
Hope it helps!

Greetings,
sebastien
Reply | Threaded
Open this post in threaded view
|

Antwort: Re: ImageStack iteration

Joachim Wesner
In reply to this post by dscho
Hi,

I´m a bit confused here. Sure, doing it the way Johannes describes will
work, but I think (part of) the original question was:

      Why does DOES_STACKS not seem to work as supposed, i.e. for a
probably simple plugin repeatedly do the same filter operation on the
individual slices automatically??
      (I.e. for the case that the operations on the slices are independant
of each other)

I just tried it with a simple inverter plugin that has DOES_STACKS set and
a stack of 5 slices and it DOES invert all 5 slices!?

(Make a new plugin_filter with New.., add DOES_STACKS in the setup method
and at best remove the delay and the second ip.invert, so it will do
permanent changes on the stack)
Dimiter, does this work on your stack?

Joachim



|---------+---------------------------->
|         |           Johannes         |
|         |           Schindelin       |
|         |           <Johannes.Schinde|
|         |           [hidden email]>      |
|         |           Gesendet von:    |
|         |           ImageJ Interest  |
|         |           Group            |
|         |           <[hidden email].|
|         |           GOV>             |
|         |                            |
|         |                            |
|         |           29.05.2006 16:27 |
|         |           Bitte antworten  |
|         |           an ImageJ        |
|         |           Interest Group   |
|---------+---------------------------->
  >-------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                               |
  |        An:      [hidden email]                                                                                           |
  |        Kopie:   (Blindkopie: Joachim Wesner/DEWET/LMSCentral/Leica)                                                           |
  |        Thema:   Re: ImageStack iteration                                                                                      |
  >-------------------------------------------------------------------------------------------------------------------------------|




Hi,

On Mon, 29 May 2006, Dimiter Prodanov wrote:

> Can anybody tell me how to achieve iteration over Slices during
processing of
> an ImageStack in a PlugInFilter?

Try something like this:

ImageStack stack = image.getStack();
for (int i = 1; i <= stack.getSize(); i++) {
             ImageProcessor ip = stack.getProcessor(i);
             // do your thing on the ip
}

Of course, this expects you to have a "ImagePlus image" member in that
class, which is assigned in the setup() method, since the run() method
only gets an ImageProcessor (I think that was your problem to begin with).

Hth,
Dscho



______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________
Reply | Threaded
Open this post in threaded view
|

Re: ImageStack iteration

Andrew-98
I am also facing such type of problem.Please any body suggest a solution.
In the following code i am trying to read some files and then i want make a
stack and display it into the stack window.

/* selecting file */
for( ; ;)
{
   /* reading pixels values*/
for(; ; )
{
   short shorts[] =..;
}
/* creating ImageProcessor */
ImageProcesor ip = new ShortProcessor(x_dim , y_dim , shorts ,null)
}
When i am adding some lines  of code ,stack window shows but only first
slice is in stack.


On 5/29/06, Joachim Wesner <[hidden email]> wrote:

>
> Hi,
>
> I´m a bit confused here. Sure, doing it the way Johannes describes will
> work, but I think (part of) the original question was:
>
>       Why does DOES_STACKS not seem to work as supposed, i.e. for a
> probably simple plugin repeatedly do the same filter operation on the
> individual slices automatically??
>       (I.e. for the case that the operations on the slices are independant
> of each other)
>
> I just tried it with a simple inverter plugin that has DOES_STACKS set and
> a stack of 5 slices and it DOES invert all 5 slices!?
>
> (Make a new plugin_filter with New.., add DOES_STACKS in the setup method
> and at best remove the delay and the second ip.invert, so it will do
> permanent changes on the stack)
> Dimiter, does this work on your stack?
>
> Joachim
>
>
>
> |---------+---------------------------->
> |         |           Johannes         |
> |         |           Schindelin       |
> |         |           <Johannes.Schinde|
> |         |           [hidden email]>      |
> |         |           Gesendet von:    |
> |         |           ImageJ Interest  |
> |         |           Group            |
> |         |           <[hidden email].|
> |         |           GOV>             |
> |         |                            |
> |         |                            |
> |         |           29.05.2006 16:27 |
> |         |           Bitte antworten  |
> |         |           an ImageJ        |
> |         |           Interest Group   |
> |---------+---------------------------->
>
>   >-------------------------------------------------------------------------------------------------------------------------------|
>   |
> |
>   |        An:      [hidden email]
> |
>   |        Kopie:   (Blindkopie: Joachim
> Wesner/DEWET/LMSCentral/Leica)
> |
>   |        Thema:   Re: ImageStack
> iteration                                                                                      |
>
>   >-------------------------------------------------------------------------------------------------------------------------------|
>
>
>
>
> Hi,
>
> On Mon, 29 May 2006, Dimiter Prodanov wrote:
>
> > Can anybody tell me how to achieve iteration over Slices during
> processing of
> > an ImageStack in a PlugInFilter?
>
> Try something like this:
>
> ImageStack stack = image.getStack();
> for (int i = 1; i <= stack.getSize(); i++) {
>              ImageProcessor ip = stack.getProcessor(i);
>              // do your thing on the ip
> }
>
> Of course, this expects you to have a "ImagePlus image" member in that
> class, which is assigned in the setup() method, since the run() method
> only gets an ImageProcessor (I think that was your problem to begin with).
>
> Hth,
> Dscho
>
>
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
>
Reply | Threaded
Open this post in threaded view
|

Re: ImageStack iteration

Robert Dougherty
Take a look at the code for Facet Orientation at
http://www.optinav.com/Facet-Orientation.htm.  To make a new stack, you
create it with something like
ImageStack imsTheta = new ImageStack(w,h);
Then you loop through the slices, and for each new slice, create an
ImageProcessor and put it on the stack with, for example,
imsTheta.addSlice("Polar  image (Theta)",ipTheta).   After adding all the
slices, you make an ImagePlus to show the stack:
ImagePlus impTheta = new ImagePlus("Polar image (Theta)",imsTheta);
To actually see it, you need to call need to call
impTheta.show();


Bob


Robert P. Dougherty, Ph.D.
President, OptiNav, Inc.
Phone (425) 467-1118
Fax (425) 467-1119
www.optinav.com
 

> -----Original Message-----
> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of
> Andrew
> Sent: Monday, May 29, 2006 1:10 PM
> To: [hidden email]
> Subject: Re: ImageStack iteration
>
> I am also facing such type of problem.Please any body suggest a solution.
> In the following code i am trying to read some files and then i want make
> a
> stack and display it into the stack window.
>
> /* selecting file */
> for( ; ;)
> {
>    /* reading pixels values*/
> for(; ; )
> {
>    short shorts[] =..;
> }
> /* creating ImageProcessor */
> ImageProcesor ip = new ShortProcessor(x_dim , y_dim , shorts ,null)
> }
> When i am adding some lines  of code ,stack window shows but only first
> slice is in stack.
>
>
> On 5/29/06, Joachim Wesner <[hidden email]> wrote:
> >
> > Hi,
> >
> > I´m a bit confused here. Sure, doing it the way Johannes describes will
> > work, but I think (part of) the original question was:
> >
> >       Why does DOES_STACKS not seem to work as supposed, i.e. for a
> > probably simple plugin repeatedly do the same filter operation on the
> > individual slices automatically??
> >       (I.e. for the case that the operations on the slices are
> independant
> > of each other)
> >
> > I just tried it with a simple inverter plugin that has DOES_STACKS set
> and
> > a stack of 5 slices and it DOES invert all 5 slices!?
> >
> > (Make a new plugin_filter with New.., add DOES_STACKS in the setup
> method
> > and at best remove the delay and the second ip.invert, so it will do
> > permanent changes on the stack)
> > Dimiter, does this work on your stack?
> >
> > Joachim
> >
> >
> >
> > |---------+---------------------------->
> > |         |           Johannes         |
> > |         |           Schindelin       |
> > |         |           <Johannes.Schinde|
> > |         |           [hidden email]>      |
> > |         |           Gesendet von:    |
> > |         |           ImageJ Interest  |
> > |         |           Group            |
> > |         |           <[hidden email].|
> > |         |           GOV>             |
> > |         |                            |
> > |         |                            |
> > |         |           29.05.2006 16:27 |
> > |         |           Bitte antworten  |
> > |         |           an ImageJ        |
> > |         |           Interest Group   |
> > |---------+---------------------------->
> >
> >   >---------------------------------------------------------------------
> ----------------------------------------------------------|
> >   |
> > |
> >   |        An:      [hidden email]
> > |
> >   |        Kopie:   (Blindkopie: Joachim
> > Wesner/DEWET/LMSCentral/Leica)
> > |
> >   |        Thema:   Re: ImageStack
> > iteration
> |
> >
> >   >---------------------------------------------------------------------
> ----------------------------------------------------------|
> >
> >
> >
> >
> > Hi,
> >
> > On Mon, 29 May 2006, Dimiter Prodanov wrote:
> >
> > > Can anybody tell me how to achieve iteration over Slices during
> > processing of
> > > an ImageStack in a PlugInFilter?
> >
> > Try something like this:
> >
> > ImageStack stack = image.getStack();
> > for (int i = 1; i <= stack.getSize(); i++) {
> >              ImageProcessor ip = stack.getProcessor(i);
> >              // do your thing on the ip
> > }
> >
> > Of course, this expects you to have a "ImagePlus image" member in that
> > class, which is assigned in the setup() method, since the run() method
> > only gets an ImageProcessor (I think that was your problem to begin
> with).
> >
> > Hth,
> > Dscho
> >
> >
> >
> > ______________________________________________________________________
> > This email has been scanned by the MessageLabs Email Security System.
> > For more information please visit http://www.messagelabs.com/email
> > ______________________________________________________________________
> >
Reply | Threaded
Open this post in threaded view
|

Re: ImageStack iteration

Albert Cardona
In reply to this post by Andrew-98
Hi Dimiter,

There may be better and more integrated ways, but one can loop the stack
manually in any case. Just by calling ImagePlus.getStack() and then iterating
over the ImageProcessors.

Albert
Reply | Threaded
Open this post in threaded view
|

Re: ImageStack iteration

Dimiter Prodanov
In reply to this post by Andrew-98
Hi All,
After all the problem was mine. Sometimes when using Eclipse not
all files compile (they should be specifically imported into the
project, bugger)
so the flags works fine. Soon I will announce a new version of GrayMorphology
processing also stacks. I also implemented a new algorithm doing
faster erosions.

best regards
Dimiter Prodanov
Reply | Threaded
Open this post in threaded view
|

Re: ImageStack iteration

seb-7
Dimiter Prodanov wrote:
> Hi All,
> After all the problem was mine. Sometimes when using Eclipse not
> all files compile (they should be specifically imported into the
> project, bugger)

<troll>
He he
Emacs+JDE rulez :-)
</troll>

I have a (stupid) question about your module:
Do you mean it will do 3D morphology ops, or 2D morphology for each
slice? (I think this is not the same, am I right?)
Thanks for your work.

sebastien
Reply | Threaded
Open this post in threaded view
|

Re: ImageStack iteration

Dimiter Prodanov
In reply to this post by Andrew-98
Hi sebastien,

The question is not stupid at all. Now the problem is
that nobody deviced sofar really fast algorithm for arbitrary
structuring elements. So it comes down to ~N^2 x hight x width
computations in 2D. In 3D it will be ~N^3 x height x width which
for a large SE is quite slow. So at the moment I will add
only slice by slice 2D operations. If a lot of people want
I will also make an explicitly 3D implementation but it will be slow.

best regards

Dimiter



Date:    Tue, 30 May 2006 20:03:50 +0200
From:    seb <[hidden email]>
Subject: Re: ImageStack iteration

Dimiter Prodanov wrote:
 > Hi All,
 > After all the problem was mine. Sometimes when using Eclipse not
 > all files compile (they should be specifically imported into the
 > project, bugger)

<troll>
He he
Emacs+JDE rulez :-)
</troll>

I have a (stupid) question about your module:
Do you mean it will do 3D morphology ops, or 2D morphology for each
slice? (I think this is not the same, am I right?)
Thanks for your work.

sebastien