MeVisLab Toolbox Reference
ml::ManagedSubImage Class Reference

#include <mlManagedSubImage.h>

Inheritance diagram for ml::ManagedSubImage:
ml::SubImage

Public Member Functions

 ManagedSubImage ()
 Constructor.
ManagedSubImageoperator= (const SubImage &si)
 Copy operator from SubImage.
 ~ManagedSubImage () override
 Destruct the object and freeing the memory.
void * takeData ()
Public Member Functions inherited from ml::SubImage
const SubImageBoxgetBox () const
 Returns the box describing the origin/extent of the subimage.
void setSourceImageExtent (const ImageVector &extent)
ImageVector getSourceImageExtent () const
SubImageBox getValidRegion () const
MLint getNumVoxels () const
MLint getSizeInBytes () const
ImageVector getStride () const
MLint getOffset (const ImageVector &voxelPosition) const
 Returns the array index offset from the origin (0,0,0,0,0,0) to the voxelPosition.
void setDataType (MLDataType dataType)
MLDataType getDataType () const
 Returns the type of image data.
const MLTypeInfosgetDataTypeInfos () const
 Returns MLTypeInfos for image data type.
MLEXPORT ImageProperties toImageProperties () const
MLEXPORT void setFromImageProperties (const ImageProperties &imageProperties)
void toStream (std::ostream &ostr) const
 SubImage ()
 Constructor: Creates a subimage with no data.
 SubImage (const SubImage &si)
 SubImage (const SubImageBox &box, MLDataType datatype, void *data=nullptr)
 SubImage (const SubImage &si, const ImageVector &offset)
virtual ~SubImage ()=default
 Virtual destructor to suppress compiler warnings.
SubImageoperator= (const SubImage &si)
void setBox (const SubImageBox &subImageBox)
void setBox (const ImageVector &imageExtent)
void translate (const ImageVector &offset)
 Translates the box of the subimage by adding the vector offset.
const ImageVectorgetOrigin () const
 Returns the origin of the subimage, which is identical to getBox().v1.
void setOrigin (const ImageVector &newOrigin)
ImageVector getExtent () const
 Returns the extent of the subimage, which is identical to getBox().getExtent().
void setExtent (MLint x, MLint y, MLint z=1, MLint c=1, MLint t=1, MLint u=1)
void setExtent (const ImageVector &newExtent)
 Sets the extent of the subimage to newExtent. This also changes the strides.
SubImageBox getBoxFromExtent () const
 Returns the size of image as box with origin 0.
SubImageBox getBoxFromImageExtent () const
ImageVector getImageExtent () const
void setImageExtent (const ImageVector &newExtent)
void * getSubImagePointer (const ImageVector &voxelPosition) const
void * getSubImagePointer (MLint x, MLint y, MLint z) const
void * getImagePointer (const ImageVector &voxelPosition) const
void * getImagePointer (MLint x, MLint y, MLint z) const
MLEXPORT void copySubImage (const SubImage &fromImage, const ScaleShiftData &scaleShiftData)
MLEXPORT void copySubImage (const SubImage &fromImage)
bool isValidSubImagePosition (const ImageVector &voxelPosition) const
bool isValidSubImagePosition (MLint x, MLint y, MLint z) const
bool isValidImagePosition (const ImageVector &voxelPosition) const
bool isValidImagePosition (MLint x, MLint y, MLint z) const
MLEXPORT void allocate (MLMemoryErrorHandling handleFailure)
MLEXPORT void allocateAsMemoryBlockHandle (MLMemoryErrorHandling handleFailure=ML_RETURN_NULL)
 Allocates data using the ML memory manager. For failure handing, see SubImage::allocate().
MLEXPORT void free ()
MLEXPORT bool isOneValued () const
MLEXPORT MLint calculateMinMax (MLdouble &minValue, MLdouble &maxValue, const SubImageBox *const validBox=nullptr) const
MLEXPORT void compare (const SubImage &subImage2, bool *regionsMatch, bool *dataTypesMatch, bool *thisBoxIsPartOfRegion2, bool *region2IsPartOfThisBox, bool *overlapHasSameValues, ImageVector *firstMismatchPos) const
MLEXPORT void fill (MLdouble value)
 Fills the subimage with a value that is cast to the data type of the subimage.
MLEXPORT void fillWithTypeData (const MLTypeData *value)
MLEXPORT void fillBordersWithScalarValue (const SubImageBox &box, MLdouble fillValue)
MLEXPORT void fillBordersWithTypeData (const SubImageBox &box, const MLTypeData *fillValue)
MLEXPORT void fillBordersWithInputValues (const SubImageBox &box, const SubImage &inputSubImage)
MLEXPORT void fillBordersWithBorderValues (const SubImageBox &box)
void fillInvalidRegionWithScalarValue (MLdouble value)
void fillInvalidRegionWithTypeData (const MLTypeData *value)
void fillInvalidRegionWithBorderValues ()
MLEXPORT bool isValid () const
void * getData () const
 Returns the memory address of the memory managed by the subimage.
MLEXPORT void setData (void *data)
MLEXPORT void setDataFromMemoryBlockHandle (const MLMemoryBlockHandle &data)
const MLMemoryBlockHandlegetMemoryBlockHandle () const

Additional Inherited Members

static MLEXPORT MLint coordToIndex (MLint x, MLint y, MLint z, MLint c, MLint t, MLint u, const ImageVector &size)
static MLEXPORT MLint coordToIndex (const ImageVector &voxelPosition, const ImageVector &size)
static MLEXPORT ImageVector indexToCoord (MLint index, const ImageVector &extent)
Protected Member Functions inherited from ml::SubImage
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)
void _copySubImageGeneric (const SubImage &fromImage, const ScaleShiftData &scaleShiftData)
 Generic, non-optimized version of copySubImage.
const MLTypeInfos_getDataTypeInfos (MLDataType dt) const
 Returns MLTypeInfos for used datatypes, indicates error if the type dt is not registered.
Protected Attributes inherited from ml::SubImage
SubImageBox _box
 The box of the subimage.
ImageVector _sourceImageExtent
 The extent of the source image, which is used for getValidRegion().
void * _data
 Memory chunk managed by this subimage.
MLMemoryBlockHandle _memoryBlock
 Memory block used by this subimage.
ImageVector _stride
MLDataType _dataType
 Data type of the image.

Detailed Description

ManagedSubImage is derived from SubImage and frees its allocated memory automatically when it is destructed. If you make use of TileRequest::AllocationPolicy == TileRequest::ExternalBuffer, make sure that you call takeData(); otherwise, this class will delete your external buffer in its destructor!

The class is not exported to make inlining possible.

Definition at line 30 of file mlManagedSubImage.h.

Constructor & Destructor Documentation

◆ ManagedSubImage()

ml::ManagedSubImage::ManagedSubImage ( )
inline

Constructor.

Definition at line 35 of file mlManagedSubImage.h.

Referenced by operator=().

◆ ~ManagedSubImage()

ml::ManagedSubImage::~ManagedSubImage ( )
inlineoverride

Destruct the object and freeing the memory.

Definition at line 44 of file mlManagedSubImage.h.

References ml::SubImage::free().

Member Function Documentation

◆ operator=()

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

Copy operator from SubImage.

Definition at line 38 of file mlManagedSubImage.h.

References ManagedSubImage(), ml::SubImage::operator=(), and ml::SubImage::SubImage().

◆ takeData()

void * ml::ManagedSubImage::takeData ( )
inline

Returns the data pointer and set the internal data to NULL (so it passes the ownership of the data to the caller) Note: This should only be used on images that where allocated via MLAlloc or with user provided memory. It will not work correctly on memory allocated by the MemoryManager, as one has to use getMemoryBlockHandle() instead to get the data.

Definition at line 52 of file mlManagedSubImage.h.

References ml::SubImage::getData(), and ml::SubImage::setData().


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