Class ViewAnalyzer


  • class ViewAnalyzer
    extends java.lang.Object
    • Field Detail

      • ra

        private final RandomAccessible<?> ra
        The target RandomAccessible, that is, the View to analyze.
      • nodes

        private final java.util.List<ViewNode> nodes
        View sequence of the target RandomAccessible. The first element is the target RandomAccessible itself. The last element is the source NativeImg where the View sequence originates.
      • errorDescription

        private final java.lang.StringBuilder errorDescription
      • oobIndex

        private int oobIndex
        The index of the out-of-bounds extension in nodes.
      • 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. Maybe null, if there is no conversion required.
      • permuteInvertTransform

        private MixedTransform permuteInvertTransform
    • Method Detail

      • checkViewTypeSupported

        private <T extends Type<T>> boolean checkViewTypeSupported()
        Check whether the pixel Type of the View is supported. All NativeTypes with entitiesPerPixel==1 are supported.
        Returns:
        true, if the view's pixel type is supported.
      • analyze

        private boolean analyze()
        Deconstruct the View sequence of the target RandomAccessible into a list of ViewNodes.
        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 are PlanarImg, ArrayImg, and CellImg variants.
        Returns:
        true, if the root is supported.
      • checkRootTypeSupported

        private boolean checkRootTypeSupported()
        Check whether the pixel Type of the root of the View sequence is supported. All NativeTypes with entitiesPerPixel==1 are 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 into oobIndex, and its description into oobExtension.
        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 the transformToSource to 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 the transformToSource to 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 the nodes sequence).

        For example if a constant-value extension is applied to a DoubleType RandomAccessible the oob value will be of DoubleType. If the RA was converted from a UnsignedByteType NativeImg we don't know the UnsignedByteType oob value for the underlying NativeImg which 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 concatenated transform from the View RandomAccessible to 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()
        Split transform into
        1. permuteInvertTransform, a pure axis permutation followed by inversion of some axes, and
        2. remainderTransform, a remainder transformation,
        such that remainder * permuteInvert == transform.

        Block copying will then first use remainderTransform to extract a intermediate block from the root NativeImg. Then compute the final block by applying permuteInvertTransform.

        Returns:
        true