Class FlatCollections
Collections.
This is useful when you want to pass an ImgLib2 IterableInterval or
RandomAccessibleInterval to an API that works with Java
Collection objects, such as Google Guava's Quantiles.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classAnIterableIntervalexpressed as aCollection.private static classARandomAccessibleIntervalexpressed as aList. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Collection<BigInteger> bigIntegerCollection(IterableInterval<? extends IntegerType<?>> image) Wraps anIntegerTypeiterable image as a collection.static List<BigInteger> bigIntegerList(RandomAccessibleInterval<? extends IntegerType<?>> image) Wraps aIntegerTyperandom-accessible image as a list.static Collection<Boolean> booleanCollection(IterableInterval<? extends BooleanType<?>> image) Wraps aBooleanTypeiterable image as a collection.booleanList(RandomAccessibleInterval<? extends BooleanType<?>> image) Wraps aBooleanTyperandom-accessible image as a list.static <T,E> Collection <E> collection(IterableInterval<T> image, Function<T, E> converter) Wraps anIterableIntervalas aCollection.static Collection<Double> doubleCollection(IterableInterval<? extends RealType<?>> image) Wraps aRealTypeiterable image as a collection.doubleList(RandomAccessibleInterval<? extends RealType<?>> image) Wraps aRealTyperandom-accessible image as a list.static Collection<Float> floatCollection(IterableInterval<? extends RealType<?>> image) Wraps aRealTypeiterable image as a collection.floatList(RandomAccessibleInterval<? extends RealType<?>> image) Wraps aRealTyperandom-accessible image as a list.static Collection<Integer> integerCollection(IterableInterval<? extends IntegerType<?>> image) Wraps anIntegerTypeiterable image as a collection.integerList(RandomAccessibleInterval<? extends IntegerType<?>> image) Wraps anIntegerTyperandom-accessible image as a list.static <T,E> List <E> list(RandomAccessibleInterval<T> image, Function<T, E> converter) Wraps aRandomAccessibleIntervalas aList.static Collection<Long> longCollection(IterableInterval<? extends IntegerType<?>> image) Wraps anIntegerTypeiterable image as a collection.longList(RandomAccessibleInterval<? extends IntegerType<?>> image) Wraps anIntegerTyperandom-accessible image as a list.private static intsizeAsInt(long size)
-
Constructor Details
-
FlatCollections
public FlatCollections()
-
-
Method Details
-
collection
Wraps anIterableIntervalas aCollection. The wrapped collection is read-only, throwingUnsupportedOperationExceptionif the caller attempts to mutate it.With this method, and unlike
list(RandomAccessibleInterval, Function), the iteration order of the wrapped collection will match that of the source image. It is best not to make any assumptions about the iteration order of the collection—only that each element of the wrapped image will appear once in the iteration.- Parameters:
image- TheIterableIntervalto wrap as a Java collection.converter- Conversion function to use for accessing elements of the collection. This function will be transparently called on the corresponding source sample from the ImgLib2 image.- Returns:
- Wrapped
Collectionof the converted type.
-
booleanCollection
public static Collection<Boolean> booleanCollection(IterableInterval<? extends BooleanType<?>> image) Wraps aBooleanTypeiterable image as a collection.Warning: Don't make any assumption on the iteration order, only that each pixel will appear once. Performance may be low as the collection uses boxed types.
- Parameters:
image- TheIterableIntervalto wrap as a Java collection.- Returns:
- Wrapped
CollectionwithBooleanelements. - See Also:
-
doubleCollection
Wraps aRealTypeiterable image as a collection.Warning: Don't make any assumption on the iteration order, only that each pixel will appear once. Performance may be low as the collection uses boxed types.
- Parameters:
image- TheIterableIntervalto wrap as a Java collection.- Returns:
- Wrapped
CollectionwithDoubleelements. - See Also:
-
floatCollection
Wraps aRealTypeiterable image as a collection.Warning: Don't make any assumption on the iteration order, only that each pixel will appear once. Performance may be low as the collection uses boxed types.
- Parameters:
image- TheIterableIntervalto wrap as a Java collection.- Returns:
- Wrapped
CollectionwithFloatelements. - See Also:
-
integerCollection
public static Collection<Integer> integerCollection(IterableInterval<? extends IntegerType<?>> image) Wraps anIntegerTypeiterable image as a collection.Warning: Don't make any assumption on the iteration order, only that each pixel will appear once. Performance may be low as the collection uses boxed types.
- Parameters:
image- TheIterableIntervalto wrap as a Java collection.- Returns:
- Wrapped
CollectionwithIntegerelements. - See Also:
-
longCollection
Wraps anIntegerTypeiterable image as a collection.Warning: Don't make any assumption on the iteration order, only that each pixel will appear once. Performance may be low as the collection uses boxed types.
- Parameters:
image- TheIterableIntervalto wrap as a Java collection.- Returns:
- Wrapped
CollectionwithLongelements. - See Also:
-
bigIntegerCollection
public static Collection<BigInteger> bigIntegerCollection(IterableInterval<? extends IntegerType<?>> image) Wraps anIntegerTypeiterable image as a collection.Warning: Don't make any assumption on the iteration order, only that each pixel will appear once. Performance may be low as the collection uses boxed types.
- Parameters:
image- TheIterableIntervalto wrap as a Java collection.- Returns:
- Wrapped
CollectionwithBigIntegerelements. - See Also:
-
list
Wraps aRandomAccessibleIntervalas aList. The wrapped list is read-only, throwingUnsupportedOperationExceptionif the caller attempts to mutate it.With this method, and unlike
collection(IterableInterval, Function), the iteration order of the wrapped list will always be theflat iteration order, as thoughViews.flatIterable(RandomAccessibleInterval)were used on the sourceRandomAccessibleIntervalimage. As such, iterating the original image and the wrappedListmay result in differing sequences of elements.- Parameters:
image- TheRandomAccessibleIntervalto wrap as a Java list.converter- Conversion function to use for accessing elements of the list. This function will be transparently called on the corresponding source sample from the ImgLib2 image.- Returns:
- Wrapped
Listof the converted type.
-
booleanList
Wraps aBooleanTyperandom-accessible image as a list.Warning: Performance may be low, as the collection uses boxed types.
- Parameters:
image- TheRandomAccessibleIntervalto wrap as a Java list.- Returns:
- Wrapped
ListwithBooleanelements. - See Also:
-
doubleList
Wraps aRealTyperandom-accessible image as a list.Warning: Performance may be low, as the collection uses boxed types.
- Parameters:
image- TheRandomAccessibleIntervalto wrap as a Java list.- Returns:
- Wrapped
ListwithDoubleelements. - See Also:
-
floatList
Wraps aRealTyperandom-accessible image as a list.Warning: Performance may be low, as the collection uses boxed types.
- Parameters:
image- TheRandomAccessibleIntervalto wrap as a Java list.- Returns:
- Wrapped
ListwithFloatelements. - See Also:
-
integerList
Wraps anIntegerTyperandom-accessible image as a list.Warning: Performance may be low, as the collection uses boxed types.
- Parameters:
image- TheRandomAccessibleIntervalto wrap as a Java list.- Returns:
- Wrapped
ListwithIntegerelements. - See Also:
-
longList
Wraps anIntegerTyperandom-accessible image as a list.Warning: Performance may be low, as the collection uses boxed types.
- Parameters:
image- TheRandomAccessibleIntervalto wrap as a Java list.- Returns:
- Wrapped
ListwithLongelements. - See Also:
-
bigIntegerList
public static List<BigInteger> bigIntegerList(RandomAccessibleInterval<? extends IntegerType<?>> image) Wraps aIntegerTyperandom-accessible image as a list.Warning: Performance may be low, as the collection uses boxed types.
- Parameters:
image- TheRandomAccessibleIntervalto wrap as a Java list.- Returns:
- Wrapped
ListwithBigIntegerelements. - See Also:
-
sizeAsInt
private static int sizeAsInt(long size)
-