imglib / imglib2-roi

Regions of interest (ROIs) and labelings for ImgLib2
Other
8 stars 8 forks source link

Determine required container for RandomAccessibleInterval<LabelingType<V>> #8

Closed dietzc closed 9 years ago

dietzc commented 9 years ago

use-case: we want to create a new ImgLabeling<V,?> with the same dimensionality and amount of labels as RandomAccessibleInterval<LabelingType<V>>. However, Istill have to decide on the IntegerType of the Img<IntegerType>. Is there an efficient way to get the number of labels which are contained on the RandomAccessibleInterval<LabelingType> without iterating over it (given that the RAI may be a View)? Or do I have to iterate over the RandomAccessibleInterval<LabelingType>?

tpietzsch commented 9 years ago

@dietzc You can use ImgLabeling.getMapping().numSets() to get an upper bound. This will give you the number of all label combinations (that is what you are after when you decide on the IntegerType, right? Not the number of labels.) that ever occurred at any pixel. The actual number may be less because certain label combinations might no longer present. For example, if you have a 1 pixel image and you add labels A, B, C to the pixel, your labeling has seen label sets {}, {A}, {A,B}, {A,B,C}. Still I think it is reasonable to use this as an estimate. If you need the exact number, you need to iterate.

tpietzsch commented 9 years ago

@dietzc Can this be closed?

dietzc commented 9 years ago

Yes! Thanks!