@hadim: I guess the API changes you mention refer to the discussion here: Implementation plan for Imglib2-rois 2D. Thanks for the link to the python script (which seems to be the same as the one @bnorthan refers to).
Trying to use that example in Java, I get to:
OpService ops = CONTEXT.getService(OpService.class);
Img<ShortType> image = ImageJFunctions.wrap( IJ.getImage() );
image = (Img<ShortType>) ops.filter().gauss(image, 3.0);
RandomAccessibleInterval<BitType> otsu = (RandomAccessibleInterval<BitType>) ops.threshold().otsu(image);
List<Shape> shapes = new ArrayList<Shape>();
HyperSphereShape shape = new HyperSphereShape(1);
shapes.add(shape);
RandomAccessibleInterval<BitType> closed =
(RandomAccessibleInterval<BitType>) ops.morphology().close(otsu, shapes);
ops.labeling().cca(closed, ConnectedComponents.StructuringElement.FOUR_CONNECTED);
LabelRegions regions = new LabelRegions(labels);
Iterator rIterator = regions.iterator();
while (rIterator.hasNext()) {
LabelRegion region = (LabelRegion) rIterator.next();
DoubleType size = ops.geom().size(region);
System.out.println("size of object is: " + size);
System.out.println("center of object is: " + region.getCenterOfMass());
}
This works, but how do I proceed to place these regions on top of my original image and get the intensities under each region?
Why aren’t there structuring elements with less than four connected (i.e. ConnectedComponents.StructuringElement.ONE_CONNECTED)? I want a list of all “particles”, i.e. a list of all groups of pixels where each pixel is connected to one or more neighbors part of that group. I haven’t been able to locate the code executing the cca function, but from the sounds of it I need StructuringElement.ONE_CONNECTED.
It is well possible that I have missed an enlightening piece of documentation, if so, can someone please point me to it?