Class FlatCollections
- java.lang.Object
-
- net.imglib2.util.FlatCollections
-
public final class FlatCollections extends java.lang.ObjectUtility class for wrapping ImgLib2 images as read-onlyCollections.This is useful when you want to pass an ImgLib2
IterableIntervalorRandomAccessibleIntervalto an API that works with JavaCollectionobjects, such as Google Guava's Quantiles.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classFlatCollections.CollectionFromII<T,E>AnIterableIntervalexpressed as aCollection.private static classFlatCollections.ListFromRAI<T,E>ARandomAccessibleIntervalexpressed as aList.
-
Constructor Summary
Constructors Constructor Description FlatCollections()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Collection<java.math.BigInteger>bigIntegerCollection(IterableInterval<? extends IntegerType<?>> image)Wraps anIntegerTypeiterable image as a collection.static java.util.List<java.math.BigInteger>bigIntegerList(RandomAccessibleInterval<? extends IntegerType<?>> image)Wraps aIntegerTyperandom-accessible image as a list.static java.util.Collection<java.lang.Boolean>booleanCollection(IterableInterval<? extends BooleanType<?>> image)Wraps aBooleanTypeiterable image as a collection.static java.util.List<java.lang.Boolean>booleanList(RandomAccessibleInterval<? extends BooleanType<?>> image)Wraps aBooleanTyperandom-accessible image as a list.static <T,E>
java.util.Collection<E>collection(IterableInterval<T> image, java.util.function.Function<T,E> converter)Wraps anIterableIntervalas aCollection.static java.util.Collection<java.lang.Double>doubleCollection(IterableInterval<? extends RealType<?>> image)Wraps aRealTypeiterable image as a collection.static java.util.List<java.lang.Double>doubleList(RandomAccessibleInterval<? extends RealType<?>> image)Wraps aRealTyperandom-accessible image as a list.static java.util.Collection<java.lang.Float>floatCollection(IterableInterval<? extends RealType<?>> image)Wraps aRealTypeiterable image as a collection.static java.util.List<java.lang.Float>floatList(RandomAccessibleInterval<? extends RealType<?>> image)Wraps aRealTyperandom-accessible image as a list.static java.util.Collection<java.lang.Integer>integerCollection(IterableInterval<? extends IntegerType<?>> image)Wraps anIntegerTypeiterable image as a collection.static java.util.List<java.lang.Integer>integerList(RandomAccessibleInterval<? extends IntegerType<?>> image)Wraps anIntegerTyperandom-accessible image as a list.static <T,E>
java.util.List<E>list(RandomAccessibleInterval<T> image, java.util.function.Function<T,E> converter)Wraps aRandomAccessibleIntervalas aList.static java.util.Collection<java.lang.Long>longCollection(IterableInterval<? extends IntegerType<?>> image)Wraps anIntegerTypeiterable image as a collection.static java.util.List<java.lang.Long>longList(RandomAccessibleInterval<? extends IntegerType<?>> image)Wraps anIntegerTyperandom-accessible image as a list.private static intsizeAsInt(long size)
-
-
-
Method Detail
-
collection
public static <T,E> java.util.Collection<E> collection(IterableInterval<T> image, java.util.function.Function<T,E> converter)
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 java.util.Collection<java.lang.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:
collection(IterableInterval, Function)
-
doubleCollection
public static java.util.Collection<java.lang.Double> doubleCollection(IterableInterval<? extends RealType<?>> image)
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:
collection(IterableInterval, Function)
-
floatCollection
public static java.util.Collection<java.lang.Float> floatCollection(IterableInterval<? extends RealType<?>> image)
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:
collection(IterableInterval, Function)
-
integerCollection
public static java.util.Collection<java.lang.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:
collection(IterableInterval, Function)
-
longCollection
public static java.util.Collection<java.lang.Long> longCollection(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
CollectionwithLongelements. - See Also:
collection(IterableInterval, Function)
-
bigIntegerCollection
public static java.util.Collection<java.math.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:
collection(IterableInterval, Function)
-
list
public static <T,E> java.util.List<E> list(RandomAccessibleInterval<T> image, java.util.function.Function<T,E> converter)
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(net.imglib2.RandomAccessibleInterval<T>)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
public static java.util.List<java.lang.Boolean> booleanList(RandomAccessibleInterval<? extends BooleanType<?>> image)
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:
list(RandomAccessibleInterval, Function)
-
doubleList
public static java.util.List<java.lang.Double> doubleList(RandomAccessibleInterval<? extends RealType<?>> image)
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:
list(RandomAccessibleInterval, Function)
-
floatList
public static java.util.List<java.lang.Float> floatList(RandomAccessibleInterval<? extends RealType<?>> image)
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:
list(RandomAccessibleInterval, Function)
-
integerList
public static java.util.List<java.lang.Integer> integerList(RandomAccessibleInterval<? extends IntegerType<?>> image)
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:
list(RandomAccessibleInterval, Function)
-
longList
public static java.util.List<java.lang.Long> longList(RandomAccessibleInterval<? extends IntegerType<?>> image)
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:
list(RandomAccessibleInterval, Function)
-
bigIntegerList
public static java.util.List<java.math.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:
list(RandomAccessibleInterval, Function)
-
sizeAsInt
private static int sizeAsInt(long size)
-
-