Class ViewAnalyzer
java.lang.Object
net.imglib2.blocks.ViewAnalyzer
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionSupplies Converter from root type to view type.private final StringBuilderView sequence of the targetRandomAccessible.private ExtensionThe description of the out-of-bounds extension.private intThe index of the out-of-bounds extension innodes.private MixedTransformprivate final RandomAccessible<?> The targetRandomAccessible, that is, the View to analyze.private MixedTransformprivate MixedTransformThe concatenated transform from the ViewRandomAccessibleto the root. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaccumulateConverters(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 booleanConnect all converters in the view sequence into a combined converter.private booleanCheck whether there is at most one out-of-bounds extension.private booleanCheck whether the out-of-bounds extension (if any) is of a supported type (constant-value, border, mirror-single, mirror-double).private booleanCheck whether the interval at the out-of-bounds extension is compatible.private booleanCheck that all View dimensions are used (mapped to some root dimension).private booleanCheck whether the root of the View sequence is supported.private booleanCheck whether the pixelTypeof the root of the View sequence is supported.private <T extends Type<T>>
booleanCheck whether the pixelTypeof the View is supported.private booleanCompute the concatenatedtransformfrom the ViewRandomAccessibleto the root.private <T extends NativeType<T>>
FallbackProperties<T> private <T extends NativeType<T>, R extends NativeType<R>>
ViewProperties<T, R> static <T extends NativeType<T>, R extends NativeType<R>>
ViewPropertiesOrError<T, R> getViewProperties(RandomAccessible<T> view) private booleanSplittransformintopermuteInvertTransform, 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 Details
-
ra
The targetRandomAccessible, that is, the View to analyze. -
nodes
-
errorDescription
-
oobIndex
private int oobIndexThe index of the out-of-bounds extension innodes. -
oobExtension
The description of the out-of-bounds extension. -
converterSupplier
-
transform
The concatenated transform from the ViewRandomAccessibleto the root. -
permuteInvertTransform
-
remainderTransform
-
-
Constructor Details
-
ViewAnalyzer
-
-
Method Details
-
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
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
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 Supplier<? extends Converter<?,?>> accumulateConverters(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
-
getFallbackProperties
-
getViewProperties
public static <T extends NativeType<T>, R extends NativeType<R>> ViewPropertiesOrError<T,R> getViewProperties(RandomAccessible<T> view)
-