MeVisLab Toolbox Reference
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< intTVectorType
 The vector type used for corner members v1 and v2.
 

Public Member Functions

Constructors
 TSubImageBox ()
 Constructor: Creates empty subimage region by setting v1 to (0,...,0) and v2 to (-1,...,-1).
 
 TSubImageBox (const VectorType &vector1, const VectorType &vector2)
 Constructor: Creates subimage from two passed vectors vector1 and vector2.
 
 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).
 
Properties and operators
bool operator== (const TSubImageBox< intT > &box) const
 Returns true if box has identical components like this, otherwise returns false.
 
bool operator!= (const TSubImageBox< intT > &box) const
 Returns false if box has identical components like this, otherwise return true.
 
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.
 
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.
 
VectorType getExtent () const
 Returns the extents of the subimage region.
 
void correct ()
 Swaps all components where v1.
 

Public Attributes

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

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.
 
TSubImageBox< intTintersect (const TSubImageBox< intT > &box) const
 Member function version to intersect this with a given box.
 
TSubImageBox< intTmerge (const TSubImageBox< intT > &box) const
 Member function version to merge this with a given box.
 
VectorType clamp (const VectorType &position) const
 Clamps the position to the nearest position inside the SubImageBox.
 
bool contains (const VectorType &position) const
 Returns true if position is inside the SubImageBox.
 
void translate (const VectorType &offsetVector)
 Shifts the whole box by an offset given by offsetVector.
 
static TSubImageBox< intTintersect (const TSubImageBox< intT > &box1, const TSubImageBox< intT > &box2)
 Returns the overlapping region of subimage regions box1 and box2.
 
static TSubImageBox< intTmerge (const TSubImageBox< intT > &box1, const TSubImageBox< intT > &box2)
 Returns the region containing both subimage regions box1 and box2.
 
static void get3DCorners (const TSubImageBox< intT > &box, VectorType corners[8])
 Returns the corners of the 3d box extents of box in corners.
 

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) );
VectorType v1
Corner v1 of the subimage region (included in region).
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
TSubImageBox< MLint > SubImageBox
Define the standard SubImageBox type used in the ML. Its size varies with the size of the MLint type.
TImageVector< MLint > ImageVector
Defines the standard ImageVector type which is used by the ML for indexing and coordinates.

Definition at line 52 of file mlSubImageBox.h.

Member Typedef Documentation

◆ VectorType

The vector type used for corner members v1 and v2.

Definition at line 57 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 77 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 84 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 90 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 310 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 200 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 264 of file mlSubImageBox.h.

References mlrange_cast().

◆ 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 215 of file mlSubImageBox.h.

References ml::TSubImageBox< intT >::isEmpty(), mlrange_cast(), ml::TSubImageBox< intT >::v1, and ml::TSubImageBox< intT >::v2.

◆ 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 137 of file mlSubImageBox.h.

Referenced by 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 123 of file mlSubImageBox.h.

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

◆ intersect() [1/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 183 of file mlSubImageBox.h.

◆ intersect() [2/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 282 of file mlSubImageBox.h.

References mlrange_cast(), and ml::TSubImageBox< intT >::v1.

Referenced by ml::ReleaseToolsMisc::calculateAverageOfSumOfSquaredDifferences(), ml::TVirtualVolume< DATATYPE >::copyMaskToSubImage(), ml::MLKernelToolsApplyFiltering(), and ml::processDataWithITKFilterAndFillOutSubImg().

◆ 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 116 of file mlSubImageBox.h.

Referenced by ml::ReleaseToolsMisc::calculateAverageOfSumOfSquaredDifferences(), ml::TSubImage< DATATYPE >::copySubImageReorderColorPlanesToInterleaved(), and ml::TSubImageBox< intT >::get3DCorners().

◆ 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 175 of file mlSubImageBox.h.

References ml::TImageVector< CompIntType >::set().

◆ merge() [1/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 190 of file mlSubImageBox.h.

◆ merge() [2/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 294 of file mlSubImageBox.h.

References mlrange_cast().

◆ 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 108 of file mlSubImageBox.h.

References ml::TSubImageBox< intT >::v1, and ml::TSubImageBox< intT >::v2.

◆ 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 102 of file mlSubImageBox.h.

References ml::TSubImageBox< intT >::v1, and ml::TSubImageBox< intT >::v2.

◆ 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 206 of file mlSubImageBox.h.

References mlrange_cast().

Member Data Documentation

◆ v1

◆ v2

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

Convention: The vector components are always bigger than or equal the corresponding components of v1, otherwise the subimage region will be interpreted as empty.

Definition at line 69 of file mlSubImageBox.h.

Referenced by ml::RasterFunction::_fillRaster(), ml::ReleaseToolsMisc::calculateAverageOfSumOfSquaredDifferences(), ml::TSubImage< DATATYPE >::calculateMinMax(), ml::TVirtualVolume< DATATYPE >::copyMaskToSubImage(), ml::TSubImageBox< intT >::get3DCorners(), ml::MLSubImgBoxFromITKRegion(), ml::TSubImageBox< intT >::operator!=(), ml::TSubImageBox< intT >::operator==(), and ml::parameter_info_utils::ToQVariantList().


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