MeVisLabToolboxReference
ml::SubImage Class Reference

This class manages/represents a rectangular 6d image region which is organized linearly in memory. More...

#include <mlSubImage.h>

Inheritance diagram for ml::SubImage:
ml::ManagedSubImage ml::TSubImage< DATATYPE > ml::TSubImage< float > ml::TSubImage< MLfloat > ml::TSubImageWithCursor< DATATYPE >

Public Member Functions

const SubImageBoxgetBox () const
 Returns the box describing the origin/extent of the subimage. More...
 
void setSourceImageExtent (const ImageVector &extent)
 Sets the image extent of the source image that was used to create this SubImage to extent. More...
 
ImageVector getSourceImageExtent () const
 Returns the image extent of the source image that was used to create this SubImage. More...
 
SubImageBox getValidRegion () const
 Returns the valid region of the SubImage, which is defined by the intersection of the SubImage::getBox() and the SubImageBox(ImageVector(0), SubImage::getSourceImageExtent()-1). More...
 
MLint getNumVoxels () const
 Returns number of voxels in (sub)image. More...
 
MLint getSizeInBytes () const
 Returns number of potential bytes in (sub)image. More...
 
ImageVector getStride () const
 Returns a stride vector to address the memory efficiently. More...
 
MLint getOffset (const ImageVector &voxelPosition) const
 Returns the array index offset from the origin (0,0,0,0,0,0) to the voxelPosition. More...
 
void setDataType (MLDataType dataType)
 Overwrite inherited setDataType method to set type of data to dataType. More...
 
MLDataType getDataType () const
 Return type of image data. More...
 
const MLTypeInfosgetDataTypeInfos () const
 Get MLTypeInfos for image data type. More...
 
MLEXPORT ImageProperties toImageProperties () const
 Converts the Subimage's datatype and extend to an ImageProperties object. More...
 
MLEXPORT void setFromImageProperties (const ImageProperties &imageProperties)
 Sets the image box and datatype from the imageProperties extent and datatype. More...
 
void toStream (std::ostream &ostr) const
 
Constructors and assignments.
 SubImage ()
 Constructor: Creates a subimage with no data. More...
 
 SubImage (const SubImage &si)
 Copy constructor to get identical copy. More...
 
 SubImage (const SubImageBox &box, MLDataType datatype, void *data=nullptr)
 Constructor for a rectangular 6d image region with position and extent given by box, with data type datatype and memory given by the pointer data. More...
 
 SubImage (const SubImage &si, const ImageVector &offset)
 Copy constructor to get identical copy. More...
 
virtual ~SubImage ()
 Virtual destructor to suppress compiler warnings. More...
 
SubImageoperator= (const SubImage &si)
 Assignment operator to get identical copy. More...
 
Origin, extents, region of image, offsets and strides.
void setBox (const SubImageBox &subImageBox)
 Sets a rectangular 6d region of the subimage to subImageBox. More...
 
void setBox (const ImageVector &imageExtent)
 Sets a rectangular 6d region of the subimage to imageExtent. More...
 
void translate (const ImageVector &offset)
 Translates the box of the subimage by adding the vector offset. More...
 
const ImageVectorgetOrigin () const
 Returns the origin of the subimage (which is identical to getBox().v1). More...
 
void setOrigin (const ImageVector &newOrigin)
 Sets the origin of the subimage (which moves the box of the subimage to newOrigin). More...
 
ImageVector getExtent () const
 Returns the extent of the subimage (which is identical to getBox().getExtent()). More...
 
void setExtent (MLint x, MLint y, MLint z=1, MLint c=1, MLint t=1, MLint u=1)
 Sets the extent of the subimage (which also changes the strides) to newExtent. More...
 
void setExtent (const ImageVector &newExtent)
 Sets the extent of the subimage (which also changes the strides) to newExtent. More...
 
SubImageBox getBoxFromExtent () const
 Returns size of image as box with origin 0. More...
 
Deprecated
SubImageBox getBoxFromImageExtent () const
 
ImageVector getImageExtent () const
 
void setImageExtent (const ImageVector &newExtent)
 
SubImageBox getBoxFromImgExt () const
 
ImageVector getImgExt () const
 
void setImgExt (const ImageVector &newExtent)
 
MLint getSize () const
 
MLint getByteSize () const
 
void * getVoidSubImgPos (const ImageVector &p) const
 
void * getVoidSubImgPos (MLint x, MLint y, MLint z) const
 
void * getVoidImgPos (const ImageVector &p) const
 
void * getVoidImgPos (MLint x, MLint y, MLint z) const
 
MLint isValidSubImgPos (const ImageVector &p) const
 
MLint isValidSubImgPos (MLint x, MLint y, MLint z) const
 
MLint isValidImgPos (const ImageVector &p) const
 
MLint isValidImgPos (MLint x, MLint y, MLint z) const
 
MLint calculateMinMax (MLldouble &minValue, MLldouble &maxValue, const SubImageBox *const validBox=nullptr) const
 
MLint calcMinMax (MLdouble &minVal, MLdouble &maxVal, const SubImageBox *const validBox=nullptr) const
 
MLint calcMinMax (MLldouble &minValue, MLldouble &maxValue, const SubImageBox *const validBox=nullptr) const
 
void fillSubImg (MLldouble val)
 
void fillSubImgWithTypeData (const MLTypeData *val)
 
void fillBordersWithClampedInputValues (const SubImageBox &box)
 
void fillBordersWithLDoubleValue (const SubImageBox &box, MLldouble fillValue)
 
void fillInvalidRegionWithLDoubleValue (MLldouble value)
 
Calculation of memory addresses of image voxels
void * getSubImagePointer (const ImageVector &voxelPosition) const
 Returns pointer to voxel data of image voxel at 6d voxelPosition relative to the begin of the subimage region. More...
 
void * getSubImagePointer (MLint x, MLint y, MLint z) const
 Returns pointer to voxel data of image voxel at 3d position p=(x,y,z) relative to the begin of the subimage region. More...
 
void * getImagePointer (const ImageVector &voxelPosition) const
 Returns pointer to voxel data of image voxel at 6d position voxelPosition relative to the begin of the complete image region. More...
 
void * getImagePointer (MLint x, MLint y, MLint z) const
 Returns pointer to voxel data of image voxel at 3d position p=(x, y, z) relative to the begin of the complete image region. More...
 
Copy image data from one subimage to another.
MLEXPORT void copySubImage (const SubImage &fromImage, const ScaleShiftData &scaleShiftData)
 Copies image data from the subimage fromImage into the overlapping region of this subimage. More...
 
MLEXPORT void copySubImage (const SubImage &fromImage)
 Implements special case for void copySubImage(const TSubImage<FROM_DATATYPE> &typedFromImg, const ScaleShiftData& scaleShiftData) where scaleShiftData is default. More...
 
Test for validity of coordinates.
bool isValidSubImagePosition (const ImageVector &voxelPosition) const
 Returns true if 6d voxelPosition is a valid position within subimage region, i.e., if voxelPosition is within (0,0,0,0,0,0) and subimage extents. More...
 
bool isValidSubImagePosition (MLint x, MLint y, MLint z) const
 Returns true if 3d position p=(x, y, z) is a valid position within subimage region, i.e., if the position is within (0,0,0) and subimage extents. More...
 
bool isValidImagePosition (const ImageVector &voxelPosition) const
 Returns true if 6d voxelPosition is a valid position within subimage region, i.e., if voxelPosition is within subImgBox.v1 and subImgBox.v2. More...
 
bool isValidImagePosition (MLint x, MLint y, MLint z) const
 Returns true if 3d position p=(x, y, z) is a valid position within subimage region, i.e., if the position is within subImgBox.v1 and subImgBox.v2. More...
 
Allocation and freeing of buffered data.
MLEXPORT void allocate (MLMemoryErrorHandling handleFailure)
 Allocate data with MLAlloc(). More...
 
MLEXPORT void allocateAsMemoryBlockHandle (MLMemoryErrorHandling handleFailure=ML_RETURN_NULL)
 Allocate data using the ML memory manager. For failure handing, see SubImage::allocate(). More...
 
MLEXPORT void free ()
 Frees data pointed to by getData() with MLFree(). More...
 
Special properties
MLEXPORT bool isOneValued () const
 Returns true if all page voxels have the same value or if the page contains only 1 voxel. More...
 
MLEXPORT MLint calculateMinMax (MLdouble &minValue, MLdouble &maxValue, const SubImageBox *const validBox=nullptr) const
 Scans subimage and determines minimum and maximum values on region which is part of subimage box and of validBox. More...
 
MLEXPORT void compare (const SubImage &subImage2, bool *regionsMatch, bool *dataTypesMatch, bool *thisBoxIsPartOfRegion2, bool *region2IsPartOfThisBox, bool *overlapHasSameValues, ImageVector *firstMismatchPos) const
 Compare two subimages with respect to their regions and their contents. More...
 
SUBIMAGE FILLING
MLEXPORT void fill (MLdouble value)
 Fills the subimage with a value cast to the data type of the subimage. More...
 
MLEXPORT void fillWithTypeData (const MLTypeData *value)
 Fills the subimage with a value given as MLTypeData. More...
 
MLEXPORT void fillBordersWithScalarValue (const SubImageBox &box, MLdouble fillValue)
 Fill all regions with the fill value fillValue which are not covered by box. More...
 
MLEXPORT void fillBordersWithTypeData (const SubImageBox &box, const MLTypeData *fillValue)
 Fills all regions with the fill value fillValue which are not covered by box. More...
 
MLEXPORT void fillBordersWithInputValues (const SubImageBox &box, const SubImage &inputSubImage)
 Fills all regions with values from inputSubImage which are not covered by box, however, only valid regions of inputSubImage are read. More...
 
MLEXPORT void fillBordersWithBorderValues (const SubImageBox &box)
 Each voxel of which is not inside box is filled with the nearest voxel which is inside box. More...
 
void fillInvalidRegionWithScalarValue (MLdouble value)
 Fills the invalid region (everything outside of getValidRegion()) with the given value. More...
 
void fillInvalidRegionWithTypeData (const MLTypeData *value)
 Fills the invalid region (everything outside of getValidRegion()) with the given value. More...
 
void fillInvalidRegionWithBorderValues ()
 Fills the invalid region (everything outside of getValidRegion()) with the values on the borders of the valid region. More...
 

Protected Member Functions

void _calcFillAreaParams (const SubImageBox &box, const SubImageBox &maxValidInputRegion, ImageVector &boxV1, ImageVector &boxV2, ImageVector &outputTSubImageV1, ImageVector &outputTSubImageV2, MLint &fullLineLenX, MLint &fullLineLenXB, MLint &leftLineStartX, MLint &leftLineLenX, MLint &leftLineLenXB, MLint &rightLineStartX, MLint &rightLineLenX, MLint &rightLineLenXB)
 Helper method to calculate important parameters for page based border filling. More...
 
void _copySubImageGeneric (const SubImage &fromImage, const ScaleShiftData &scaleShiftData)
 Generic, non-optimized version of copySubImage. More...
 
const MLTypeInfos_getDataTypeInfos (MLDataType dt) const
 Get MLTypeInfos for used data types, indicates error if type is not registered. More...
 

Protected Attributes

SubImageBox _box
 The box of the subimage. More...
 
ImageVector _sourceImageExtent
 The extent of the source image, which is used for getValidRegion() More...
 
void * _data
 Memory chunk managed by this subimage. More...
 
MLMemoryBlockHandle _memoryBlock
 Memory block used by this subimage. More...
 
ImageVector _stride
 Stride vector to address the memory efficiently. More...
 
MLDataType _dataType
 Datatype of the image. More...
 

Properties of subimage

MLEXPORT bool isValid () const
 Returns 1(=true) if image region and data is valid. More...
 
void * getData () const
 Returns the memory address of the memory managed by the subimage. More...
 
MLEXPORT void setData (void *data)
 Sets data as a new memory block for the subimage. More...
 
MLEXPORT void setDataFromMemoryBlockHandle (const MLMemoryBlockHandle &data)
 Sets the managed data from a given MLMemoryBlockHandle, the sub image will store this handle and thus reference count the memory managed by the handle as long as the SubImage stays alive. More...
 
const MLMemoryBlockHandlegetMemoryBlockHandle () const
 Returns the memory block handle that manages the data of this SubImage if it has been set via setDataFromMemoryBlockHandle(). More...
 
static MLEXPORT MLint coordToIndex (MLint x, MLint y, MLint z, MLint c, MLint t, MLint u, const ImageVector &size)
 Converts the coordinate (x, y, z, c, t,u) to an index into an image with 6D extents given by size. More...
 
static MLEXPORT MLint coordToIndex (const ImageVector &voxelPosition, const ImageVector &size)
 Converts the coordinate voxelPosition into the image with extents size to an index. More...
 
static MLEXPORT ImageVector indexToCoord (MLint index, const ImageVector &extent)
 Converts an index into an array with extents extent to a coordinate. More...
 

Detailed Description

This class manages/represents a rectangular 6d image region which is organized linearly in memory.

Thread-safety: This class is reentrant.

This class owns

  • Methods to set/access image properties which are inherited from the class ImageProperties.
  • A pointer to the memory data containing the image data as void pointer.

IMPORTANT NOTES:

  • This subimage class does NOT allocate/deallocate the memory chunk itself. It usually must be allocated elsewhere and assigned to this class.
  • The class itself is not exported to avoid that inline usage is inhibited. Only stuff implemented in the .cpp file is exported explicitly.

Other notes:

  • With this class the Host manages and encapsulates rectangular image regions (e.g., for pages, tiles, cached image results) and passes them to the image processing algorithms.
  • The typical image processing methods in the ML are located in overloaded methods of Module::calculateOutputSubImage. In these methods usually the untyped memory chunks given as SubImage are wrapped again to typed subimages (see TSubImage). See TSubImage for more information about that.
  • The type of the image data in memory is handled via a void pointer, however the type is managed as enum type to support typed accesses in derived classes (see TSubImage). Thus the access to certain image voxels is not supported. The Host does not need the knowledge about the data itself. The typed access to voxels is implemented on top of this class as the template class TSubImage.

Definition at line 68 of file mlSubImage.h.

Constructor & Destructor Documentation

◆ SubImage() [1/4]

ml::SubImage::SubImage ( )
inline

Constructor: Creates a subimage with no data.

Definition at line 78 of file mlSubImage.h.

◆ SubImage() [2/4]

ml::SubImage::SubImage ( const SubImage si)
inline

Copy constructor to get identical copy.

Note that the pointer to the data is copied, and NOT the data itself.

Definition at line 91 of file mlSubImage.h.

◆ SubImage() [3/4]

ml::SubImage::SubImage ( const SubImageBox box,
MLDataType  datatype,
void *  data = nullptr 
)
inline

Constructor for a rectangular 6d image region with position and extent given by box, with data type datatype and memory given by the pointer data.

Definition at line 105 of file mlSubImage.h.

◆ SubImage() [4/4]

ml::SubImage::SubImage ( const SubImage si,
const ImageVector offset 
)
inline

Copy constructor to get identical copy.

Note that the pointer to the data is copied, and NOT the data itself. The box of the input image is translated by the given offset vector.

Definition at line 118 of file mlSubImage.h.

◆ ~SubImage()

virtual ml::SubImage::~SubImage ( )
inlinevirtual

Virtual destructor to suppress compiler warnings.

Definition at line 131 of file mlSubImage.h.

References ML_TRACE_IN_TIME_CRITICAL.

Member Function Documentation

◆ _calcFillAreaParams()

void ml::SubImage::_calcFillAreaParams ( const SubImageBox box,
const SubImageBox maxValidInputRegion,
ImageVector boxV1,
ImageVector boxV2,
ImageVector outputTSubImageV1,
ImageVector outputTSubImageV2,
MLint fullLineLenX,
MLint fullLineLenXB,
MLint leftLineStartX,
MLint leftLineLenX,
MLint leftLineLenXB,
MLint rightLineStartX,
MLint rightLineLenX,
MLint rightLineLenXB 
)
protected

Helper method to calculate important parameters for page based border filling.

Input parameters: box specifies the box which shall not be filled. maxValidInputRegion is the region which is allowed to be read.

Return parameters: boxV1 and boxV2 are the corners of box. outputTSubImageV1 and outputTSubImageV2 are the corners of the box of this. fullLineLenX is the number of voxels in one row of this. fullLineLenXB is the number of bytes in one row of this. leftLineStartX is the first voxel left from box to be filled in x-rows. leftLineLenX is the number of voxels to be filled starting at voxel leftLineStartX. leftLineLenXB is the number of bytes to be filled starting at voxel leftLineStartX. rightLineStartX is the first voxel right from box to be filled in x-rows. rightLineLenX is the number of voxels to be filled starting at voxel rightLineStartX. rightLineLenXB is the number of bytes to be filled starting at voxel rightLineStartX.

◆ _copySubImageGeneric()

void ml::SubImage::_copySubImageGeneric ( const SubImage fromImage,
const ScaleShiftData scaleShiftData 
)
protected

Generic, non-optimized version of copySubImage.

◆ _getDataTypeInfos()

const MLTypeInfos* ml::SubImage::_getDataTypeInfos ( MLDataType  dt) const
protected

Get MLTypeInfos for used data types, indicates error if type is not registered.

◆ allocate()

MLEXPORT void ml::SubImage::allocate ( MLMemoryErrorHandling  handleFailure)

Allocate data with MLAlloc().

If the allocation fails it is handled as described by handleFailure (see MLMemoryErrorHandling for description of modes). The internal pointer to the data buffer is simply overwritten; the application is responsible for freeing it before, for example with SubImage::free(). The number of allocated bytes results from the size of the subimage box and the data type. An empty box will result in the allocation of zero bytes on the heap which also need to be freed correctly.

IMPORTANT: By definition the allocated data is not owned by the subimage and will NOT be freed on destruction of the SubImage instance. The calling application is responsible for that. Use SubImage::free() for that.

◆ allocateAsMemoryBlockHandle()

MLEXPORT void ml::SubImage::allocateAsMemoryBlockHandle ( MLMemoryErrorHandling  handleFailure = ML_RETURN_NULL)

Allocate data using the ML memory manager. For failure handing, see SubImage::allocate().

Referenced by ml::PCLMLTools::createPointCloudFromPagedImage(), and ml::getInputAsItkImportImageAndSubImg().

◆ calcMinMax() [1/2]

MLint ml::SubImage::calcMinMax ( MLdouble minVal,
MLdouble maxVal,
const SubImageBox *const  validBox = nullptr 
) const
inline
Deprecated:
Use MLdouble instead of MLldouble arguments

Definition at line 766 of file mlSubImage.h.

◆ calcMinMax() [2/2]

MLint ml::SubImage::calcMinMax ( MLldouble minValue,
MLldouble maxValue,
const SubImageBox *const  validBox = nullptr 
) const
inline
Deprecated:
Use calculateMinMax() instead.

Definition at line 770 of file mlSubImage.h.

◆ calculateMinMax() [1/2]

MLEXPORT MLint ml::SubImage::calculateMinMax ( MLdouble minValue,
MLdouble maxValue,
const SubImageBox *const  validBox = nullptr 
) const

Scans subimage and determines minimum and maximum values on region which is part of subimage box and of validBox.

If validBox is passed as a NULL pointer (the default), all voxels are checked. The return value is the number of scanned voxels. If the subimage is empty, minValue and maxValue are set to 0 and the return value is 0. Warning: If used in calculateOutputSubImage, take into consideration that pages may also contain invalid data which is not part of the image. Pass 'image box' as validBox to be sure to access only valid regions.

◆ calculateMinMax() [2/2]

MLint ml::SubImage::calculateMinMax ( MLldouble minValue,
MLldouble maxValue,
const SubImageBox *const  validBox = nullptr 
) const
inline
Deprecated:
Use MLdouble instead of MLldouble arguments

Definition at line 762 of file mlSubImage.h.

◆ compare()

MLEXPORT void ml::SubImage::compare ( const SubImage subImage2,
bool *  regionsMatch,
bool *  dataTypesMatch,
bool *  thisBoxIsPartOfRegion2,
bool *  region2IsPartOfThisBox,
bool *  overlapHasSameValues,
ImageVector firstMismatchPos 
) const

Compare two subimages with respect to their regions and their contents.

All pointer parameters may be passed as NULL parameters if not needed and will silently be ignored then.

Parameters
subImage2Second subimage to be compared with.
regionsMatchIf passed as non-NULL pointer, *regionsMatch is set to true if regions are identical.
dataTypesMatchIf passed as non-NULL pointer, *dataTypesMatch is set to true if both data types are identical.
thisBoxIsPartOfRegion2If passed as non-NULL pointer, *region1IsPartOfRegion2 is set to true if the region of this is a subregion of subImage2 or is identical.
region2IsPartOfThisBoxIf passed as non-NULL pointer, *region2IsPartOfRegion1 is set to true if the region of subImage2 is a subregion of this or is identical.
overlapHasSameValuesIf passed as non-NULL pointer, *overlapHasSameValues is set to true if subimages have the same and valid types, data pointers are both non-NULL and all voxels in the overlapping region of this and subImage2 contain equal values.
firstMismatchPosIf passed as non-NULL pointer, *firstMismatchPos is set to the first value which does not match in overlapping regions. If no overlap exists or something is invalid (data pointers or types) it is set to (-1, ..., -1).

◆ coordToIndex() [1/2]

static MLEXPORT MLint ml::SubImage::coordToIndex ( MLint  x,
MLint  y,
MLint  z,
MLint  c,
MLint  t,
MLint  u,
const ImageVector size 
)
static

Converts the coordinate (x, y, z, c, t,u) to an index into an image with 6D extents given by size.

This convenience function is static and can be used also without a class instance.

◆ coordToIndex() [2/2]

static MLEXPORT MLint ml::SubImage::coordToIndex ( const ImageVector voxelPosition,
const ImageVector size 
)
static

Converts the coordinate voxelPosition into the image with extents size to an index.

This convenience function is static and can be used also without a class instance.

◆ copySubImage() [1/2]

MLEXPORT void ml::SubImage::copySubImage ( const SubImage fromImage,
const ScaleShiftData scaleShiftData 
)

Copies image data from the subimage fromImage into the overlapping region of this subimage.

Grey values are transformed linearly according to the settings in scaleShiftData (see ScaleShiftData). Notes:

  • The copied data always has the data type of this subimage. If necessary it is cast.
  • By transforming linearly gray values before copying them it is possible to avoid information loss due to type casting.
  • The default case of scaleShiftData defines scaleShiftData.getScale()==1 and scaleShiftData.getShift()==0. So voxel value transformation does not change anything and copying is implemented as special case which is therefore faster.

◆ copySubImage() [2/2]

MLEXPORT void ml::SubImage::copySubImage ( const SubImage fromImage)

Implements special case for void copySubImage(const TSubImage<FROM_DATATYPE> &typedFromImg, const ScaleShiftData& scaleShiftData) where scaleShiftData is default.

◆ fill()

MLEXPORT void ml::SubImage::fill ( MLdouble  value)

Fills the subimage with a value cast to the data type of the subimage.

◆ fillBordersWithBorderValues()

MLEXPORT void ml::SubImage::fillBordersWithBorderValues ( const SubImageBox box)

Each voxel of which is not inside box is filled with the nearest voxel which is inside box.

Note that box must be specified in global image coordinates. box must overlap the box of the subImage at least in one voxel to guarantee correct operation since copying can be done only from box area. If no overlap exists then the routine returns without filling anything.

◆ fillBordersWithClampedInputValues()

void ml::SubImage::fillBordersWithClampedInputValues ( const SubImageBox box)
inline
Deprecated:
Use fillBordersWithBorderValues() instead.

Definition at line 780 of file mlSubImage.h.

◆ fillBordersWithInputValues()

MLEXPORT void ml::SubImage::fillBordersWithInputValues ( const SubImageBox box,
const SubImage inputSubImage 
)

Fills all regions with values from inputSubImage which are not covered by box, however, only valid regions of inputSubImage are read.

Not available regions from the input are ignored and may lead to unchanged regions outside box if inputSubImage does not cover all regions outside box. Note that box must be specified in global image coordinates. So two subimages with different origins and same sizes are filled differently, dependent on their overlap with the box in global image coordinates. This method should be called only if this and inputSubImage differ.

◆ fillBordersWithLDoubleValue()

void ml::SubImage::fillBordersWithLDoubleValue ( const SubImageBox box,
MLldouble  fillValue 
)
inline
Deprecated:
Use fillBordersWithScalarValue instead

Definition at line 783 of file mlSubImage.h.

◆ fillBordersWithScalarValue()

MLEXPORT void ml::SubImage::fillBordersWithScalarValue ( const SubImageBox box,
MLdouble  fillValue 
)

Fill all regions with the fill value fillValue which are not covered by box.

Note that box must be specified in global image coordinates. So two subimages with different origins and same sizes are filled differently, dependent on their overlap with the box in global image coordinates.

◆ fillBordersWithTypeData()

MLEXPORT void ml::SubImage::fillBordersWithTypeData ( const SubImageBox box,
const MLTypeData fillValue 
)

Fills all regions with the fill value fillValue which are not covered by box.

Note that box must be specified in global image coordinates. So two subimages with different origins and same sizes are filled differently, dependent on their overlap with the box in global image coordinates. fillValue must point to a valid and correctly sized value of the data type of the subimage. If fillValue is NULL, the call is ignored.

◆ fillInvalidRegionWithBorderValues()

void ml::SubImage::fillInvalidRegionWithBorderValues ( )
inline

Fills the invalid region (everything outside of getValidRegion()) with the values on the borders of the valid region.

This is useful to initialize invalid regions of an output/input sub image.

Definition at line 627 of file mlSubImage.h.

◆ fillInvalidRegionWithLDoubleValue()

void ml::SubImage::fillInvalidRegionWithLDoubleValue ( MLldouble  value)
inline
Deprecated:
Use fillInvalidRegionWithScalarValue instead

Definition at line 786 of file mlSubImage.h.

◆ fillInvalidRegionWithScalarValue()

void ml::SubImage::fillInvalidRegionWithScalarValue ( MLdouble  value)
inline

Fills the invalid region (everything outside of getValidRegion()) with the given value.

This is useful to initialize invalid regions of an output/input sub image.

Definition at line 614 of file mlSubImage.h.

◆ fillInvalidRegionWithTypeData()

void ml::SubImage::fillInvalidRegionWithTypeData ( const MLTypeData value)
inline

Fills the invalid region (everything outside of getValidRegion()) with the given value.

This is useful to initialize invalid regions of an output/input sub image.

Definition at line 620 of file mlSubImage.h.

◆ fillSubImg()

void ml::SubImage::fillSubImg ( MLldouble  val)
inline
Deprecated:
Use fill() instead.

Definition at line 774 of file mlSubImage.h.

◆ fillSubImgWithTypeData()

void ml::SubImage::fillSubImgWithTypeData ( const MLTypeData val)
inline
Deprecated:
Use fillWithTypeData() instead.

Definition at line 777 of file mlSubImage.h.

◆ fillWithTypeData()

MLEXPORT void ml::SubImage::fillWithTypeData ( const MLTypeData value)

Fills the subimage with a value given as MLTypeData.

value must point to a valid and correctly sized value of the data type of the subimage. If value is NULL, the call is ignored.

◆ free()

MLEXPORT void ml::SubImage::free ( )

Frees data pointed to by getData() with MLFree().

as described by MLFree(). It is legal to call free() if getData() is NULL. In that case the call is ignored. After this call getData() will return NULL. If the memory has been set via setDataFromMemoryBlockHandle(), free() does NOT delete the memory but just clears the internal memory handle.

Referenced by ml::getInputAsItkImportImageAndSubImg().

◆ getBox()

◆ getBoxFromExtent()

SubImageBox ml::SubImage::getBoxFromExtent ( ) const
inline

Returns size of image as box with origin 0.

Definition at line 206 of file mlSubImage.h.

◆ getBoxFromImageExtent()

SubImageBox ml::SubImage::getBoxFromImageExtent ( ) const
inline
Deprecated:
Use getBoxFromExtent() instead.

Returns extent of the image as box with origin 0.

Definition at line 212 of file mlSubImage.h.

Referenced by ml::TVirtualVolume< DATATYPE >::copyFromSubImage().

◆ getBoxFromImgExt()

SubImageBox ml::SubImage::getBoxFromImgExt ( ) const
inline
Deprecated:
Use getBoxFromExtent() instead.

Definition at line 723 of file mlSubImage.h.

◆ getByteSize()

MLint ml::SubImage::getByteSize ( ) const
inline
Deprecated:
Use getSizeInBytes() instead.

Definition at line 735 of file mlSubImage.h.

◆ getData()

void* ml::SubImage::getData ( ) const
inline

Returns the memory address of the memory managed by the subimage.

Definition at line 366 of file mlSubImage.h.

Referenced by ml::PCLMLTools::appendSubImageVoxelsToPointCloud(), ml::getITKImportImageFromSubImg(), ml::TSubImage< MLfloat >::TSubImage(), and ml::tsubimage_cast().

◆ getDataType()

MLDataType ml::SubImage::getDataType ( ) const
inline

◆ getDataTypeInfos()

const MLTypeInfos* ml::SubImage::getDataTypeInfos ( ) const
inline

Get MLTypeInfos for image data type.

Definition at line 285 of file mlSubImage.h.

References MLGetTypeInfosForDataType().

Referenced by ml::PCLMLTools::appendSubImageVoxelsToPointCloud().

◆ getExtent()

ImageVector ml::SubImage::getExtent ( ) const
inline

Returns the extent of the subimage (which is identical to getBox().getExtent()).

Definition at line 191 of file mlSubImage.h.

◆ getImageExtent()

ImageVector ml::SubImage::getImageExtent ( ) const
inline
Deprecated:
Use getExtent() instead.

Returns the extent of the image.

Definition at line 216 of file mlSubImage.h.

◆ getImagePointer() [1/2]

void* ml::SubImage::getImagePointer ( const ImageVector voxelPosition) const
inline

Returns pointer to voxel data of image voxel at 6d position voxelPosition relative to the begin of the complete image region.

The subimage is a part of the complete image. I.e., the position p=getBox.v1() is considered the origin of the image region/subimage.

Definition at line 317 of file mlSubImage.h.

Referenced by ml::PCLMLTools::appendSubImageVoxelsToPointCloud().

◆ getImagePointer() [2/2]

void* ml::SubImage::getImagePointer ( MLint  x,
MLint  y,
MLint  z 
) const
inline

Returns pointer to voxel data of image voxel at 3d position p=(x, y, z) relative to the begin of the complete image region.

The subimage is a part of the complete image. I.e., the position p=getBox.v1() is considered the origin of the image region/subimage.

Definition at line 325 of file mlSubImage.h.

◆ getImgExt()

ImageVector ml::SubImage::getImgExt ( ) const
inline
Deprecated:
Use getExtent() instead.

Definition at line 726 of file mlSubImage.h.

◆ getMemoryBlockHandle()

const MLMemoryBlockHandle& ml::SubImage::getMemoryBlockHandle ( ) const
inline

Returns the memory block handle that manages the data of this SubImage if it has been set via setDataFromMemoryBlockHandle().

Returns an empty handle when the data has been set with setData().

Definition at line 382 of file mlSubImage.h.

◆ getNumVoxels()

MLint ml::SubImage::getNumVoxels ( ) const
inline

Returns number of voxels in (sub)image.

Note that it could become larger than 2^32 even on 32 bit systems. It will never be smaller than 0; the signed return type is used for safer signed arithmetics.

Definition at line 249 of file mlSubImage.h.

◆ getOffset()

MLint ml::SubImage::getOffset ( const ImageVector voxelPosition) const
inline

Returns the array index offset from the origin (0,0,0,0,0,0) to the voxelPosition.

Definition at line 264 of file mlSubImage.h.

◆ getOrigin()

const ImageVector& ml::SubImage::getOrigin ( ) const
inline

Returns the origin of the subimage (which is identical to getBox().v1).

Definition at line 180 of file mlSubImage.h.

◆ getSize()

MLint ml::SubImage::getSize ( ) const
inline
Deprecated:
Use getNumVoxels() instead.

Definition at line 732 of file mlSubImage.h.

◆ getSizeInBytes()

MLint ml::SubImage::getSizeInBytes ( ) const
inline

Returns number of potential bytes in (sub)image.

Note that it could become larger than 2^32 even on 32 bit systems. It will never be smaller than 0; the signed return type is used for safer signed arithmetics.

Definition at line 253 of file mlSubImage.h.

◆ getSourceImageExtent()

ImageVector ml::SubImage::getSourceImageExtent ( ) const
inline

Returns the image extent of the source image that was used to create this SubImage.

This is used for the intersection calculation of the getValidRegion() call.

Definition at line 235 of file mlSubImage.h.

Referenced by ml::TSubImage< MLfloat >::TSubImage().

◆ getStride()

ImageVector ml::SubImage::getStride ( ) const
inline

Returns a stride vector to address the memory efficiently.

So the memory address of an subimage voxel can easily be calculated from the dot product of strides and voxel position. Usually stride.x=1, stride.y=x, stride.z=x*y, stride.c=x*y*z, ...

Definition at line 258 of file mlSubImage.h.

Referenced by ml::KernelLineApplicatorBase< DATATYPE, KDATATYPE >::_defineIndices(), ml::TSubImage< MLfloat >::copySubImageTyped(), and ml::TSubImageCursorBase< DATATYPE >::TSubImageCursorBase().

◆ getSubImagePointer() [1/2]

void* ml::SubImage::getSubImagePointer ( const ImageVector voxelPosition) const
inline

Returns pointer to voxel data of image voxel at 6d voxelPosition relative to the begin of the subimage region.

I.e., the position (0,0,0,0,0,0) is considered the origin of the subimage.

Definition at line 295 of file mlSubImage.h.

◆ getSubImagePointer() [2/2]

void* ml::SubImage::getSubImagePointer ( MLint  x,
MLint  y,
MLint  z 
) const
inline

Returns pointer to voxel data of image voxel at 3d position p=(x,y,z) relative to the begin of the subimage region.

I.e., the position (0,0,0,0,0,0) is considered the origin of the subimage.

Definition at line 306 of file mlSubImage.h.

◆ getValidRegion()

SubImageBox ml::SubImage::getValidRegion ( ) const
inline

Returns the valid region of the SubImage, which is defined by the intersection of the SubImage::getBox() and the SubImageBox(ImageVector(0), SubImage::getSourceImageExtent()-1).

The ML host automatically sets the source image extent on SubImages that it creates. If you want to use getValidRegion() on SubImages that you create on your own, you have to call setSourceImageExtent() yourself.

Definition at line 242 of file mlSubImage.h.

References ml::WEMSetOp::intersect().

◆ getVoidImgPos() [1/2]

void* ml::SubImage::getVoidImgPos ( const ImageVector p) const
inline
Deprecated:
Use getImagePointer() instead.

Definition at line 744 of file mlSubImage.h.

◆ getVoidImgPos() [2/2]

void* ml::SubImage::getVoidImgPos ( MLint  x,
MLint  y,
MLint  z 
) const
inline
Deprecated:
Use getImagePointer() instead.

Definition at line 747 of file mlSubImage.h.

◆ getVoidSubImgPos() [1/2]

void* ml::SubImage::getVoidSubImgPos ( const ImageVector p) const
inline
Deprecated:
Use getSubImagePointer() instead.

Definition at line 738 of file mlSubImage.h.

◆ getVoidSubImgPos() [2/2]

void* ml::SubImage::getVoidSubImgPos ( MLint  x,
MLint  y,
MLint  z 
) const
inline
Deprecated:
Use getSubImagePointer() instead.

Definition at line 741 of file mlSubImage.h.

◆ indexToCoord()

static MLEXPORT ImageVector ml::SubImage::indexToCoord ( MLint  index,
const ImageVector extent 
)
static

Converts an index into an array with extents extent to a coordinate.

This convenience function is static and can be used also without a class instance. Note that it is not really fast.

◆ isOneValued()

MLEXPORT bool ml::SubImage::isOneValued ( ) const

Returns true if all page voxels have the same value or if the page contains only 1 voxel.

If subimage has no voxels (empty) or more than one value, false is returned.

◆ isValid()

MLEXPORT bool ml::SubImage::isValid ( ) const

Returns 1(=true) if image region and data is valid.

Returns 0(=false) if not. This flag does NOT say anything about the validity of the contents of the memory.

◆ isValidImagePosition() [1/2]

bool ml::SubImage::isValidImagePosition ( const ImageVector voxelPosition) const
inline

Returns true if 6d voxelPosition is a valid position within subimage region, i.e., if voxelPosition is within subImgBox.v1 and subImgBox.v2.

If outside, false is returned. So the position p=getBox().v1 addresses the origin of the subimage.

Definition at line 440 of file mlSubImage.h.

◆ isValidImagePosition() [2/2]

bool ml::SubImage::isValidImagePosition ( MLint  x,
MLint  y,
MLint  z 
) const
inline

Returns true if 3d position p=(x, y, z) is a valid position within subimage region, i.e., if the position is within subImgBox.v1 and subImgBox.v2.

If outside, false is returned. So the position p=getBox().v1 addresses the origin of the subimage.

Definition at line 452 of file mlSubImage.h.

◆ isValidImgPos() [1/2]

MLint ml::SubImage::isValidImgPos ( const ImageVector p) const
inline
Deprecated:
Use isValidImagePosition() instead.

Definition at line 756 of file mlSubImage.h.

◆ isValidImgPos() [2/2]

MLint ml::SubImage::isValidImgPos ( MLint  x,
MLint  y,
MLint  z 
) const
inline
Deprecated:
Use isValidImagePosition() instead.

Definition at line 759 of file mlSubImage.h.

◆ isValidSubImagePosition() [1/2]

bool ml::SubImage::isValidSubImagePosition ( const ImageVector voxelPosition) const
inline

Returns true if 6d voxelPosition is a valid position within subimage region, i.e., if voxelPosition is within (0,0,0,0,0,0) and subimage extents.

If outside, false is returned. So the position p=(0,0,0,0,0,0) addresses the origin of the subimage.

Definition at line 416 of file mlSubImage.h.

◆ isValidSubImagePosition() [2/2]

bool ml::SubImage::isValidSubImagePosition ( MLint  x,
MLint  y,
MLint  z 
) const
inline

Returns true if 3d position p=(x, y, z) is a valid position within subimage region, i.e., if the position is within (0,0,0) and subimage extents.

If outside, false is returned. So the position p=(0,0,0,0,0,0) addresses the origin of the subimage and all higher coordinates for c, t and u are always used as 0.

Definition at line 429 of file mlSubImage.h.

◆ isValidSubImgPos() [1/2]

MLint ml::SubImage::isValidSubImgPos ( const ImageVector p) const
inline
Deprecated:
Use isValidSubImagePosition() instead.

Definition at line 750 of file mlSubImage.h.

◆ isValidSubImgPos() [2/2]

MLint ml::SubImage::isValidSubImgPos ( MLint  x,
MLint  y,
MLint  z 
) const
inline
Deprecated:
Use isValidSubImagePosition() instead.

Definition at line 753 of file mlSubImage.h.

◆ operator=()

SubImage& ml::SubImage::operator= ( const SubImage si)
inline

Assignment operator to get identical copy.

Note that only the pointer to the data is copied, and NOT the data itself.

Definition at line 135 of file mlSubImage.h.

References _box, _data, _dataType, _memoryBlock, _sourceImageExtent, and _stride.

◆ setBox() [1/2]

void ml::SubImage::setBox ( const SubImageBox subImageBox)
inline

Sets a rectangular 6d region of the subimage to subImageBox.

Overloads method from base class ImageProperties.

Definition at line 157 of file mlSubImage.h.

References ml::TSubImageBox< intT >::getExtent(), and ml::TVector< TVectorBase >::getStrides().

Referenced by ml::getInputAsItkImportImageAndSubImg().

◆ setBox() [2/2]

void ml::SubImage::setBox ( const ImageVector imageExtent)
inline

Sets a rectangular 6d region of the subimage to imageExtent.

So the origin of box will be (0,0,0,0,0,0), the second box edge will result to the extent -1. This overloads the method from base class ImageProperties.

Definition at line 167 of file mlSubImage.h.

References ml::TVector< TVectorBase >::getStrides().

◆ setData()

MLEXPORT void ml::SubImage::setData ( void *  data)
inline

Sets data as a new memory block for the subimage.

The previous block is NOT touched anymore and it is NOT freed or deleted. If the memory was previously set by setDataFromMemoryBlockHandle(), the memory block handle is cleared.

Definition at line 371 of file mlSubImage.h.

◆ setDataFromMemoryBlockHandle()

MLEXPORT void ml::SubImage::setDataFromMemoryBlockHandle ( const MLMemoryBlockHandle data)
inline

Sets the managed data from a given MLMemoryBlockHandle, the sub image will store this handle and thus reference count the memory managed by the handle as long as the SubImage stays alive.

This calls setData() with the data from the memory block handle.

Definition at line 377 of file mlSubImage.h.

References MLMemoryBlockHandle::data().

◆ setDataType()

void ml::SubImage::setDataType ( MLDataType  dataType)
inline

Overwrite inherited setDataType method to set type of data to dataType.

The validity flag is not changed.

Definition at line 275 of file mlSubImage.h.

References MLSizeOf().

◆ setExtent() [1/2]

void ml::SubImage::setExtent ( MLint  x,
MLint  y,
MLint  z = 1,
MLint  c = 1,
MLint  t = 1,
MLint  u = 1 
)
inline

Sets the extent of the subimage (which also changes the strides) to newExtent.

The default value for missing dimensions is 1.

Definition at line 195 of file mlSubImage.h.

◆ setExtent() [2/2]

void ml::SubImage::setExtent ( const ImageVector newExtent)
inline

Sets the extent of the subimage (which also changes the strides) to newExtent.

Definition at line 200 of file mlSubImage.h.

References ml::TVector< TVectorBase >::getStrides(), and ml::TImageVector< CompIntType >::set().

◆ setFromImageProperties()

MLEXPORT void ml::SubImage::setFromImageProperties ( const ImageProperties imageProperties)

Sets the image box and datatype from the imageProperties extent and datatype.

Note that this does not affect the stored data and that the resulting box will have v1 = ImageVector(0) and v2 = imageProperties.getImgExt()-1. This box is adequate for requesting the complete volume defined by imageProperties as a single tile.

◆ setImageExtent()

void ml::SubImage::setImageExtent ( const ImageVector newExtent)
inline
Deprecated:
Use setExtent() instead.

Sets the extent of the image.

Definition at line 220 of file mlSubImage.h.

◆ setImgExt()

void ml::SubImage::setImgExt ( const ImageVector newExtent)
inline
Deprecated:
Use setExtent() instead.

Definition at line 729 of file mlSubImage.h.

◆ setOrigin()

void ml::SubImage::setOrigin ( const ImageVector newOrigin)
inline

Sets the origin of the subimage (which moves the box of the subimage to newOrigin).

This method ensures that the extent stays the same.

Definition at line 184 of file mlSubImage.h.

◆ setSourceImageExtent()

void ml::SubImage::setSourceImageExtent ( const ImageVector extent)
inline

Sets the image extent of the source image that was used to create this SubImage to extent.

This is used for the intersection calculation of the getValidRegion() call.

Definition at line 231 of file mlSubImage.h.

◆ toImageProperties()

MLEXPORT ImageProperties ml::SubImage::toImageProperties ( ) const

Converts the Subimage's datatype and extend to an ImageProperties object.

Notice the the min/max values of the ImageProperties are not set, since a Subimage does not store a min/max value.

◆ toStream()

void ml::SubImage::toStream ( std::ostream &  ostr) const

◆ translate()

void ml::SubImage::translate ( const ImageVector offset)
inline

Translates the box of the subimage by adding the vector offset.

Definition at line 174 of file mlSubImage.h.

Member Data Documentation

◆ _box

SubImageBox ml::SubImage::_box
protected

The box of the subimage.

Definition at line 690 of file mlSubImage.h.

Referenced by operator=().

◆ _data

void* ml::SubImage::_data
protected

Memory chunk managed by this subimage.

Definition at line 696 of file mlSubImage.h.

Referenced by operator=().

◆ _dataType

MLDataType ml::SubImage::_dataType
protected

Datatype of the image.

Definition at line 707 of file mlSubImage.h.

Referenced by operator=().

◆ _memoryBlock

MLMemoryBlockHandle ml::SubImage::_memoryBlock
protected

Memory block used by this subimage.

Definition at line 699 of file mlSubImage.h.

Referenced by operator=().

◆ _sourceImageExtent

ImageVector ml::SubImage::_sourceImageExtent
protected

The extent of the source image, which is used for getValidRegion()

Definition at line 693 of file mlSubImage.h.

Referenced by operator=().

◆ _stride

ImageVector ml::SubImage::_stride
protected

Stride vector to address the memory efficiently.

So the memory address of an subimage voxel can easily be calculated from the dot product of strides and voxel position. Usually stride.x=1, stride.y=x, stride.z=x*y, stride.c=x*y*z,...

Definition at line 704 of file mlSubImage.h.

Referenced by operator=().


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