ImgLib2 cursor as a java.util.Collection

If I remember correctly, there is code in Fiji for viewing an net.imglib2.Cursor as a java.util.Collection. Perhaps created by @ctrueden? Can’t seem to find the library–does anybody know where it is?

I don’t know if there’s anything specific in imglib2, but since Cursor implements Iterator, you should be able to make a Collection in various ways, e.g. using StreamSupport.stream() and .collect(), or IteratorUtils from Apache Commons.

See:

Maybe there’s something even shorter in ImgLib2 already?

2 Likes

@albertcardona Yep! It’s net.imglib2.util.FlatCollections. It adapts IterableInterval to Collection and RandomAccessibleInterval to List. The PR was:

3 Likes