Getting the position of objects in 3D Counting

I am doing 2D and 3D counting on a stack of images. I am using the Particle Analyzer as it is the default method by ImageJ. I also liked that it is providing me with the x and y position of the object that I can mark on the corresponding image.

For 3D counting, I used the ImageJ 3D Object Counter which I noticed to be slow. I found on a post that this is because it runs 2D counting before 3D counting. It was advised to replace it with 3D ImageJ Suite and so I did.

for (int ch=0 ; ch < imagePlusfiltered.getNChannels(); ch++) {
      // 3D ImageJ Suit Counting 
      segment3DImage = new Segment3DImage(channelImages[ch],0,255);
      Count3D[ch] =  segment3DImage.getNbObj();

My First question, is it possible to have the x and y position of the labelled objects as I did with the Particle Analyzer?

My Second Question, I found on ImageJ Suite Website that using simple segmentation is similar to ImageJ 3D Object Counter which I found its explanation online and from reading the code seems to confirm the same. If so then why the ImageJ 3D Object Counter is slower?

Hi @Mourka,

The 3D Simple Segmentation from the 3D ImageJ Suite will use a faster algorithm that 3D Object Counter. Note that the class Segment3DImage is actually containing the code from 3D Object Counter. If you want to use the faster code from 3D Simple Segmentation, you will need to use the ImageLabeller class as follows :

// convert a binary ImagePlus to ImageHandler
 ImageHandler img = ImageHandler.wrap(myPlus);
// create a labeller and extract the objects from the image
 ImageLabeller labeler = new ImageLabeller();
 ArrayList<Object3DVoxels> objects = labeler.getObjects(img);

You can then extract the centroid coordinates of the objects by using :

objects.get(0).getCenterX(); // same with Y and Z

There are actually two positions given by the Particle Analyzer , one will refer to the actual centroid of the object, the other one (that you will get by selecting Record Starts), will give one point of the contour of the object.

Hope this helps,



1 Like

Hi @ThomasBoudier

I just have one question based on your answer. Does ImageLabeller uses the simple segmentation method that I also used in my code using segment3DImage() but on top of that it gives the voxel information or both are using different methods?

I checked its code and I confirmed it is under the 3D Simple Segmentation Algorithms but I am seeing different methods used.

Hi @Mourka ,

Yes the two classes use different algorithms. ImageLabeller uses a faster segmentation algorithm and it is used by the 3D Simple Segmentation plugin.