ImagePlus arrays

Dear all,

I want to do something like this. I want to read some images to different ImagePlus variables through a for loop.

a[ ] = {1,2,3,4,5};

for(i=0;li<length.a;i++){
               ImagePlus image[i] = something(a[i]);
}

my problem is it possible to create bunch of new images as indicates above. something like array of images. 1st imege is image[1], 2nd image is imege[2]… something like that. and later we can use those images

lets say

image[1].show();
image[2].show();

I hope you got the question…! :slight_smile:

Did you consider using a stack as your “array of images”?

Regards

Herbie

The problem is when it travel through the loop it should create a image stack. In the beginning. there is no image stack.(We can create a empty stack). Then how can we assign each image from the loop to above stack.?

How would you do this in ImageJ with its GUI?

“Images to Stack” — no?

Try the command recorder for Java …

IJ.run(imp, "Images to Stack", "name=Stack title=[] use keep");

Good luck

Herbie

I don’t know how to do it through Imagej GUI. I have a image which is a connected component labeled image.


Now I am going to take these each blob in to its separate image. Like below. Here I have done it using MorpholibJ connected component labeling. And then selecting each blob one by one.

I want to automate the process. Taking one blob the code is looks like this.

ImagePlus IP = LabelImages.keepLabels(labeledImage,b[1]);

b array contains the number of blobs extracted form the image.

Thank you very much for the consideration.

It can be achieved as follows. Then need to have a mechanism to add these blobs to a image stack.

 ImagePlus labeledImage = BinaryImages.componentsLabeling( imp, 4, 8 );
            labeledImage.show();

            int[] labels = LabelImages.findAllLabels( labeledImage );
            int[] b = new int[labels.length];
           // System.out.println(labels.length);
            ImageStack ist = new ImageStack(imp.getWidth(),imp.getHeight(),labels.length);

            for(int i=0;i<labels.length;i++){
                b[0] = labels[i];
                ImagePlus IP = LabelImages.keepLabels(labeledImage,b);
                IP.show();
            }

This thing will show all the images in the screen in separate windows

Good day!

I don’t know how to do it through Imagej GUI.

Don’t you think it is high time to get acquainted with the basic functions of ImageJ?

The user guide deals in detail with the functionality of plain ImageJ. Most of these functions can be recorded by using the recorder function of ImageJ as macro,- script-, or Java-code.

Since about a year now you are struggling with various aspects of your project, as well as with ImageJ and Java. Others have previously suggested that you need a profound knowledge of ImageJ and Java if you want to be successful with your scientific endeavour.

Good luck

Herbie

2 Likes

Thank you very much I am trying to improve imagej and java skills. And as you all suggest 1 St I try with macro recording. Then I use that code in my code. Some work some don’t. Then I try to use core methods and classes. Thank you again. I hope to finish this project this month.:blush::blush:

1 Like