ML Reference
ml::TImageVector< CompIntType > Class Template Reference

ImageVector is the 6D TVector specialization used by the ML for all image indexing. More...

#include <mlImageVector.h>

Inheritance diagram for ml::TImageVector< CompIntType >:
ml::TVector< TVectorBase >

Public Types

typedef TVector< TVector6DBase< CompIntType > > ParentClass
 Parent class of this class.
 
typedef ParentClass::ComponentType ComponentType
 Integer type used by this vector.
 
- Public Types inherited from ml::TVector< TVectorBase >
enum  { NumberOfDimensions = ParentClass::NumberOfDimensions }
 Enumerator defining the dimension of this class. More...
 
typedef TVectorBase::ComponentType ComponentType
 Integer type used by this vector.
 
typedef TVectorBase ParentClass
 Parent class of this class.
 

Public Member Functions

 TImageVector ()
 Constructor. All components are initialized to 0.
 
 TImageVector (const ParentClass &v)
 Copy constructor from Base class.
 
 TImageVector (const ComponentType i)
 Constructor which initializes all components to i.
 
template<typename T2IntType >
 TImageVector (const TImageVector< T2IntType > &v2)
 Copy constructor from another TVector of same or other integer type, values are cast.
 
 TImageVector (const ComponentType xp, const TImageVector< ComponentType > &p)
 Constructor which assigns X to x and copies other elements from p.
 
void set (const ComponentType v=0)
 Sets all components to v or - if v is not specified - to 0.
 
void set (const ParentClass &v)
 Like assignment operator.
 
 TImageVector (const MLint num, const ComponentType *const arr, const ComponentType deflt)
 Constructor which initializes the vector components by copying them from arr[0] ,..., arr[num-1].
 
 TImageVector (const ComponentType xp, const ComponentType yp, const ComponentType zp, const ComponentType cp, const ComponentType tp, const ComponentType up)
 Constructor which initializes all components with the values x, y, z, c, t and u.
 
 TImageVector (const Vector6 &v6)
 Copies the six double components of v6 into x, ..., u, respectively.
 
void set (const ComponentType vx, const ComponentType vy, const ComponentType vz=0, const ComponentType vc=0, const ComponentType vt=0, const ComponentType vu=0)
 Sets vector to (vx, vy, vz, vc, vt, vu). Not passed components are set to 0.
 
void get (ComponentType *const xp=nullptr, ComponentType *const yp=nullptr, ComponentType *const zp=nullptr, ComponentType *const cp=nullptr, ComponentType *const tp=nullptr, ComponentType *const up=nullptr) const
 Returns the subset of those Vector components whose corresponding pointers are not NULL.
 
bool iterate (const TImageVector< ComponentType > &ext)
 Coordinate incrementation/iterator function inside ext.
 
Vector6 toVector6 () const
 Returns the vector contents as Vector6.
 
Vector3 toVector3 () const
 Returns the x,y,z components as Vector3.
 
- Public Member Functions inherited from ml::TVector< TVectorBase >
std::string print (const std::string &openStr="", const std::string &sepStr=" ", const std::string &termStr="", const MLint16 numDigits=-1) const
 Returns the string openStr + v.array[0] + sepStr + ... + v.array[NumberOfDimensions-2] + sepStr + v.array[NumberOfDimensions-1] + termStr.
 
 TVector ()
 Constructor. All components are initialized to 0.
 
 TVector (const ComponentType i)
 Constructor which initializes all components to i.
 
 TVector (const TVector< TVectorBase > &v2)
 
TVector< TVectorBase > & operator= (const TVector< TVectorBase > &v2)
 
template<typename TVectorBase2 >
 TVector (const TVector< TVectorBase2 > &v2)
 Copy constructor from another TVector of same or other integer type, values are cast.
 
 TVector (const ComponentType xp, const TVector &p)
 Constructor which assigns X to x and copies other elements from p.
 
 TVector (const MLint num, const ComponentType *const arr, const ComponentType deflt)
 Constructor which initializes the vector components by copying them from arr[0] ,..., arr[num-1].
 
void copy (const MLint num, ComponentType *const arr) const
 Copy the first num elements from internal array into arr starting with array[0] to arr[0] to array[num-1] to arr[num-1], respectively.
 
void set (const ComponentType v=0)
 Sets all components to v or - if v is not specified - to 0.
 
void set (const TVector &v)
 Like assignment operator.
 
TVector< TVectorBase > operator+ (const TVector &b) const
 Add the corresponding component from b to each component.
 
TVector< TVectorBase > & operator+= (const TVector< TVectorBase > &b)
 Adds the corresponding component from b to each component.
 
TVector< TVectorBase > operator- (const TVector< TVectorBase > &b) const
 Calculates and returns *this-b.
 
TVector< TVectorBase > & operator-= (const TVector< TVectorBase > &b)
 Subtracts the corresponding component from b from each component.
 
TVector< TVectorBase > operator* (const TVector< TVectorBase > &b) const
 Calculates and returns the multiplication of each component of this with its corresponding component from b.
 
TVector< TVectorBase > & operator*= (const TVector< TVectorBase > &b)
 Multiplies each component with its corresponding components from b.
 
TVector< TVectorBase > operator+ (const ComponentType b) const
 Calculates and returns the addition of each component of *this with scalar b.
 
TVector< TVectorBase > operator- (const ComponentType b) const
 Subtracts the scalar b from all components.
 
TVector< TVectorBase > operator* (const ComponentType b) const
 Multiplies all components with scalar b.
 
TVector< TVectorBase > operator/ (const TVector< TVectorBase > &b) const
 Calculates and returns the division of each component of *this by its corresponding component from b.
 
TVector< TVectorBase > & operator/= (const TVector< TVectorBase > &b)
 Divides each component by its corresponding component from b.
 
bool operator== (const TVector< TVectorBase > &b) const
 Equality operator: Returns whether each component of a is equal to its corresponding component of b.
 
bool operator!= (const TVector< TVectorBase > &b) const
 Inequality operator: Returns whether any component differs from its corresponding component of b.
 
bool operator< (const TVector< TVectorBase > &b) const
 "Smaller" comparison operator, return whether the 'smaller' relation is valid for all components.
 
bool operator<= (const TVector< TVectorBase > &b) const
 "Smaller Or Equal" comparison operator, return whether the 'smaller or equal' relation is valid for all components.
 
bool operator> (const TVector< TVectorBase > &b) const
 "Greater" comparison operator, return whether the 'greater' relation is valid for all components.
 
bool operator>= (const TVector< TVectorBase > &b) const
 "Greater or Equal" comparison operator, return whether the 'greater or equal' relation is valid for all components.
 
TVector< TVectorBase > operator& (const TVector< TVectorBase > &b) const
 Performs a binary "And" of all components with the corresponding components of another Vector.
 
TVector< TVectorBase > operator| (const TVector< TVectorBase > &b) const
 Performs a binary "Or" of all components with the corresponding components of another Vector.
 
TVector< TVectorBase > operator^ (const TVector< TVectorBase > &b) const
 Performs a binary "Xor" of all components with the corresponding components of another Vector.
 
TVector< TVectorBase > & operator&= (const TVector< TVectorBase > &b)
 Performs a binary "And" of all components with the corresponding components of another Vector.
 
TVector< TVectorBase > & operator|= (const TVector< TVectorBase > &b)
 Performs a binary "Or" of all components with the corresponding components of another Vector.
 
TVector< TVectorBase > & operator^= (const TVector< TVectorBase > &b)
 Performs a binary "Xor" of all components with the corresponding components of another Vector.
 
TVector< TVectorBase > operator& (const ComponentType b) const
 Performs a binary "And" of all components with an integer.
 
TVector< TVectorBase > operator| (const ComponentType b) const
 Performs a binary "Or" of all components with an integer.
 
TVector< TVectorBase > operator^ (const ComponentType b) const
 Performs a binary "Xor" of all components with an integer.
 
TVector< TVectorBase > & operator&= (const ComponentType b)
 Performs a binary "And" of all components with an integer.
 
TVector< TVectorBase > & operator|= (const ComponentType b)
 Performs a binary "Or" of all components with an integer.
 
TVector< TVectorBase > & operator^= (const ComponentType b)
 Performs a binary "Xor" of all components with an integer.
 
TVector< TVectorBase > operator>> (const int b) const
 Performs a binary right shift ">>" on each vector component.
 
TVector< TVectorBase > operator<< (const int b) const
 Performs a binary left shift "<<" on each vector component.
 
TVector< TVectorBase > & operator>>= (const int b)
 Performs a binary right shift unary ">>=" on each vector component.
 
TVector< TVectorBase > & operator<<= (const int b)
 Performs a binary left shift unary "<<=" on each vector component.
 
TVector< TVectorBase > operator- () const
 Performs an unary "-" on each vector component.
 
ComponentType operator[] (const size_t i) const
 Constant indexing operator permits read access to array[0], ..., array[NumberOfDimensions-1] via indexes 0,1, ..., NumberOfDimensions-1, respectively.
 
ComponentTypeoperator[] (const size_t i)
 Indexing operator permits read and write access to array[0], ..., array[NumberOfDimensions-1] via indexes 0,1, ..., NumberOfDimensions-1, respectively.
 
MLint getMaxIdx () const
 Searches the maximum component and returns the index of its first occurrence.
 
ComponentType getMax () const
 Returns the maximum component value.
 
MLint getMinIdx () const
 Searches the minimum component and returns the index of its first occurrence.
 
ComponentType getMin () const
 Returns the minimum component value.
 
TVector< TVectorBase > getStrides (const ComponentType offset=1) const
 Interprets the vector as image extension and returns a stride vector.
 
TVector< TVectorBase > getVectorPosition (ComponentType offsetPos) const
 Interprets the vector as a stride vector of an image and returns the offset position offsetPos from the image origin to the coordinate specified by the vector.
 
MLint getExtDimension () const
 Returns the index to the highest vector component which is not 1 which is useful to get the real dimensional extent of an image.
 
bool hasNegativeComp () const
 Returns whether any component is negative.
 
bool allBiggerZero () const
 Returns whether all components > 0.
 
bool sanityCheckNumberOfVoxels () const
 Returns whether product of all components is in range of integer type.
 
TVector< TVectorBase > divCeil (const TVector< TVectorBase > &b) const
 Returns the component wise division of the vector this by vector b with rounding up.
 
TVector< TVectorBase > compMin (const TVector< TVectorBase > &b) const
 Returns the component wise minimum of components of this and b.
 
TVector< TVectorBase > compMax (const TVector< TVectorBase > &b) const
 Returns the component wise maximum of components of this and b.
 
TVector< TVectorBase > compMod (const TVector< TVectorBase > &b) const
 Returns the rest of the division of this by b component wise.
 
TVector< TVectorBase > compAbs () const
 Returns a vector with all components of this replaced by their absolute values.
 
ComponentType compMul () const
 Returns the product of all components. There is no check for integer overflow.
 
ComponentType compSum () const
 Returns the sum of all components. There is no check for integer overflow.
 
ComponentType dot (const TVector< TVectorBase > &b) const
 Returns the scalar product of vectors this and b. There is no check for integer overflow.
 
void fillSmallerComps (const ComponentType threshold=0, const ComponentType fillVal=0)
 Sets the components which are smaller than threshold to fillVal.
 
void fillGreaterComps (const ComponentType threshold=0, const ComponentType fillVal=0)
 Sets the components which are greater than threshold to fillVal.
 
void fillEqualComps (const ComponentType threshold=0, const ComponentType fillVal=0)
 Sets the components which are equal to threshold to fillVal.
 

Static Public Member Functions

Properties of an image of the ML.
static MLint dim ()
 Returns the dimension the ML calculates with.
 
- Static Public Member Functions inherited from ml::TVector< TVectorBase >
static TVector< TVectorBase > divCeil (const TVector< TVectorBase > &a, const TVector< TVectorBase > &b)
 Static version: Returns the component wise division of the vector a by vector b with rounding up.
 
static TVector< TVectorBase > compMin (const TVector< TVectorBase > &a, const TVector< TVectorBase > &b)
 Static version: Returns the component wise minimum of vectors a and b.
 
static TVector< TVectorBase > compMax (const TVector< TVectorBase > &a, const TVector< TVectorBase > &b)
 Static version: Returns the component wise maximum of vectors a and b.
 
static TVector< TVectorBase > compMod (const TVector< TVectorBase > &a, const TVector< TVectorBase > &b)
 Static version: Returns the rest dividing vector a by b component wise.
 
static TVector< TVectorBase > compAbs (const TVector< TVectorBase > &a)
 Static version: Returns a vector with all components of a replaced by their absolute values.
 
static ComponentType compMul (const TVector< TVectorBase > &a)
 Static version: Returns the product of all components without check for integer overflow.
 
static ComponentType compSum (const TVector< TVectorBase > &a)
 Static version: Returns the sum of all components without check for integer overflow.
 
static ComponentType dot (const TVector< TVectorBase > &a, const TVector< TVectorBase > &b)
 Static version: Returns the scalar product of vectors a and b without check for integer overflow.
 

Detailed Description

template<typename CompIntType = MLint>
class ml::TImageVector< CompIntType >

ImageVector is the 6D TVector specialization used by the ML for all image indexing.

It uses MLint as default for CompIntType and TVector6DBase<CompIntType> as container type for specialized access to array member with x,y,z,c,t, and u.

In contrast to the base class TVector the members are specialized to MLMaxImageDimension dimensions to implement dedicated functionality for ML images. This class can also be instantiated with arguments or other CompIntType arguments to compile with an arbitrary integer base type.

Example for vector initialization:

p.x=1; p.y=2; p.z=3; p.c=4; p.t=5; p.u=6;
// or
p[0]=3; p[1]=5; p[2]=7; p[3]=9; p[4]=11; p[5]=13;
// or
p.set(3, 5, 7, 9, 11, 13);
// or
ImageVector q(4, p);
// or
p = ImageVector(1,2,3,4,5,6);
// or
ImageVector p(1,2,3,4,5,6);
void set(const ComponentType v=0)
Sets all components to v or - if v is not specified - to 0.
TImageVector< MLint > ImageVector
Defines the standard ImageVector type which is used by the ML for indexing and coordinates.

Notes:

  • operator= can safely be used although not implemented explicitly.
  • This class is used to describe points, coordinates and subimage regions easily, in a uniform manner and independent of the exact number of supported dimensions.
  • All coordinate components are explicitly public and may used so without limitation of class functionality.
  • Even method parameters are implemented as "const" to give compilers maximum information to optimize.
  • In most methods this class is not traced nor ML_TRY/CATCH mechanisms are used, because:
  • it is heavily used in time critical positions for all image processing aspects in ML modules.
  • it should be possible to detect/debug errors easily on next higher function which then should be traced/try/caught.

Definition at line 135 of file mlImageVector.h.

Member Typedef Documentation

◆ ComponentType

template<typename CompIntType = MLint>
typedef ParentClass::ComponentType ml::TImageVector< CompIntType >::ComponentType

Integer type used by this vector.

Definition at line 142 of file mlImageVector.h.

◆ ParentClass

template<typename CompIntType = MLint>
typedef TVector<TVector6DBase<CompIntType> > ml::TImageVector< CompIntType >::ParentClass

Parent class of this class.

Definition at line 139 of file mlImageVector.h.

Constructor & Destructor Documentation

◆ TImageVector() [1/8]

template<typename CompIntType = MLint>
ml::TImageVector< CompIntType >::TImageVector ( )
inline

Constructor. All components are initialized to 0.

Definition at line 154 of file mlImageVector.h.

◆ TImageVector() [2/8]

template<typename CompIntType = MLint>
ml::TImageVector< CompIntType >::TImageVector ( const ParentClass & v)
inline

Copy constructor from Base class.

This allows the usage of the ParentClass objects of the same ComponentType in operators using the TImageVector.

Definition at line 158 of file mlImageVector.h.

◆ TImageVector() [3/8]

template<typename CompIntType = MLint>
ml::TImageVector< CompIntType >::TImageVector ( const ComponentType i)
inlineexplicit

Constructor which initializes all components to i.

Definition at line 161 of file mlImageVector.h.

◆ TImageVector() [4/8]

template<typename CompIntType = MLint>
template<typename T2IntType >
ml::TImageVector< CompIntType >::TImageVector ( const TImageVector< T2IntType > & v2)
inlineexplicit

Copy constructor from another TVector of same or other integer type, values are cast.

Only valid elements are copied if vectors have different lengths.

Definition at line 166 of file mlImageVector.h.

◆ TImageVector() [5/8]

template<typename CompIntType = MLint>
ml::TImageVector< CompIntType >::TImageVector ( const ComponentType xp,
const TImageVector< ComponentType > & p )
inline

Constructor which assigns X to x and copies other elements from p.

Definition at line 169 of file mlImageVector.h.

◆ TImageVector() [6/8]

template<typename CompIntType = MLint>
ml::TImageVector< CompIntType >::TImageVector ( const MLint num,
const ComponentType *const arr,
const ComponentType deflt )
inline

Constructor which initializes the vector components by copying them from arr[0] ,..., arr[num-1].

All other elements are initialized to the value deflt. arr must have at least num elements.

Definition at line 180 of file mlImageVector.h.

◆ TImageVector() [7/8]

template<typename CompIntType = MLint>
ml::TImageVector< CompIntType >::TImageVector ( const ComponentType xp,
const ComponentType yp,
const ComponentType zp,
const ComponentType cp,
const ComponentType tp,
const ComponentType up )
inline

Constructor which initializes all components with the values x, y, z, c, t and u.

Definition at line 185 of file mlImageVector.h.

◆ TImageVector() [8/8]

template<typename CompIntType = MLint>
ml::TImageVector< CompIntType >::TImageVector ( const Vector6 & v6)
inlineexplicit

Copies the six double components of v6 into x, ..., u, respectively.

A simple cast is performed to convert the doubles to the ComponentType type.

Definition at line 198 of file mlImageVector.h.

Member Function Documentation

◆ dim()

template<typename CompIntType = MLint>
static MLint ml::TImageVector< CompIntType >::dim ( )
inlinestatic

Returns the dimension the ML calculates with.

Definition at line 149 of file mlImageVector.h.

References ml::MLMaxImageDimension.

◆ get()

template<typename CompIntType = MLint>
void ml::TImageVector< CompIntType >::get ( ComponentType *const xp = nullptr,
ComponentType *const yp = nullptr,
ComponentType *const zp = nullptr,
ComponentType *const cp = nullptr,
ComponentType *const tp = nullptr,
ComponentType *const up = nullptr ) const
inline

Returns the subset of those Vector components whose corresponding pointers are not NULL.

Definition at line 221 of file mlImageVector.h.

◆ iterate()

template<typename CompIntType = MLint>
bool ml::TImageVector< CompIntType >::iterate ( const TImageVector< ComponentType > & ext)
inline

Coordinate incrementation/iterator function inside ext.

Increments x by 1 until it overflows in x (limited by ext). On overflow x is set to 0 and y is incremented by 1 etc. If *this == ext is reached after incrementation then the vector is reset to (0,0,0,0,0,0) and true is returned, otherwise false. Note: Function works sensible only if *this is inside [(0,0,0,0,0,0), (ext.x, ... ,ext.u)[ and if &ext if != this.

Definition at line 239 of file mlImageVector.h.

◆ set() [1/3]

template<typename CompIntType = MLint>
void ml::TImageVector< CompIntType >::set ( const ComponentType v = 0)
inline

Sets all components to v or - if v is not specified - to 0.

Definition at line 172 of file mlImageVector.h.

Referenced by ml::TSubImage< DATATYPE >::calculateMinMax(), ml::TSubImageBox< intT >::makeEmpty(), and ml::SubImage::setExtent().

◆ set() [2/3]

template<typename CompIntType = MLint>
void ml::TImageVector< CompIntType >::set ( const ComponentType vx,
const ComponentType vy,
const ComponentType vz = 0,
const ComponentType vc = 0,
const ComponentType vt = 0,
const ComponentType vu = 0 )
inline

Sets vector to (vx, vy, vz, vc, vt, vu). Not passed components are set to 0.

Definition at line 209 of file mlImageVector.h.

◆ set() [3/3]

template<typename CompIntType = MLint>
void ml::TImageVector< CompIntType >::set ( const ParentClass & v)
inline

Like assignment operator.

Definition at line 175 of file mlImageVector.h.

◆ toVector3()

template<typename CompIntType = MLint>
Vector3 ml::TImageVector< CompIntType >::toVector3 ( ) const
inline

Returns the x,y,z components as Vector3.

Definition at line 275 of file mlImageVector.h.

◆ toVector6()

template<typename CompIntType = MLint>
Vector6 ml::TImageVector< CompIntType >::toVector6 ( ) const
inline

Returns the vector contents as Vector6.

Definition at line 264 of file mlImageVector.h.


The documentation for this class was generated from the following file: