dip::DataType struct
#include <diplib.h>

DataType objects are used to indicate what the data type of an image is.

It is a simple enumeration type, but with some added member functions that can be used to query the data type. A series of constant expressions (dip::DT_XXX) have been defined that should be used when specifying a data type, there is never a need to call the constructors to this class explicitly. It is possible to call DataType member functions on these constants:

dip::DT_BIN.SizeOf();

See Pixel data types for more information about image sample data types.

Constructors, destructors, conversion operators

template<typename T>
DataType(T) explicit constexpr
Get the data type value of any expression, as long as that expression is of one of the known data types.
DataType(String const& name) explicit
A string can be cast to a data type. See Pixel data types for recognized strings.
operator int() const constexpr
DataType objects implicitly convert to the enumeration integer.
operator Classes() const constexpr
Implicit conversion to dip::DataType::Classes options class.

Public functions

void swap(DataType& other)
Swaps the values of this and other
auto operator==(DataType other) const -> bool
DataType objects can be compared.
auto Name() const -> char const*
Returns a C-style string constant with a representation of the data type name. See Pixel data types for returned strings.
auto SizeOf() const -> dip::uint
Returns the size in bytes of the data type.
auto IsInRange(dip::sint value) const -> bool
Returns true if the integer value is within the range representable by the data type.
auto IsInRange(dip::uint value) const -> bool
Returns true if the integer value is within the range representable by the data type.
auto Real() -> DataType
Returns the real data type corresponding to a complex data type.
auto IsA(Classes cls) const -> bool constexpr
Returns true if the data type is of the given class.
auto IsBinary() const -> bool constexpr
Returns true if the data type is binary.
auto IsUInt() const -> bool constexpr
Returns true if the data type is an unsigned integer type.
auto IsSInt() const -> bool constexpr
Returns true if the data type is a signed integer type.
auto IsInteger() const -> bool constexpr
Returns true if the data type is an integer type.
auto IsFloat() const -> bool constexpr
Returns true if the data type is a floating point type.
auto IsReal() const -> bool constexpr
Returns true if the data type is real (floating point or integer).
auto IsFlex() const -> bool constexpr
Returns true if the data type is one of the "flex" types (floating point or complex).
auto IsFlexBin() const -> bool constexpr
Returns true if the data type is floating point, complex or binary.
auto IsComplex() const -> bool constexpr
Returns true if the data type is complex.
auto IsUnsigned() const -> bool constexpr
Returns true if the data type is an unsigned type (binary or unsigned integer).
auto IsSigned() const -> bool constexpr
Returns true if the data type is a signed type (signed integer, floating point or complex)

Public static functions

static auto SuggestInteger(DataType type) -> DataType
Returns an integer type that is most suitable to hold samples of type. See Pixel data types.
static auto SuggestSigned(DataType type) -> DataType
Returns a signed type that is most suitable to hold samples of type. See Pixel data types.
static auto SuggestFloat(DataType type) -> DataType
Returns a suitable floating-point type that can hold the samples of type. See Pixel data types.
static auto SuggestDouble(DataType type) -> DataType
Returns a suitable double precision floating-point type (real or complex) that can hold large sums of type. See Pixel data types.
static auto SuggestComplex(DataType type) -> DataType
Returns a suitable complex type that can hold the samples of type. See Pixel data types.
static auto SuggestFlex(DataType type) -> DataType
Returns a suitable floating-point or complex type that can hold the samples of type. See Pixel data types.
static auto SuggestFlexBin(DataType type) -> DataType
Returns a suitable floating-point, complex or binary type that can hold the samples of type. See Pixel data types.
static auto SuggestAbs(DataType type) -> DataType
Returns a suitable type that can hold samples of type abs(type). See Pixel data types.
static auto SuggestReal(DataType type) -> DataType
Returns a suitable real type that can hold the samples of type. See Pixel data types.
static auto SuggestArithmetic(DataType type1, DataType type2) -> DataType
Returns a suitable floating-point, complex or binary type (FlexBin) that can hold the result of an arithmetic computation performed with the two data types.
static auto SuggestDyadicOperation(DataType type1, DataType type2) -> DataType
Returns a suitable type that can hold any samples of the two data types.

Function documentation

static DataType dip::DataType::SuggestArithmetic(DataType type1, DataType type2)

Returns a suitable floating-point, complex or binary type (FlexBin) that can hold the result of an arithmetic computation performed with the two data types.

The output value given type1 and type2 is as follows. First the two arguments are promoted using dip::DataType::SuggestFlexBin (which converts 8 and 16-bit integers to DT_SFLOAT and 32 and 64-bit integers to DT_DFLOAT), and the resulting two types are looked up in this table (note that the order of the two inputs is irrelevant, and the table is symmetric):

 DT_BINDT_SFLOATDT_DFLOATDT_SCOMPLEXDT_DCOMPLEX
DT_BINDT_BINDT_SFLOATDT_DFLOATDT_SCOMPLEXDT_DCOMPLEX
DT_SFLOATDT_SFLOATDT_SFLOATDT_DFLOATDT_SCOMPLEXDT_DCOMPLEX
DT_DFLOATDT_DFLOATDT_DFLOATDT_DFLOATDT_DCOMPLEXDT_DCOMPLEX
DT_SCOMPLEXDT_SCOMPLEXDT_SCOMPLEXDT_DCOMPLEXDT_SCOMPLEXDT_DCOMPLEX
DT_DCOMPLEXDT_DCOMPLEXDT_DCOMPLEXDT_DCOMPLEXDT_DCOMPLEXDT_DCOMPLEX

static DataType dip::DataType::SuggestDyadicOperation(DataType type1, DataType type2)

Returns a suitable type that can hold any samples of the two data types.

The output value given type1 and type2 is as follows (note that the order of the two inputs is irrelevant, and the table is symmetric):

 DT_BINDT_UINT8DT_SINT8DT_UINT16DT_SINT16DT_UINT32DT_SINT32DT_UINT64DT_SINT64DT_SFLOATDT_DFLOATDT_SCOMPLEXDT_DCOMPLEX
DT_BINDT_BINDT_UINT8DT_SINT8DT_UINT16DT_SINT16DT_UINT32DT_SINT32DT_UINT64DT_SINT64DT_SFLOATDT_DFLOATDT_SCOMPLEXDT_DCOMPLEX
DT_UINT8DT_UINT8DT_UINT8DT_SINT16DT_UINT16DT_SINT16DT_UINT32DT_SINT32DT_UINT64DT_SINT64DT_SFLOATDT_DFLOATDT_SCOMPLEXDT_DCOMPLEX
DT_SINT8DT_SINT8DT_SINT16DT_SINT8DT_SINT32DT_SINT16DT_SINT64DT_SINT32DT_SINT64DT_SINT64DT_SFLOATDT_DFLOATDT_SCOMPLEXDT_DCOMPLEX
DT_UINT16DT_UINT16DT_UINT16DT_SINT32DT_UINT16DT_SINT32DT_UINT32DT_SINT32DT_UINT64DT_SINT64DT_SFLOATDT_DFLOATDT_SCOMPLEXDT_DCOMPLEX
DT_SINT16DT_SINT16DT_SINT16DT_SINT16DT_SINT32DT_SINT16DT_SINT64DT_SINT32DT_SINT64DT_SINT64DT_SFLOATDT_DFLOATDT_SCOMPLEXDT_DCOMPLEX
DT_UINT32DT_UINT32DT_UINT32DT_SINT64DT_UINT32DT_SINT64DT_UINT32DT_SINT64DT_UINT64DT_SINT64DT_DFLOATDT_DFLOATDT_DCOMPLEXDT_DCOMPLEX
DT_SINT32DT_SINT32DT_SINT32DT_SINT32DT_SINT32DT_SINT32DT_SINT64DT_SINT32DT_SINT64DT_SINT64DT_DFLOATDT_DFLOATDT_DCOMPLEXDT_DCOMPLEX
DT_UINT64DT_UINT64DT_UINT64DT_SINT64DT_UINT64DT_SINT64DT_UINT64DT_SINT64DT_UINT64DT_SINT64DT_DFLOATDT_DFLOATDT_DCOMPLEXDT_DCOMPLEX
DT_SINT64DT_SINT64DT_SINT64DT_SINT64DT_SINT64DT_SINT64DT_SINT64DT_SINT64DT_SINT64DT_SINT64DT_DFLOATDT_DFLOATDT_DCOMPLEXDT_DCOMPLEX
DT_SFLOATDT_SFLOATDT_SFLOATDT_SFLOATDT_SFLOATDT_SFLOATDT_DFLOATDT_DFLOATDT_DFLOATDT_DFLOATDT_SFLOATDT_DFLOATDT_SCOMPLEXDT_DCOMPLEX
DT_DFLOATDT_DFLOATDT_DFLOATDT_DFLOATDT_DFLOATDT_DFLOATDT_DFLOATDT_DFLOATDT_DFLOATDT_DFLOATDT_DFLOATDT_DFLOATDT_DCOMPLEXDT_DCOMPLEX
DT_SCOMPLEXDT_SCOMPLEXDT_SCOMPLEXDT_SCOMPLEXDT_SCOMPLEXDT_SCOMPLEXDT_DCOMPLEXDT_DCOMPLEXDT_DCOMPLEXDT_DCOMPLEXDT_SCOMPLEXDT_DCOMPLEXDT_SCOMPLEXDT_DCOMPLEX
DT_DCOMPLEXDT_DCOMPLEXDT_DCOMPLEXDT_DCOMPLEXDT_DCOMPLEXDT_DCOMPLEXDT_DCOMPLEXDT_DCOMPLEXDT_DCOMPLEXDT_DCOMPLEXDT_DCOMPLEXDT_DCOMPLEXDT_DCOMPLEXDT_DCOMPLEX