2.4. Helper Classes

2.4.1. ImageVector, ImageVector

The ml::ImageVector class manages a 6D point/vector with 6 components x, y, z, c, t, u of the type MLint. It is the main class used for voxel positions, image extents, box corners or page extents. The typical (integer) vector arithmetics is available as well as minimum and maximum component search, lexicographical comparison, stride operations and component-wise multiplication for voxel addressing, etc. It offers different template specializations with 16, 32 and 64 bit integer components, because most ML image and voxel addressing is done by this class. A ImageVector works with 64 bit integers to support very large image addressing and should be used in all image processing modules unless there are clear reasons for using specialized versions. The most important methods are:

  • operators +, -, *, /, <<, >>, []

    Operators as they are defined on integers, applied component-wise.

  • getStrides()

    If a ImageVector is interpreted as an image extent, this method returns another ImageVector with voxel offsets (usually called strides in such a context). To get from one voxel position to a neighbor position, e.g., to y, the corresponding stride getStrides().y has to be added. The y strides are usually identical with the x extent of the image, the z stride with the number of x extent multiplied by the y extent, the c stride with x extent*y extent*z extent , etc. Strides are typically needed for very fast voxel positioning with indices into images.

  • getVectorPosition(offsetPos)

    If the ImageVector is interpreted as the extent of an image and offsetPos as an index into the image, getVectorPosition() returns the position of the voxel as ImageVector.

  • getExtDimension()

    If the ImageVector is interpreted as the extent of an image, this method returns the highest ImageVector component that cannot be used to get the real dimension of an image.

  • hasNegativeComp()

    This method returns true if any component is negative, otherwise it returns false. This method can be used to check whether the position might be an invalid image coordinate (negative components are not used for voxel addressing).

  • allBiggerZero()

    This method returns true if all components > 0, otherwise it returns false.

  • Constructors, set and get methods to initialize the ImageVector in different ways, maximum/minimum component search, etc. are available.

Please refer to file ???? in the project MLLinearAlgebra for more information (Section 2.6.1, “MLLinearAlgebra(Vector2, ..., Vector10, Vector16, Matrix2, , ..., Matrix6, quaternion, ImageVector)”).

2.4.2.  SubImageBox

The ml::SubImageBox class manages a rectangular 6D box given by two corners that are specified by the Vectors v1 and v2. It permits volume intersection, calculation, etc. SubImageBox is available in 16, 32 and 64 bit template specializations (like the class ImageVector). Use SubImageBox without a number for all normal ML code. See mlSubImageBox.h in the project ML. A comparable class with 6D float vector is available as SubImageBoxd in file mlSubImageBoxd.h .

[Important]Important
  • Both corners of the box are considered to be inside the box, so a SubImageBox from (13,12,10,0,0,0) to (13,12,10,0,0,0) contains exactly one voxel.

  • The SubImageBox is empty if any of the v1 components is bigger than the corresponding v2 component.

    Figure 2.4. SubImageBox

    SubImageBox

This class offers a set of useful methods, e.g.:

  • getSize()

    Returns the number of voxels in the subimage region, i.e. the product of all extents if this is not empty; otherwise 0 is returned.

  • isEmpty()

    Returns true if the box is empty; otherwise false is returned.

  • intersect(loc2)

    Returns the regions that overlap with subimage regions loc2 as a SubImageBox. In case of non-overlapping boxes, the returned box is empty.

  • contains (pos)

    Returns true if pos is within box; otherwise false is returned.

  • getExtent()

    Returns a vector with the extent of the box in all 6 dimensions (see Section 2.4.1, “ImageVector, ImageVector”).

  • translate(shift)

    Translates the box by the vector shift.

  • get3DCorners(...)

    Returns all eight corners of the box as vectors ( see Section 2.4.1, “ImageVector, ImageVector”).

Please refer to file mlSubImageBox.h for more information.