2.8. ML Data Types

In the ML, there are some important voxel and data types used in different contexts.

2.8.1. Voxel Types and Their Enumerators

The following voxel types and enumerators are available in the ML:

  1. MLint8 and MLint8Type

  2. MLuint8 and MLuint8Type

  3. MLint16 and MLint16Type

  4. MLuint16 and MLuint16Type

  5. MLint32 and MLint32Type

  6. MLuint32 and MLuint32Type

  7. MLint64 and MLint64Type

  8. MLfloat and MLfloatType

  9. MLdouble and MLdoubleType

  10. std::complex<float> and MLComplexfType

  11. std::complex<double> and MLComplexdType

  12. ml::Vector*f and MLVector*fType

  13. ml::Vector*d and MLVector*dType

  14. ml::Matrix*f and MLMatrix*fType

  15. ml::Matrix*d and MLMatrix*dType

  16. ml::Vector*i8 and MLVector*i8Type

  17. ml::Vector*i16 and MLVector*i16Type

  18. ml::Vector*i32 and MLVector*i32Type

  19. ml::Vector*i64 and MLVector*i64Type

2.8.2. Index, Size and Offset Types

The following index and offset types are available in the ML:

  1. MLint

    A signed ML integer type with at least 64 bits used for all index calculations on very large images even on 32 bit systems (typically used for positions and coordinates in images). It is widely used in the ML for 64 bit index, size and range specifications which support signed arithmetic.

    Examples of usage are classes ImageVector and SubImageBox which use MLint as members.

  2. MLuint

    An unsigned ML integer type with at least 64 bits used for index calculations on very large images even on 32 bit systems. Its is sometimes needed for image positions and coordinates where a sign is not desired. Note that the signed MLint should normally be used for safe signed arithmetics, so MLuint is rarely used in ML contexts. It is typically used for index, size and range specifications without sign.

    An example of usage is the specification of file sizes which can be larger than 4 GB even on 32 bit systems and where negative sizes make no sense. Further examples are some function arguments in mlFileSystem.h .

  3. MLsoffset

    This signed ML offset type is a 32 bit signed integer on 32 bit platforms and a 64 bit signed integer on 64 bit platforms. This type is typically used for expressions in pointer offsets where 64 bit integers could cause warnings on 32 bit systems (because their range exceeds 32 bit pointer offsets). Such a type is necessary, because normal integers are not large enough on 64 bit systems; they remain 32 bit on most 64 bit platforms. In most ML sources, the MLsoffset type is used instead of the MLuoffset, because signed arithmetic is often required in image processing operations.

    An example of usage are index tables for kernel elements which are added to pointers (see project MLKernel and classes KernelBaseModule and KernelModule). These indexes must be able to describe negative and positive offsets on pointers which remain in the address space of the system.

  4. MLuoffset

    This unsigned ML offset type is a 32 bit unsigned integer on 32 bit platforms and an unsigned 64 bit one on 64 bit platforms. Such a type is necessary, because a normal unsigned integer is not large enough on 64 bit systems; it remains 32 bit even on many 64 bit platforms. Be careful when using this type in ML image processing, because in most contexts signed arithmetic is required when offsetting image pointers. Thus it is rarely used in ML contexts.

  5. MLssize_t

    The signed ML size type is a signed 32 bit size_t on 32 bit platforms and 64 bit size_t on 64 bit platforms. It corresponds to the normal ssize_t type on Unix platforms and to the SSIZE_T type on windows platforms. It is used for index, size and range specifications which do not exceed the signed range of the address space of a system. It is rarely used in ML contexts.

  6. MLsize_t

    The unsigned ML size type is an unsigned 32 bit size_t on 32 bit platforms and 64 bit size_t on 64 bit platforms. It corresponds to the normal size_t type available on most systems. It is typically used for index, size and range specifications which do not exceed the range of the address space of a system. The original size_t type is used in most ML code, because it is platform-independent.

[Note]Note

Internally (on 32 bit platforms), a size_t (and MLsize_t) is normally either an unsigned int or an unsigned long depending on compilers and platforms.

MLuoffset is always an unsigned integer type. Therefore size_t and MLuoffset do not behave identically everywhere (for example when they are passed as references) although their sizes and signs always come along with each other. So both types are useful and in a few cases they have to be distinguished carefully when implementing platform-independent code.

Of course, the same applies for the types MLssize_t and MLsoffset.