Hi all,
I want to create a labelling of an image, and then analyse the regions of the image with other ops. For example, I’d like to calculate the connectivity of each particle in an image. Following others’ code examples I got this far:
final ImgLabeling<Integer, IntType> labeling = opService.labeling().cca(
inputImage, ConnectedComponents.StructuringElement.EIGHT_CONNECTED);
uiService.show(labeling.getIndexImg());
final ImgPlus<BitType> bitTypeImgPlus = Common.toBitTypeImgPlus(opService,
inputImage);
final LabelRegions<Integer> regions = new LabelRegions<>(labeling);
final Set<Integer> labels = regions.getExistingLabels();
labels.forEach(label -> {
final LabelRegion<Integer> region = regions.getLabelRegion(label);
final IterableInterval<BitType> sample = Regions.sample(region,
bitTypeImgPlus);
final Img<BitType> bitTypeImg = opService.convert().bit(sample);
final double connectivity = opService.topology()
.eulerCharacteristic26NFloating(bitTypeImg).get();
System.out.println("Connectivity " + connectivity);
});
The code crashes at opService.convert()
with a
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.IndexOutOfBoundsException: Index: 1, Size: 1 at net.imagej.ops.thread.chunker.DefaultChunker.run(DefaultChunker.java:104)
I’ve forgotten how to convert/wrap an IterableInterval
into a RandomAccessibleInterval
. How do I do that?
Furthermore, if I wanted to exclude regions that intersect image edges, how could I go about it?
Best regards,
Richard