The library infrastructure » Support types module
#include "diplib.h"

Types used for image samples (pixels), and related support functionality

Namespaces

namespace dip::Option::CmpProp
Namespace to emulate an enumerator, contains values

Classes

template<typename T>
class dip::DimensionArray
A dynamic array type optimized for few elements.
struct dip::Range
Used in indexing to indicate a regular subset of pixels along one image dimension.
struct dip::RegressionParameters
Represents the result of a 2D regression analysis: \(y = a + bx\) .

Aliases

using dip::Option::CmpPropFlags = dip::detail::Options<CmpPropEnumerator>
Determines which properties to compare. Combines multiple dip::Option::CmpPropEnumerator values, predefined values are in CmpProp.
using dip::sint = std::ptrdiff_t
An integer type to be used for strides and similar measures.
using dip::uint = std::size_t
An integer type to be used for sizes and the like.
using dip::IntegerArray = DimensionArray<dip::sint>
An array to hold strides, filter sizes, etc.
using dip::UnsignedArray = DimensionArray<dip::uint>
An array to hold dimensions, dimension lists, etc.
using dip::FloatArray = DimensionArray<dip::dfloat>
An array to hold filter parameters.
using dip::BooleanArray = DimensionArray<bool>
An array used as a dimension selector.
using dip::CoordinateArray = std::vector<UnsignedArray>
An array of pixel coordinates.
using dip::FloatCoordinateArray = std::vector<FloatArray>
An array of subpixel coordinates.
using dip::String = std::string
A string, used to specify an option
using dip::StringArray = std::vector<String>
An array of strings, used to specify an option per dimension
using dip::StringSet = std::set<String>
A collection of strings, used to specify multiple independent options
using dip::RangeArray = DimensionArray<dip::Range>
An array of ranges

Enums

enum class dip::Option::ThrowException: int{ DONT_THROW, DO_THROW }
Some functions that check for a condition optionally throw an exception if that condition is not met.
enum class dip::Option::AllowSingletonExpansion: int{ DONT_ALLOW, DO_ALLOW }
The function dip::Image::CheckIsMask takes this option to control how sizes are compared.
enum class dip::Option::AcceptDataTypeChange: int{ DONT_ALLOW, DO_ALLOW }
The function dip::Image::ReForge takes this option to control how to handle protected images.
enum class dip::Option::CropLocation: int{ CENTER, MIRROR_CENTER, TOP_LEFT, BOTTOM_RIGHT }
The function dip::Image::Crop takes this option to control which pixels are taken.
enum class dip::Option::CmpPropEnumerator: int{ DataType, Dimensionality, Sizes, Strides, TensorShape, TensorElements, TensorStride, ColorSpace, PixelSize }
Determines which properties to compare.

Functions

template<typename T>
void dip::sortIndices(DimensionArray<typename DimensionArray<T>::size_type>& indices, DimensionArray<T> const& data)
Sorts the indices array with indices into the data array, from smallest to largest. The sort is stable.
template<typename T>
auto dip::SquareDistance(DimensionArray<T> const& v1, DimensionArray<T> const& v2) -> double
Computes the Square Euclidean distance between two points.
template<typename T>
auto dip::Distance(DimensionArray<T> const& v1, DimensionArray<T> const& v2) -> double
Computes the Square Euclidean distance between two points.
template<typename T>
void dip::ArrayUseParameter(DimensionArray<T>& array, dip::uint nDims, T defaultValue = {})
Check the length of an array, and extend it if necessary and possible.
auto dip::BooleanFromString(dip::String const& input, dip::String const& trueString, dip::String const& falseString) -> bool
Translates a string input parameter that is meant as a boolean value.
auto dip::StringCompareCaseInsensitive(dip::String const& string1, dip::String const& string2) -> bool
A case-insensitive string comparison, use only with ASCII characters!
void dip::ToLowerCase(dip::String& string)
Convert a string to lower case, use only with ASCII characters!
void dip::ToUpperCase(dip::String& string)
Convert a string to upper case, use only with ASCII characters!

Operators

template<typename T>
auto dip::operator==(DimensionArray<T> const& lhs, DimensionArray<T> const& rhs) -> bool
Compares two arrays, returns true only if they have the same size and contain the same values.
template<typename T>
auto dip::operator!=(DimensionArray<T> const& lhs, DimensionArray<T> const& rhs) -> bool
Compares two arrays, returns true if they have different size and/or contain different values.
template<typename T>
auto dip::operator>(DimensionArray<T> const& lhs, DimensionArray<T> const& rhs) -> bool
Compares two arrays, returns true only if they have the same size and all lhs elements are larger than all rhs elements.
template<typename T>
auto dip::operator<(DimensionArray<T> const& lhs, DimensionArray<T> const& rhs) -> bool
Compares two arrays, returns true only if they have the same size and all lhs elements are smaller than all rhs elements.
template<typename T>
auto dip::operator>=(DimensionArray<T> const& lhs, DimensionArray<T> const& rhs) -> bool
Compares two arrays, returns true only if they have the same size and all lhs elements are larger or equal than all rhs elements.
template<typename T>
auto dip::operator<=(DimensionArray<T> const& lhs, DimensionArray<T> const& rhs) -> bool
Compares two arrays, returns true only if they have the same size and all lhs elements are smaller or equal than all rhs elements.
template<typename T>
auto dip::operator==(DimensionArray<T> const& lhs, T const& rhs) -> DimensionArray<bool>
Compares an array to a scalar, returns a boolean array.
template<typename T>
auto dip::operator!=(DimensionArray<T> const& lhs, T const& rhs) -> DimensionArray<bool>
Compares an array to a scalar, returns a boolean array.
template<typename T>
auto dip::operator>(DimensionArray<T> const& lhs, T const& rhs) -> DimensionArray<bool>
Compares an array to a scalar, returns a boolean array.
template<typename T>
auto dip::operator<(DimensionArray<T> const& lhs, T const& rhs) -> DimensionArray<bool>
Compares an array to a scalar, returns a boolean array.
template<typename T>
auto dip::operator>=(DimensionArray<T> const& lhs, T const& rhs) -> DimensionArray<bool>
Compares an array to a scalar, returns a boolean array.
template<typename T>
auto dip::operator<=(DimensionArray<T> const& lhs, T const& rhs) -> DimensionArray<bool>
Compares an array to a scalar, returns a boolean array.
template<typename T>
auto dip::operator<<(std::ostream& os, DimensionArray<T> const& array) -> std::ostream&
Writes the array to a stream

Variables

dip::Option::CmpPropFlags const dip::Option::CmpProp::DataType constexpr
CmpPropEnumerator::DataType.
dip::Option::CmpPropFlags const dip::Option::CmpProp::Dimensionality constexpr
CmpPropEnumerator::Dimensionality.
dip::Option::CmpPropFlags const dip::Option::CmpProp::Sizes constexpr
CmpPropEnumerator::Sizes.
dip::Option::CmpPropFlags const dip::Option::CmpProp::Strides constexpr
CmpPropEnumerator::Strides.
dip::Option::CmpPropFlags const dip::Option::CmpProp::TensorShape constexpr
CmpPropEnumerator::TensorShape.
dip::Option::CmpPropFlags const dip::Option::CmpProp::TensorElements constexpr
CmpPropEnumerator::TensorElements.
dip::Option::CmpPropFlags const dip::Option::CmpProp::TensorStride constexpr
CmpPropEnumerator::TensorStride.
dip::Option::CmpPropFlags const dip::Option::CmpProp::ColorSpace constexpr
CmpPropEnumerator::ColorSpace.
dip::Option::CmpPropFlags const dip::Option::CmpProp::PixelSize constexpr
CmpPropEnumerator::PixelSize.
dip::Option::CmpPropFlags const dip::Option::CmpProp::AllSizes constexpr
Sizes + TensorElements.
dip::Option::CmpPropFlags const dip::Option::CmpProp::Samples constexpr
DataType + Sizes + TensorElements.
dip::Option::CmpPropFlags const dip::Option::CmpProp::Shape constexpr
DataType + Sizes + TensorShape.
dip::Option::CmpPropFlags const dip::Option::CmpProp::Full constexpr
Shape + Strides + TensorStride.
dip::Option::CmpPropFlags const dip::Option::CmpProp::All constexpr
Shape + ColorSpace + PixelSize.

Macros

#define DIP_DECLARE_OPTIONS
Declare a type used to pass enumerated options to a function or class.

Class documentation

struct dip::RegressionParameters

Represents the result of a 2D regression analysis: \(y = a + bx\) .

Variables
dip::dfloat intercept intercept, \(a\) .
dip::dfloat slope slope, \(b\) .

Enum documentation

enum class dip::Option::ThrowException: int

Some functions that check for a condition optionally throw an exception if that condition is not met.

Enumerators
DONT_THROW = 0 Do not throw and exception, return false if the condition is not met.
DO_THROW = 1 Throw an exception if the condition is not met.

enum class dip::Option::AllowSingletonExpansion: int

The function dip::Image::CheckIsMask takes this option to control how sizes are compared.

Enumerators
DONT_ALLOW = 0 Do not allow singleton expansion.
DO_ALLOW = 1 Allow singleton expansion.

enum class dip::Option::AcceptDataTypeChange: int

The function dip::Image::ReForge takes this option to control how to handle protected images.

Enumerators
DONT_ALLOW = 0 Do not allow data type change, the output image is always of the requested type.
DO_ALLOW = 1 Allow data type change, if the output image is protected, it will be used as is.

enum class dip::Option::CropLocation: int

The function dip::Image::Crop takes this option to control which pixels are taken.

Enumerators
CENTER = 0 The pixel at the origin of the input image is also at the origin in the output image.
MIRROR_CENTER = 1 Same as CENTER, but for even-sized images, the origin is presumed to be left of center, rather than right of center.
TOP_LEFT = 2 The corner of the image at coordinates {0,0,0…} is kept in the corner.
BOTTOM_RIGHT = 3 The corner of the image opposite that of TOP_LEFT is kept in the corner.

enum class dip::Option::CmpPropEnumerator: int

Determines which properties to compare.

Implicitly casts to dip::Option::CmpPropFlags. Combine constants together with the + operator.

Enumerators
DataType = 0 Compares data type
Dimensionality = 1 Compares number of dimensions
Sizes = 2 Compares image size
Strides = 3 Compares image strides
TensorShape = 4 Compares tensor size and shape
TensorElements = 5 Compares number of tensor elements
TensorStride = 6 Compares tensor stride
ColorSpace = 7 Compares color space
PixelSize = 8 Compares pixel size

Function documentation

template<typename T>
void dip::ArrayUseParameter(DimensionArray<T>& array, dip::uint nDims, T defaultValue = {})

Check the length of an array, and extend it if necessary and possible.

This function is used where a function’s input parameter is an array that is supposed to match the image dimensionality nDims. The user can give an array of that length, or an array with a single value, which will be used for all dimensions, or an empty array, in which case the default value defaultValue will be used for all dimensions.

Macro documentation

#define DIP_DECLARE_OPTIONS

Declare a type used to pass enumerated options to a function or class.

This macro is used as follows:

enum class MyOption { clean, fresh, shine };
DIP_DECLARE_OPTIONS( MyOption, MyOptions )

MyOptions will be a type that combines one or more values from MyOption. These values can be combined using the + operator. A variable of type MyOptions can be tested using its Contains method which returns a bool:

MyOptions opts {};                            // No options are set
opts = MyOption::fresh;                       // Set only one option
opts = MyOption::clean + MyOption::shine;     // Set only these two options
if( opts.Contains( MyOption::clean )) {...}   // Test to see if `MyOption::clean` is set

The Contains method returns true only of all flags specified in the input are set. The == operator returns true only if the two operands contain exactly the same set of flags.

Note that there should be no more than 32 options within the enumerator.

This macro will not work within a class definition – You will need to manually declare the type alias and define the operator outside of the class.