"Images to Stack" command as an ImageJ Op?

scijava
imagej2
imagej-legacy
imagej-ops
parameters
Tags: #<Tag:0x00007fa304543040> #<Tag:0x00007fa304542cd0> #<Tag:0x00007fa304542b40> #<Tag:0x00007fa3045429b0> #<Tag:0x00007fa304542870>

#1

Hi all,

Is there an ImageJ Op for the “Images to Stack” command, specifically with the “Copy (center)” method to handle images of different sizes? I couldn’t find anything using the ImageJ2 “Find Commands” plugin or by searching and figured I ought to ask here before re-inventing the wheel.

If it doesn’t exist, I’d like to get some input to avoid re-inventing other wheels also. Excuse me for the barrage of questions - I’m somewhat new to the ImageJ2 architecture and ecosystem and still don’t quite understand how the parts interact. If there are any high-level diagrams to explain things, please point me at them!

  1. “Images to Stack” requires an arbitrary number of input images and the IJ1 command does this using pattern matching on the titles of all open images. This is a very crude approach and doesn’t really fit in with the IJ2 way of doing things. However, what is the IJ2 way to approach this? SciJava @Parameter doesn’t (currently) support an arbitrary number of images as input, e.g., a Dataset parameter.

  2. In order to add support for a Dataset parameter, is it just a matter of implementing a new InputWidget, WidgetModel and UIComponent, or are there a number of other things to consider? Is there any documentation (other than the source code) on how to go about this?

  3. Would arrays of parameters like this work with input harvesting for macros and headless usage? I’m not at all familiar with how those systems work.

Thanks,
Aidan


#2

Hi @omaraa

So. I cannot help you too much in Ops details… But, there is now an Op Finder in ImageJ - so you can search for existing Ops there. Just type ‘Find Ops’ into the Command Finder …

I’ll leave other Ops experts to answer your other questions …

eta


#3

Hi @omaraa,

I’ll try to help you… however I’m not sure if I understand each detail of your question… so correct me if I’m wrong!

If I understand you correctly, you have several images in n-d and you want to combine them to an n+1-d image, in your case 2d planes to a 3d stack? Are you already working with imglib2 (imglib2.net)? There are several nice convenience methods. The basic approach would be as follows:

  1. Take your image and extend it using Views.extend(...) or ops().transform().extend(...) or so. Basically, you take the image and extend it at the borders given some strategy (e.g. zeros, mirrored values, fade out etc…).
  2. Basically, you can now crop an arbitrary Interval from the result of the extend using e.g. Views.interval or ops().transform().interval(..). All intervals have now the same size.
  3. Using Views.stack(...) you can combine the intervals from (2).

Does this help?

Best,

Christian


#4

So if I want to do generate such stack from various image sizes in the Jython macro language, I need to extend my images to the size of the largest image of the list before joining them into a stack object.

There is really no way to use the Images to stack method with a list of images as argument ?


#5

The latest ImageJ daily build (1.52d16) adds a static method to the ImagesToStack class that converts an array of images into a stack. Here is a JavaScript example:

  images = new Array(3);
  images[0] = IJ.openImage("http://wsr.imagej.net/images/blobs.gif");
  images[1] = IJ.openImage("http://wsr.imagej.net/images/leaf.jpg");
  images[2] = IJ.openImage("http://wsr.imagej.net/images/boats.gif");
  stack = ImagesToStack.run(images);
  if (stack!=null)
     stack.show();

The ImagesToStack.run(images) method uses the default settings (“copy centered”, “use titles as labels”) but it can be extended to support options if needed.

View the source code changes at