MeVisLab Toolbox 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< TVector6DBase< MLint > > ml::TVector6DBase< CompIntType >

Public Types

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

Public Member Functions

 TImageVector ()
 Constructor. All components are initialized to 0. More...
 
 TImageVector (const ParentClass &v)
 Copy constructor from Base class. More...
 
 TImageVector (const ComponentType i)
 Constructor which initializes all components to i. More...
 
template<typename T2IntType >
 TImageVector (const TImageVector< T2IntType > &v2)
 Copy constructor from another TVector of same or other integer type, values are cast. More...
 
 TImageVector (const ComponentType xp, const TImageVector< ComponentType > &p)
 Constructor which assigns X to x and copies other elements from p. More...
 
void set (const ComponentType v=0)
 Sets all components to v or - if v is not specified - to 0. More...
 
void set (const ParentClass &v)
 Like assignment operator. More...
 
 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]. More...
 
 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. More...
 
 TImageVector (const Vector6 &v6)
 Copies the six double components of v6 into x, ..., u, respectively. More...
 
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. More...
 
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. More...
 
bool iterate (const TImageVector< ComponentType > &ext)
 Coordinate incrementation/iterator function inside ext. More...
 
Vector6 toVector6 () const
 Returns the vector contents as Vector6. More...
 
Vector3 toVector3 () const
 Returns the x,y,z components as Vector3. More...
 
- Public Member Functions inherited from ml::TVector< TVector6DBase< MLint > >
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 + ... More...
 
 TVector ()
 Constructor. All components are initialized to 0. More...
 
 TVector (const ComponentType i)
 Constructor which initializes all components to i. More...
 
 TVector (const TVector< TVector6DBase< MLint > > &v2)
 
 TVector (const TVector< TVectorBase2 > &v2)
 Copy constructor from another TVector of same or other integer type, values are cast. More...
 
 TVector (const ComponentType xp, const TVector &p)
 Constructor which assigns X to x and copies other elements from p. More...
 
 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]. More...
 
TVector< TVector6DBase< MLint > > & operator= (const TVector< TVector6DBase< MLint > > &v2)
 
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. More...
 
void set (const ComponentType v=0)
 Sets all components to v or - if v is not specified - to 0. More...
 
void set (const TVector &v)
 Like assignment operator. More...
 
TVector< TVector6DBase< MLint > > operator+ (const TVector &b) const
 Add the corresponding component from b to each component. More...
 
TVector< TVector6DBase< MLint > > operator+ (const ComponentType b) const
 Calculates and returns the addition of each component of *this with scalar b. More...
 
TVector< TVector6DBase< MLint > > & operator+= (const TVector< TVector6DBase< MLint > > &b)
 Adds the corresponding component from b to each component. More...
 
TVector< TVector6DBase< MLint > > operator- (const TVector< TVector6DBase< MLint > > &b) const
 Calculates and returns *this-b. More...
 
TVector< TVector6DBase< MLint > > operator- (const ComponentType b) const
 Subtracts the scalar b from all components. More...
 
TVector< TVector6DBase< MLint > > operator- () const
 Performs an unary "-" on each vector component. More...
 
TVector< TVector6DBase< MLint > > & operator-= (const TVector< TVector6DBase< MLint > > &b)
 Subtracts the corresponding component from b from each component. More...
 
TVector< TVector6DBase< MLint > > operator* (const TVector< TVector6DBase< MLint > > &b) const
 Calculates and returns the multiplication of each component of this with its corresponding component from b. More...
 
TVector< TVector6DBase< MLint > > operator* (const ComponentType b) const
 Multiplies all components with scalar b. More...
 
TVector< TVector6DBase< MLint > > & operator*= (const TVector< TVector6DBase< MLint > > &b)
 Multiplies each component with its corresponding components from b. More...
 
TVector< TVector6DBase< MLint > > operator/ (const TVector< TVector6DBase< MLint > > &b) const
 Calculates and returns the division of each component of *this by its corresponding component from b. More...
 
TVector< TVector6DBase< MLint > > & operator/= (const TVector< TVector6DBase< MLint > > &b)
 Divides each component by its corresponding component from b. More...
 
bool operator== (const TVector< TVector6DBase< MLint > > &b) const
 Equality operator: Returns whether each component of a is equal to its corresponding component of b. More...
 
bool operator!= (const TVector< TVector6DBase< MLint > > &b) const
 Inequality operator: Returns whether any component differs from its corresponding component of b. More...
 
bool operator< (const TVector< TVector6DBase< MLint > > &b) const
 "Smaller" comparison operator, return whether the 'smaller' relation is valid for all components. More...
 
bool operator<= (const TVector< TVector6DBase< MLint > > &b) const
 "Smaller Or Equal" comparison operator, return whether the 'smaller or equal' relation is valid for all components. More...
 
bool operator> (const TVector< TVector6DBase< MLint > > &b) const
 "Greater" comparison operator, return whether the 'greater' relation is valid for all components. More...
 
bool operator>= (const TVector< TVector6DBase< MLint > > &b) const
 "Greater or Equal" comparison operator, return whether the 'greater or equal' relation is valid for all components. More...
 
TVector< TVector6DBase< MLint > > operator& (const TVector< TVector6DBase< MLint > > &b) const
 Performs a binary "And" of all components with the corresponding components of another Vector. More...
 
TVector< TVector6DBase< MLint > > operator& (const ComponentType b) const
 Performs a binary "And" of all components with an integer. More...
 
TVector< TVector6DBase< MLint > > operator| (const TVector< TVector6DBase< MLint > > &b) const
 Performs a binary "Or" of all components with the corresponding components of another Vector. More...
 
TVector< TVector6DBase< MLint > > operator| (const ComponentType b) const
 Performs a binary "Or" of all components with an integer. More...
 
TVector< TVector6DBase< MLint > > operator^ (const TVector< TVector6DBase< MLint > > &b) const
 Performs a binary "Xor" of all components with the corresponding components of another Vector. More...
 
TVector< TVector6DBase< MLint > > operator^ (const ComponentType b) const
 Performs a binary "Xor" of all components with an integer. More...
 
TVector< TVector6DBase< MLint > > & operator&= (const TVector< TVector6DBase< MLint > > &b)
 Performs a binary "And" of all components with the corresponding components of another Vector. More...
 
TVector< TVector6DBase< MLint > > & operator&= (const ComponentType b)
 Performs a binary "And" of all components with an integer. More...
 
TVector< TVector6DBase< MLint > > & operator|= (const TVector< TVector6DBase< MLint > > &b)
 Performs a binary "Or" of all components with the corresponding components of another Vector. More...
 
TVector< TVector6DBase< MLint > > & operator|= (const ComponentType b)
 Performs a binary "Or" of all components with an integer. More...
 
TVector< TVector6DBase< MLint > > & operator^= (const TVector< TVector6DBase< MLint > > &b)
 Performs a binary "Xor" of all components with the corresponding components of another Vector. More...
 
TVector< TVector6DBase< MLint > > & operator^= (const ComponentType b)
 Performs a binary "Xor" of all components with an integer. More...
 
TVector< TVector6DBase< MLint > > operator>> (const int b) const
 Performs a binary right shift ">>" on each vector component. More...
 
TVector< TVector6DBase< MLint > > operator<< (const int b) const
 Performs a binary left shift "<<" on each vector component. More...
 
TVector< TVector6DBase< MLint > > & operator>>= (const int b)
 Performs a binary right shift unary ">>=" on each vector component. More...
 
TVector< TVector6DBase< MLint > > & operator<<= (const int b)
 Performs a binary left shift unary "<<=" on each vector component. More...
 
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. More...
 
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. More...
 
MLint getMaxIdx () const
 Searches the maximum component and returns the index of its first occurrence. More...
 
ComponentType getMax () const
 Returns the maximum component value. More...
 
MLint getMinIdx () const
 Searches the minimum component and returns the index of its first occurrence. More...
 
ComponentType getMin () const
 Returns the minimum component value. More...
 
TVector< TVector6DBase< MLint > > getStrides (const ComponentType offset=1) const
 Interprets the vector as image extension and returns a stride vector. More...
 
TVector< TVector6DBase< MLint > > 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. More...
 
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. More...
 
bool hasNegativeComp () const
 Returns whether any component is negative. More...
 
bool allBiggerZero () const
 Returns whether all components > 0. More...
 
TVector< TVector6DBase< MLint > > divCeil (const TVector< TVector6DBase< MLint > > &b) const
 Returns the component wise division of the vector this by vector b with rounding up. More...
 
TVector< TVector6DBase< MLint > > compMin (const TVector< TVector6DBase< MLint > > &b) const
 Returns the component wise minimum of components of this and b. More...
 
TVector< TVector6DBase< MLint > > compMax (const TVector< TVector6DBase< MLint > > &b) const
 Returns the component wise maximum of components of this and b. More...
 
TVector< TVector6DBase< MLint > > compMod (const TVector< TVector6DBase< MLint > > &b) const
 Returns the rest of the division of this by b component wise. More...
 
TVector< TVector6DBase< MLint > > compAbs () const
 Returns a vector with all components of this replaced by their absolute values. More...
 
ComponentType compMul () const
 Returns the product of all components. There is no check for integer overflow. More...
 
ComponentType compSum () const
 Returns the sum of all components. There is no check for integer overflow. More...
 
ComponentType dot (const TVector< TVector6DBase< MLint > > &b) const
 Returns the scalar product of vectors this and b. There is no check for integer overflow. More...
 
void fillSmallerComps (const ComponentType threshold=0, const ComponentType fillVal=0)
 Sets the components which are smaller than threshold to fillVal. More...
 
void fillGreaterComps (const ComponentType threshold=0, const ComponentType fillVal=0)
 Sets the components which are greater than threshold to fillVal. More...
 
void fillEqualComps (const ComponentType threshold=0, const ComponentType fillVal=0)
 Sets the components which are equal to threshold to fillVal. More...
 

Static Public Member Functions

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

Additional Inherited Members

- Public Attributes inherited from ml::TVector6DBase< CompIntType >
union {
   struct {
      ComponentType   x
 X component of the vector. More...
 
      ComponentType   y
 Y component of the vector. More...
 
      ComponentType   z
 Z component of the vector. More...
 
      ComponentType   c
 Color component of the vector. More...
 
      ComponentType   t
 Time component of the vector. More...
 
      ComponentType   u
 Unit/Modality/User component of the vector. More...
 
   } 
 
   ComponentType   array [NumberOfDimensions]
 Provides public access to all members as an array; the caller must guarantee that indexes are within [0,...,MLMaxImageDimension-1]. More...
 
}; 
 
- Protected Member Functions inherited from ml::TVector6DBase< CompIntType >
 TVector6DBase ()
 Do not allow a direct creation of this class as object, because this container does not initialize itself, it must be done only by derived classes for performance reasons. More...
 

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.
ComponentType x
X component of the vector.
Definition: mlImageVector.h:59
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.

Referenced by ml::ITKIndexFromMLVector(), ml::ITKSizeFromMLVector(), ml::MLVectorFromITKIndex(), and ml::MLVectorFromITKSize().

◆ 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.

References ml::TVector6DBase< CompIntType >::c, ml::TVector6DBase< CompIntType >::t, ml::TVector6DBase< CompIntType >::u, ml::TVector6DBase< CompIntType >::x, ml::TVector6DBase< CompIntType >::y, and ml::TVector6DBase< CompIntType >::z.

◆ set() [1/3]

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

◆ 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: