MeVisLabToolboxReference
ml::TSubImageBox< intT > Class Template Reference

This class defines a rectangular subimage region of standard ML dimensions. More...

#include <mlSubImageBox.h>

Public Types

typedef TImageVector< intT > VectorType
 The vector type used for corner members v1 and v2. More...
 

Public Member Functions

Constructors
 TSubImageBox ()
 Constructor: Creates empty subimage region by setting v1 to (0,...,0) and v2 to (-1,...,-1). More...
 
 TSubImageBox (const VectorType &vector1, const VectorType &vector2)
 Constructor: Creates subimage from two passed vectors vector1 and vector2. More...
 
 TSubImageBox (const VectorType extent)
 Constructor: Creates subimage from an extent, i.e., v1 is set to (0,...,0) and v2 is set to (extent.x-1,...,extent.u-1). More...
 
Properties and operators
bool operator== (const TSubImageBox< intT > &box) const
 Returns true if box has identical components like this, otherwise returns false. More...
 
bool operator!= (const TSubImageBox< intT > &box) const
 Returns false if box has identical components like this, otherwise return true. More...
 
bool isEmpty () const
 Returns true if subimage region is empty, i.e., if any of the components of v1 is greater than the corresponding component of v2. More...
 
intT getNumVoxels () const
 Returns number of voxels in the subimage region, i.e., the product of all extents if this is not empty; otherwise 0 is returned. More...
 
VectorType getExtent () const
 Returns the extents of the subimage region. More...
 
void correct ()
 Swaps all components where v1. More...
 
Deprecated
intT getSize () const
 
VectorType getExt () const
 

Public Attributes

VectorType v1
 Corner v1 of the subimage region (included in region). More...
 
VectorType v2
 Corner v2 of the subimage region (also included in region!). More...
 

Functions and methods on TSubImageBox<intT>.

void makeEmpty ()
 Makes box empty by setting v1 to (0,...,0) and v2 to (-1,...,-1), i.e., constructor state is restored. More...
 
TSubImageBox< intT > intersect (const TSubImageBox< intT > &box) const ML_RETURN_VALUE_SHOULD_BE_USED
 Member function version to intersect this with a given box. More...
 
TSubImageBox< intT > merge (const TSubImageBox< intT > &box) const ML_RETURN_VALUE_SHOULD_BE_USED
 Member function version to merge this with a given box. More...
 
VectorType clamp (const VectorType &position) const
 Clamps the position to the nearest position inside the SubImageBox. More...
 
bool contains (const VectorType &position) const
 Returns true if position is inside the SubImageBox. More...
 
void translate (const VectorType &offsetVector)
 Shifts the whole box by an offset given by offsetVector. More...
 
static TSubImageBox< intT > intersect (const TSubImageBox< intT > &box1, const TSubImageBox< intT > &box2) ML_RETURN_VALUE_SHOULD_BE_USED
 Returns the overlapping region of subimage regions box1 and box2. More...
 
static TSubImageBox< intT > merge (const TSubImageBox< intT > &box1, const TSubImageBox< intT > &box2)
 Returns the region containing both subimage regions box1 and box2. More...
 
static void get3DCorners (const TSubImageBox< intT > &box, VectorType corners[8])
 Returns the corners of the 3d box extents of box in corners. More...
 

Detailed Description

template<typename intT>
class ml::TSubImageBox< intT >

This class defines a rectangular subimage region of standard ML dimensions.

The subimage region is defined by two corners given by 2 objects of class TVector.

Thread-safety: This class is reentrant.

Notes:

  • operator= can safely be used although not implemented explicitly.
  • This class is used to describe subimage regions easily, portable and independent of the number of dimensions.

Example to initialize a subimage region:

loc.v1.x=0; loc.v1.y=0; loc.v1.z=0; loc.v1.c=0; loc.v1.t=0; loc.v1.u=0;
loc.v2.x=5; loc.v2.y=5; loc.v2.z=5; loc.v2.c=0; loc.v2.t=0; loc.v2.u=0;
// or alternatively
loc.v1 = ImageVector(0,0,0,0,0,0);
loc.v2 = ImageVector(5,5,5,0,0,0);
// or another alternative:
loc = SubImageBox( ImageVector(0,0,0,0,0,0),ImageVector(5,5,5,0,0,0) );

Definition at line 47 of file mlSubImageBox.h.

Member Typedef Documentation

◆ VectorType

template<typename intT>
typedef TImageVector<intT> ml::TSubImageBox< intT >::VectorType

The vector type used for corner members v1 and v2.

Definition at line 52 of file mlSubImageBox.h.

Constructor & Destructor Documentation

◆ TSubImageBox() [1/3]

template<typename intT>
ml::TSubImageBox< intT >::TSubImageBox ( )
inline

Constructor: Creates empty subimage region by setting v1 to (0,...,0) and v2 to (-1,...,-1).

Definition at line 72 of file mlSubImageBox.h.

◆ TSubImageBox() [2/3]

template<typename intT>
ml::TSubImageBox< intT >::TSubImageBox ( const VectorType vector1,
const VectorType vector2 
)
inline

Constructor: Creates subimage from two passed vectors vector1 and vector2.

ImageVector components are left as they are; So the caller is responsible to create a valid/invalid subimage region.

Definition at line 79 of file mlSubImageBox.h.

◆ TSubImageBox() [3/3]

template<typename intT>
ml::TSubImageBox< intT >::TSubImageBox ( const VectorType  extent)
inline

Constructor: Creates subimage from an extent, i.e., v1 is set to (0,...,0) and v2 is set to (extent.x-1,...,extent.u-1).

Definition at line 85 of file mlSubImageBox.h.

Member Function Documentation

◆ clamp()

template<typename intT >
TImageVector< intT > ml::TSubImageBox< intT >::clamp ( const VectorType position) const

Clamps the position to the nearest position inside the SubImageBox.

If the SubImageBox is empty, the result vector contains undefined values.

Definition at line 355 of file mlSubImageBox.h.

◆ contains()

template<typename intT>
bool ml::TSubImageBox< intT >::contains ( const VectorType position) const
inline

Returns true if position is inside the SubImageBox.

Definition at line 192 of file mlSubImageBox.h.

◆ correct()

template<typename intT >
void ml::TSubImageBox< intT >::correct ( )

Swaps all components where v1.

  • > v2.*. I.e., an empty vector becomes non empty if corresponding components are not equal.

Definition at line 309 of file mlSubImageBox.h.

◆ get3DCorners()

template<typename intT>
static void ml::TSubImageBox< intT >::get3DCorners ( const TSubImageBox< intT > &  box,
VectorType  corners[8] 
)
inlinestatic

Returns the corners of the 3d box extents of box in corners.

All returned corners will be ImageVector(0) if box is empty. All c,t and u components are always set to 0.

Definition at line 207 of file mlSubImageBox.h.

◆ getExt()

template<typename intT>
VectorType ml::TSubImageBox< intT >::getExt ( ) const
inline
Deprecated:
Use getExtent() instead.

Definition at line 239 of file mlSubImageBox.h.

◆ getExtent()

template<typename intT>
VectorType ml::TSubImageBox< intT >::getExtent ( ) const
inline

Returns the extents of the subimage region.

If subimage region is empty then 0 is returned.

Definition at line 132 of file mlSubImageBox.h.

Referenced by ml::getInputAsItkImportImageAndSubImg(), ml::ITKRegionFromMLSubImgBox(), ml::SubImage::setBox(), and ml::PagedImage::setImageExtent().

◆ getNumVoxels()

template<typename intT>
intT ml::TSubImageBox< intT >::getNumVoxels ( ) const
inline

Returns number of voxels in the subimage region, i.e., the product of all extents if this is not empty; otherwise 0 is returned.

There is not check for integer overflows.

Definition at line 118 of file mlSubImageBox.h.

Referenced by ml::ReleaseToolsMisc::calculateAverageOfSumOfSquaredDifferences(), ml::TSubImage< MLfloat >::calculateMinMax(), and ml::getInputAsItkImportImageAndSubImg().

◆ getSize()

template<typename intT>
intT ml::TSubImageBox< intT >::getSize ( ) const
inline
Deprecated:
Use getNumVoxels() instead.

Definition at line 236 of file mlSubImageBox.h.

◆ intersect() [1/2]

template<typename intT>
TSubImageBox< intT > ml::TSubImageBox< intT >::intersect ( const TSubImageBox< intT > &  box1,
const TSubImageBox< intT > &  box2 
)
static

Returns the overlapping region of subimage regions box1 and box2.

A result with (v1.x>v2.x || ... || v1.z>v1.z) is interpreted as empty! See also isEmpty(). This is especially true if that already holds for box1 or box2.

Definition at line 327 of file mlSubImageBox.h.

Referenced by ml::ReleaseToolsMisc::calculateAverageOfSumOfSquaredDifferences(), ml::MLKernelToolsApplyFiltering(), and ml::processDataWithITKFilterAndFillOutSubImg().

◆ intersect() [2/2]

template<typename intT>
TSubImageBox<intT> ml::TSubImageBox< intT >::intersect ( const TSubImageBox< intT > &  box) const
inline

Member function version to intersect this with a given box.

Definition at line 176 of file mlSubImageBox.h.

◆ isEmpty()

template<typename intT>
bool ml::TSubImageBox< intT >::isEmpty ( ) const
inline

Returns true if subimage region is empty, i.e., if any of the components of v1 is greater than the corresponding component of v2.

Otherwise false is returned.

Definition at line 111 of file mlSubImageBox.h.

Referenced by ml::ReleaseToolsMisc::calculateAverageOfSumOfSquaredDifferences(), ml::TSubImage< MLfloat >::copySubImageReorderColorPlanesToInterleaved(), ml::TSubImage< MLfloat >::copySubImageTyped(), ml::TSubImageBox< MLint >::get3DCorners(), and ml::TSubImageBox< MLint >::merge().

◆ makeEmpty()

template<typename intT>
void ml::TSubImageBox< intT >::makeEmpty ( )
inline

Makes box empty by setting v1 to (0,...,0) and v2 to (-1,...,-1), i.e., constructor state is restored.

Definition at line 169 of file mlSubImageBox.h.

◆ merge() [1/2]

template<typename intT>
TSubImageBox< intT > ml::TSubImageBox< intT >::merge ( const TSubImageBox< intT > &  loc1,
const TSubImageBox< intT > &  loc2 
)
static

Returns the region containing both subimage regions box1 and box2.

Returns the region containing both subimage regions loc1 and loc2.

Two empty regions result to an empty one; if only one is empty, the other one is returned.

Two empty regions result to an empty one, if only one is empty then the other one is returned.

Definition at line 339 of file mlSubImageBox.h.

◆ merge() [2/2]

template<typename intT>
TSubImageBox<intT> ml::TSubImageBox< intT >::merge ( const TSubImageBox< intT > &  box) const
inline

Member function version to merge this with a given box.

Definition at line 182 of file mlSubImageBox.h.

◆ operator!=()

template<typename intT>
bool ml::TSubImageBox< intT >::operator!= ( const TSubImageBox< intT > &  box) const
inline

Returns false if box has identical components like this, otherwise return true.

Definition at line 103 of file mlSubImageBox.h.

◆ operator==()

template<typename intT>
bool ml::TSubImageBox< intT >::operator== ( const TSubImageBox< intT > &  box) const
inline

Returns true if box has identical components like this, otherwise returns false.

Definition at line 97 of file mlSubImageBox.h.

◆ translate()

template<typename intT>
void ml::TSubImageBox< intT >::translate ( const VectorType offsetVector)
inline

Shifts the whole box by an offset given by offsetVector.

Definition at line 198 of file mlSubImageBox.h.

Referenced by ml::processDataWithITKFilterAndFillOutSubImg().

Member Data Documentation

◆ v1

◆ v2


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