Package net.imglib2.blocks
Class ViewAnalyzer
- java.lang.Object
-
- net.imglib2.blocks.ViewAnalyzer
-
class ViewAnalyzer extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classViewAnalyzer.AccumulateConverters
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.Supplier<? extends Converter<?,?>>converterSupplierSupplies Converter from root type to view type.private java.lang.StringBuildererrorDescriptionprivate java.util.List<ViewNode>nodesView sequence of the targetRandomAccessible.private ExtensionoobExtensionThe description of the out-of-bounds extension.private intoobIndexThe index of the out-of-bounds extension innodes.private MixedTransformpermuteInvertTransformprivate RandomAccessible<?>raThe targetRandomAccessible, that is, the View to analyze.private MixedTransformremainderTransformprivate MixedTransformtransformThe concatenated transform from the ViewRandomAccessibleto the root.
-
Constructor Summary
Constructors Modifier Constructor Description privateViewAnalyzer(RandomAccessible<?> ra)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static java.util.function.Supplier<? extends Converter<?,?>>accumulateConverters(java.util.List<ViewNode.ConverterViewNode<?,?>> nodes)private booleananalyze()Deconstruct the View sequence of the targetRandomAccessibleinto a list ofViewNodes.private static voidapply(MixedTransform transformToSource, long[] source, long[] target)Apply thetransformToSourceto a target vector to obtain a source vector.private booleancheckConverters()Connect all converters in the view sequence into a combined converter.private booleancheckExtensions1()Check whether there is at most one out-of-bounds extension.private booleancheckExtensions2()Check whether the out-of-bounds extension (if any) is of a supported type (constant-value, border, mirror-single, mirror-double).private booleancheckExtensions3()Check whether the interval at the out-of-bounds extension is compatible.private booleancheckNoDimensionsAdded()Check that all View dimensions are used (mapped to some root dimension).private booleancheckRootSupported()Check whether the root of the View sequence is supported.private booleancheckRootTypeSupported()Check whether the pixelTypeof the root of the View sequence is supported.private <T extends Type<T>>
booleancheckViewTypeSupported()Check whether the pixelTypeof the View is supported.private booleanconcatenateTransforms()Compute the concatenatedtransformfrom the ViewRandomAccessibleto the root.private <T extends NativeType<T>>
FallbackProperties<T>getFallbackProperties()private <T extends NativeType<T>,R extends NativeType<R>>
ViewProperties<T,R>getViewProperties()static <T extends NativeType<T>,R extends NativeType<R>>
ViewPropertiesOrError<T,R>getViewProperties(RandomAccessible<T> view)private booleansplitTransform()SplittransformintopermuteInvertTransform, a pure axis permutation followed by inversion of some axes, andremainderTransform, a remainder transformation, such thatremainder * permuteInvert == transform.private static BoundingBoxtransform(MixedTransform transformToSource, BoundingBox boundingBox)Apply thetransformToSourceto a target bounding box to obtain a source bounding box.
-
-
-
Field Detail
-
ra
private final RandomAccessible<?> ra
The targetRandomAccessible, that is, the View to analyze.
-
nodes
private final java.util.List<ViewNode> nodes
View sequence of the targetRandomAccessible. The first element is the targetRandomAccessibleitself. The last element is the sourceNativeImgwhere the View sequence originates.
-
errorDescription
private final java.lang.StringBuilder errorDescription
-
oobIndex
private int oobIndex
The index of the out-of-bounds extension innodes.
-
oobExtension
private Extension oobExtension
The description of the out-of-bounds extension.
-
converterSupplier
private java.util.function.Supplier<? extends Converter<?,?>> converterSupplier
Supplies Converter from root type to view type. Maybenull, if there is no conversion required.
-
transform
private MixedTransform transform
The concatenated transform from the ViewRandomAccessibleto the root.
-
permuteInvertTransform
private MixedTransform permuteInvertTransform
-
remainderTransform
private MixedTransform remainderTransform
-
-
Constructor Detail
-
ViewAnalyzer
private ViewAnalyzer(RandomAccessible<?> ra)
-
-
Method Detail
-
checkViewTypeSupported
private <T extends Type<T>> boolean checkViewTypeSupported()
Check whether the pixelTypeof the View is supported. AllNativeTypes withentitiesPerPixel==1are supported.- Returns:
true, if the view's pixel type is supported.
-
analyze
private boolean analyze()
Deconstruct the View sequence of the targetRandomAccessibleinto a list ofViewNodes.- Returns:
false, if during the analysis a View type is encountered that can not be handled.true, if everything went ok.
-
checkRootSupported
private boolean checkRootSupported()
Check whether the root of the View sequence is supported. Supported roots arePlanarImg,ArrayImg, andCellImgvariants.- Returns:
true, if the root is supported.
-
checkRootTypeSupported
private boolean checkRootTypeSupported()
Check whether the pixelTypeof the root of the View sequence is supported. AllNativeTypes withentitiesPerPixel==1are supported.- Returns:
true, if the root's pixel type is supported.
-
checkExtensions1
private boolean checkExtensions1()
Check whether there is at most one out-of-bounds extension. If an extension is found, store its index intooobIndex, and its description intooobExtension.- Returns:
true, if there is at most one out-of-bounds extension.false, otherwise
-
checkExtensions2
private boolean checkExtensions2()
Check whether the out-of-bounds extension (if any) is of a supported type (constant-value, border, mirror-single, mirror-double).- Returns:
true, if the out-of-bounds extension is of a supported type, or if there is no extension.
-
checkExtensions3
private boolean checkExtensions3()
Check whether the interval at the out-of-bounds extension is compatible. The interval must be equal to the root interval carried through the transforms so far. This means that the extension can be applied to the root directly (assuming that extension method is the same for every axis.)- Returns:
true, if the out-of-bounds extension interval is compatible, or if there is no extension.
-
apply
private static void apply(MixedTransform transformToSource, long[] source, long[] target)
Apply thetransformToSourceto a target vector to obtain a source vector.- Parameters:
transformToSource- the transformToSource from target to source.source- set this to the source coordinates.target- target coordinates.
-
transform
private static BoundingBox transform(MixedTransform transformToSource, BoundingBox boundingBox)
Apply thetransformToSourceto a target bounding box to obtain a source bounding box.- Parameters:
transformToSource- the transformToSource from target to source.boundingBox- the target bounding box.- Returns:
- the source bounding box.
-
checkConverters
private boolean checkConverters()
Connect all converters in the view sequence into a combined converter. If the out-of-bounds extension requires values of a specific type (like constant-value extension), then all converters have to happen after the out-of-bounds extension (that is, they have to occur earlier in thenodessequence).For example if a constant-value extension is applied to a
DoubleTypeRandomAccessiblethe oob value will be ofDoubleType. If the RA was converted from aUnsignedByteTypeNativeImgwe don't know theUnsignedByteTypeoob value for the underlyingNativeImgwhich would lead to the same effect. Therefore, this is not allowed.If everything works, the combined converter is provided in
converterSupplier.- Returns:
true, if all converters could be combined and work with the out-of-bounds extension.
-
accumulateConverters
private static java.util.function.Supplier<? extends Converter<?,?>> accumulateConverters(java.util.List<ViewNode.ConverterViewNode<?,?>> nodes)
-
concatenateTransforms
private boolean concatenateTransforms()
Compute the concatenatedtransformfrom the ViewRandomAccessibleto the root.- Returns:
true
-
checkNoDimensionsAdded
private boolean checkNoDimensionsAdded()
Check that all View dimensions are used (mapped to some root dimension).- Returns:
true, if all View dimensions are used.
-
splitTransform
private boolean splitTransform()
SplittransformintopermuteInvertTransform, a pure axis permutation followed by inversion of some axes, andremainderTransform, a remainder transformation,
remainder * permuteInvert == transform.Block copying will then first use
remainderTransformto extract a intermediate block from the rootNativeImg. Then compute the final block by applyingpermuteInvertTransform.- Returns:
true
-
getViewProperties
private <T extends NativeType<T>,R extends NativeType<R>> ViewProperties<T,R> getViewProperties()
-
getFallbackProperties
private <T extends NativeType<T>> FallbackProperties<T> getFallbackProperties()
-
getViewProperties
public static <T extends NativeType<T>,R extends NativeType<R>> ViewPropertiesOrError<T,R> getViewProperties(RandomAccessible<T> view)
-
-