MeVisLab Toolbox Reference
ml::BitImage Class Reference

Class to manage a binary image. More...

#include <mlBitImage.h>

Inheritance diagram for ml::BitImage:
ml::Base

Public Types

Operation modes to write bit images into normal subimages.
enum  OperationModes {
  SET_MODE = 0 , OR_MODE , AND_MODE , XOR_MODE ,
  CLEAR_MODE , NUM_MODES
}
 
- Public Types inherited from ml::Base
enum  PersistenceInterface { PersistenceByString , PersistenceByTreeNode , PersistenceByStream }
 This enum describes the different persistence interfaces available. More...
 

Public Member Functions

Construction, Destruction, Assignment

Constructor.

Creates an empty bit image (extents (0,0,0,0,0,0)). If useExceptions is passed as true then all errors in bit image usage throw exceptions instead of causing damage. Otherwise no checks are performed which will damage the program usually.

 BitImage (bool useExceptions=false)
 
 BitImage (const ImageVector &ext, bool useExceptions=false)
 Convenience constructor. More...
 
MLTOOLS_EXPORT BitImage (const BitImage &bitImg)
 Copy constructor, copies bitImg to this instance. More...
 
MLTOOLS_EXPORT ~BitImage () override
 Destructor. Never throws controlled diagnostic exceptions. More...
 
void reset ()
 Make image empty and restore default construction state with disabled exceptions. More...
 
bool useExceptionHandling () const
 Return true if exception handling is on, otherwise return false. More...
 
MLTOOLS_EXPORT void useExceptionHandling (bool useExceptions)
 Pass true to enable exception handling, false to disable it. More...
 
MLTOOLS_EXPORT const BitImageoperator= (const BitImage &bitImg)
 Assignment operator. More...
 
Extents

Resize image.

Contents are destroyed and initialized to zero. On memory allocation failure or too large extents (> 4 giga bit) false is returned, and image is left in reset state without allocated memory. Otherwise true is returned. On extent changes the cursor is reset to position 0. Negative extents are handled as ImageVector(0,0,0,0,0,0) extent and no memory is allocated, and true is returned. Throws no controlled diagnostic exceptions even if exception handling is on.

bool setExtent (const ImageVector &ext)
 
const ImageVectorgetExtent () const
 Return image size. Never throws controlled diagnostic exceptions. More...
 
const SubImageBox getBoxFromImageExtent () const
 Return a SubImageBox representing the image extent of the BitImage. More...
 
const SubImageBoxgetSourceBox () const
 Returns the original placement of the bit image corresponding to a potential image the bit image is created from. More...
 
void setSourceBox (const SubImageBox &box)
 Sets the original placement of the bit image corresponding to a potential image the bit image is created from. More...
 
Miscellaneous

Returns some basic statistical values.

Passed NULL pointers are not set. Not const but it doesn't modify the instance really.

const ImageVectorgetStrides () const
 
MLint getCursorBitIndex () const
 Return strides for words. Never throws controlled diagnostic exceptions. More...
 
bool isEmpty () const
 Returns true if image is empty. Never throws controlled diagnostic exceptions. More...
 
void clear (bool val)
 Clears/sets all bits in the image. Never throws controlled diagnostic exceptions. More...
 
MLTOOLS_EXPORT void getStatistics (MLuint64 *numBits, MLuint64 *numSetBits, MLuint64 *numClearedBits)
 
MLTOOLS_EXPORT BitImagegetDownScaledBitImage (const ImageVector &scales) const
 Create a down scaled mlBitImage from this. More...
 
MLTOOLS_EXPORT long updateBitImageFromVolume (const void *data, const MLDataType dType, const SubImageBox &origBox, const double minVal, const double maxVal, const unsigned char addBorderPixels=0)
 Scan volume given by data and origBox and filter all values through the interval given by [minVal, maxVal). More...
 
MLTOOLS_EXPORT SubImageBox calculateBoundingBox (bool val=true)
 Calculates the bounding box of all bits of value val (default is true). More...
 
MLTOOLS_EXPORT void copyToBitImage (BitImage &dstBitImg, OperationModes mode=SET_MODE, const SubImageBox &box=SubImageBox(), const ImageVector &offset=ImageVector(0))
 Copy all bits from the overlapping regions from box and *this to the position box.v1+offset to dstBitImg. More...
 
MLTOOLS_EXPORT BitImagegetSubBitImageByMask (bool val, SubImageBox *maskedBox=nullptr)
 Calculates the bounding box of all bits of value val and returns a new BitImage containing exactly that area. More...
 
Direct access to image content
bool operator[] (const ImageVector &pos) const
 Constant vector index read access to voxel value at position pos. More...
 
void setValue (const ImageVector &pos, const bool v)
 Set bit at position pos to value v. More...
 
void set (const ImageVector &pos)
 Set bit at position pos optimized for all extents of a bit image. More...
 
void clear (const ImageVector &pos)
 Clear bit at position pos optimized for all extents of a bit image. More...
 
void toggle (const ImageVector &pos)
 Toggle bit at position pos. More...
 
bool isSet (const ImageVector &pos) const
 Return true if bit at position pos is set, otherwise false. More...
 
bool isInRange (const ImageVector &p) const
 Test for ImageVector coordinates in valid range. More...
 
bool isInRange (const Vector6 &p) const
 Test for Vector6 coordinates in valid range. More...
 
General cursor management.

Set cursor position to position pos.

If exceptions are on and pos is out of range then the error code ML_OUT_OF_RANGE is thrown. Otherwise program state becomes undefined.

void setCursorPosition (const ImageVector &pos)
 
const ImageVectorgetCursorPosition () const
 Return current cursor position. Never throws controlled diagnostic exceptions. More...
 
bool getCursorValue () const
 Return true if bit under cursor is true, otherwise false. Never throws controlled diagnostic exceptions. More...
 
void setCursorValue (const bool val)
 Sets the bit under the cursor to 1 if true is passed as val, otherwise 0 is set. Never throws controlled diagnostic exceptions. More...
 
void setCursorValue ()
 Sets the bit under the cursor to 1. Never throws controlled diagnostic exceptions. More...
 
void toggleCursorValue ()
 Toggles the bit under the cursor. Never throws controlled diagnostic exceptions. More...
 
void clearCursorValue ()
 Clears the bit under the cursor to 0. Never throws controlled diagnostic exceptions. More...
 
size_t getCursorWordIndex () const
 Return index to word in image to which the cursor points. Never throws controlled diagnostic exceptions. More...
 
ML_BIT_IMG_DATA_TYPE getCursorWord () const
 Return content of word in image to which the cursor points. More...
 
ML_BIT_IMG_DATA_TYPE getCursorBitMask () const
 Return the bit mask specifying the bit in the cursor word. Never throws controlled diagnostic exceptions. More...
 
Cursor movements forward in X/Y/Z/C/T/U direction. Throws MLErrorCode exceptions when going to invalid position if exception handling is enabled, otherwise state becomes instable.
void moveCursorX ()
 
void moveCursorY ()
 
void moveCursorZ ()
 
void moveCursorC ()
 
void moveCursorT ()
 
void moveCursorU ()
 
Cursor movements backward in X/Y/Z/C/T/U direction. Throws MLErrorCode exceptions when going to invalid position if exception handling is enabled, otherwise state becomes instable.
void reverseMoveCursorX ()
 
void reverseMoveCursorY ()
 
void reverseMoveCursorZ ()
 
void reverseMoveCursorC ()
 
void reverseMoveCursorT ()
 
void reverseMoveCursorU ()
 
Linear image traversal.

Set cursor and dependent members to default position (0,0,0,0,0,0).

Throws no controlled diagnostic exceptions even if exception handling is on.

MLTOOLS_EXPORT void resetCursor ()
 
MLTOOLS_EXPORT bool moveCursorXWrapAround ()
 Special cursor move: Increment x coordinate of cursor. More...
 
Interactions with subimages and subimage boxes
MLTOOLS_EXPORT void fill (const SubImageBox &box, const bool value)
 Fill the area given by box in the bit image with value value. More...
 
MLTOOLS_EXPORT void invert (const SubImageBox &box)
 Toggle the area given by box in the bit image. More...
 
MLTOOLS_EXPORT void copyToSubImage (SubImage &outSubImg, const double bkVal, const double fgVal, const OperationModes mode=SET_MODE) const
 Copy area from the bit image into the subimage given by outSubImg. More...
 
MLTOOLS_EXPORT void copyFromSubImage (SubImage &inImg, const SubImageBox &box, const ImageVector &pos, const double intMin, const double intMax)
 Copy the area given by box from inImg to the position p of the bitImage. More...
 
Save/load bit image from file.
MLTOOLS_EXPORT bool is64BitVersion () const
 Returns true if any member or allocated buffer requires 64 handling, otherwise false is returned. More...
 
MLTOOLS_EXPORT bool writeToFile (const std::string &path, bool overwrite=true)
 Writes bit image content into file specified by path path and return true on success and false on failure. More...
 
MLTOOLS_EXPORT MLErrorCode save (const std::string &path, bool overwrite=true)
 Writes bit image content into file specified by path. More...
 
MLTOOLS_EXPORT bool readFromFile (const std::string &path)
 Reads a bit image from file specified by path and returns true on success, false on error. More...
 
MLTOOLS_EXPORT MLErrorCode load (const std::string &path)
 Read bit image from file specified by path and returns ML_RESULT_OK success or another error code in case of failure. More...
 
Direct manipulation interface.
ML_BIT_IMG_DATA_TYPEgetImageMemory ()
 Provide access to the BitImage memory. More...
 
size_t getNumberOfAllocatedImageMemoryWords () const
 Returns the number of currently allocated ML_BIT_IMG_DATA_TYPE words. More...
 
- Public Member Functions inherited from ml::Base
 Base ()
 Constructor. More...
 
virtual ~Base ()
 Destructor. More...
 
virtual BasedeepCopy () const
 Set addStateToTree version number that can be accessed via getAddStateVersion() More...
 
bool isOfAllowedType (const std::vector< const RuntimeType * > &types) const
 Check if this object's type is equal to or derived from one of the types given in the argument. More...
 
virtual bool isRefCountedBase () const
 Returns if the instance is derived from RefCountedBase. More...
 
virtual std::string detailString () const
 Return a string describing this object. More...
 
virtual bool implementsPersistence (PersistenceInterface) const
 Override this method to declare which persistence interfaces are implemented by your derived class. More...
 
virtual std::string persistentState () const
 Returns a string describing the object's internal state. More...
 
virtual void setPersistentState (const std::string &state)
 Restores the object's internal state from a string that had been previously generated using persistentState(). More...
 
virtual void addStateToTree (TreeNode *) const
 Attaches the object state as children of the given parent node. More...
 
virtual void readStateFromTree (TreeNode *)
 Reads the object state from the children of the given parent node. More...
 
virtual void writeTo (AbstractPersistenceOutputStream *) const
 Write the objects state to the data stream object. More...
 
virtual void readFrom (AbstractPersistenceInputStream *, int)
 Read the objects state from the data stream object. More...
 

Static Public Member Functions

static MLTOOLS_EXPORT MLuint32 selfTest ()
 Starts a self test of the mlBitImage class. More...
 

Additional Inherited Members

- Protected Member Functions inherited from ml::Base
virtual char * getPersistentState () const
 Returns a C string describing the object's internal state. More...
 
virtual void setPersistentState (const char *)
 Restores the object's internal state from a string that had been previously generated using getPersistentState(). More...
 
virtual void clearPersistentState (char *) const
 Disposes a string previously allocated by getPersistentState(). More...
 

Detailed Description

Class to manage a binary image.

Definition at line 67 of file mlBitImage.h.

Member Enumeration Documentation

◆ OperationModes

Enumerator
SET_MODE 

values are written/replaced into target values.

OR_MODE 

values are ored to target values.

AND_MODE 

values are anded to/with target values.

XOR_MODE 

values are xored to/with target values.

CLEAR_MODE 

set bits in values are cleared in target values.

NUM_MODES 

number of OperationMode enums.

Definition at line 73 of file mlBitImage.h.

Constructor & Destructor Documentation

◆ BitImage() [1/3]

ml::BitImage::BitImage ( bool  useExceptions = false)
inline

Definition at line 89 of file mlBitImage.h.

◆ BitImage() [2/3]

ml::BitImage::BitImage ( const ImageVector ext,
bool  useExceptions = false 
)
inline

Convenience constructor.

Create a bit image with extents given by ext. If useExceptions is passed as true then all errors in bit image usage throw exceptions instead of causing damage. Otherwise no checks are performed which will damage the program usually. Image contents image will be undefined after creation.

Definition at line 96 of file mlBitImage.h.

◆ BitImage() [3/3]

MLTOOLS_EXPORT ml::BitImage::BitImage ( const BitImage bitImg)

Copy constructor, copies bitImg to this instance.

If copying fails due to lack of memory then *this is left in reset state and ML_NO_MEMORY is thrown; without activated exception handling the program runs in an undefined state.

◆ ~BitImage()

MLTOOLS_EXPORT ml::BitImage::~BitImage ( )
inlineoverride

Destructor. Never throws controlled diagnostic exceptions.

Definition at line 106 of file mlBitImage.h.

Member Function Documentation

◆ calculateBoundingBox()

MLTOOLS_EXPORT SubImageBox ml::BitImage::calculateBoundingBox ( bool  val = true)

Calculates the bounding box of all bits of value val (default is true).

An empty SubImageBox is returned if no bits of value val are found.

◆ clear() [1/2]

void ml::BitImage::clear ( bool  val)
inline

Clears/sets all bits in the image. Never throws controlled diagnostic exceptions.

Definition at line 189 of file mlBitImage.h.

◆ clear() [2/2]

void ml::BitImage::clear ( const ImageVector pos)
inline

Clear bit at position pos optimized for all extents of a bit image.

If exceptions are on and pos is out of range then the error code ML_OUT_OF_RANGE is thrown. Otherwise program state becomes undefined.

Definition at line 214 of file mlBitImage.h.

References ML_BIT_IMG_ALL_BITS, ML_BIT_IMG_DATA_TYPE, ML_BIT_IMG_INDEX_BITS, ML_BIT_IMG_LOW_BIT, and ML_BIT_IMG_SHIFT.

◆ clearCursorValue()

void ml::BitImage::clearCursorValue ( )
inline

Clears the bit under the cursor to 0. Never throws controlled diagnostic exceptions.

Definition at line 259 of file mlBitImage.h.

References ML_BIT_IMG_ALL_BITS, ML_BIT_IMG_DATA_TYPE, ML_BIT_IMG_INDEX_BITS, ML_BIT_IMG_LOW_BIT, and ML_BIT_IMG_SHIFT.

◆ copyFromSubImage()

MLTOOLS_EXPORT void ml::BitImage::copyFromSubImage ( SubImage inImg,
const SubImageBox box,
const ImageVector pos,
const double  intMin,
const double  intMax 
)

Copy the area given by box from inImg to the position p of the bitImage.

The box position (0,0,0,0,0,0) is considered the first valid voxel in inImg. Before copying the region to copy is limited to valid areas. All values >= intMin and < intMax are set to true all other values are set to false.

◆ copyToBitImage()

MLTOOLS_EXPORT void ml::BitImage::copyToBitImage ( BitImage dstBitImg,
OperationModes  mode = SET_MODE,
const SubImageBox box = SubImageBox(),
const ImageVector offset = ImageVector(0) 
)

Copy all bits from the overlapping regions from box and *this to the position box.v1+offset to dstBitImg.

Only valid regions in *this are read and copied to dstBitImg. offset defaults to the 0 vector. If box is empty (the default) then the full *this image is copied to position offset as far as target pixels are inside dstBitImg. mode (which defaults to SET_MODE) determines the way how bits in the target image are modified by the copy operation.

◆ copyToSubImage()

MLTOOLS_EXPORT void ml::BitImage::copyToSubImage ( SubImage outSubImg,
const double  bkVal,
const double  fgVal,
const OperationModes  mode = SET_MODE 
) const

Copy area from the bit image into the subimage given by outSubImg.

Note that only valid regions of the bit image are read - if outSubImg reaches outside the bit image the corresponding areas are not read, i.e. these regions are left undefined in outSubImg. bkVal is written for false bits, fgVal for true bits. mode describes how the values are written into the voxel values of outSubImage; default is BitImage::SET_MODE. On non integer data types all modes not equal to BitImage::SET_MODE cast the values to MLint64, apply the operations and cast back the results to the data type of outSubImg. Note: bkVal and fgVal are always cast to the data type of outSubImg.

◆ fill()

MLTOOLS_EXPORT void ml::BitImage::fill ( const SubImageBox box,
const bool  value 
)

Fill the area given by box in the bit image with value value.

If area reaches outside the image then it's automatically clamped to a valid region.

◆ getBoxFromImageExtent()

const SubImageBox ml::BitImage::getBoxFromImageExtent ( ) const
inline

Return a SubImageBox representing the image extent of the BitImage.

Definition at line 153 of file mlBitImage.h.

◆ getCursorBitIndex()

MLint ml::BitImage::getCursorBitIndex ( ) const
inline

Return strides for words. Never throws controlled diagnostic exceptions.

Definition at line 183 of file mlBitImage.h.

◆ getCursorBitMask()

ML_BIT_IMG_DATA_TYPE ml::BitImage::getCursorBitMask ( ) const
inline

Return the bit mask specifying the bit in the cursor word. Never throws controlled diagnostic exceptions.

Definition at line 269 of file mlBitImage.h.

References ML_BIT_IMG_DATA_TYPE, ML_BIT_IMG_INDEX_BITS, and ML_BIT_IMG_LOW_BIT.

◆ getCursorPosition()

const ImageVector& ml::BitImage::getCursorPosition ( ) const
inline

Return current cursor position. Never throws controlled diagnostic exceptions.

Definition at line 244 of file mlBitImage.h.

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

◆ getCursorValue()

bool ml::BitImage::getCursorValue ( ) const
inline

Return true if bit under cursor is true, otherwise false. Never throws controlled diagnostic exceptions.

Definition at line 247 of file mlBitImage.h.

References ML_BIT_IMG_INDEX_BITS, ML_BIT_IMG_LOW_BIT, and ML_BIT_IMG_SHIFT.

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

◆ getCursorWord()

ML_BIT_IMG_DATA_TYPE ml::BitImage::getCursorWord ( ) const
inline

Return content of word in image to which the cursor points.

Bits of positions outside the image contain undefined values. Never throws controlled diagnostic exceptions.

Definition at line 266 of file mlBitImage.h.

References ML_BIT_IMG_SHIFT.

◆ getCursorWordIndex()

size_t ml::BitImage::getCursorWordIndex ( ) const
inline

Return index to word in image to which the cursor points. Never throws controlled diagnostic exceptions.

Definition at line 262 of file mlBitImage.h.

References ML_BIT_IMG_SHIFT.

◆ getDownScaledBitImage()

MLTOOLS_EXPORT BitImage* ml::BitImage::getDownScaledBitImage ( const ImageVector scales) const

Create a down scaled mlBitImage from this.

Each extent in all dimensions is scaled down by the corresponding component in scales and increased by 1. A component wise multiplication of a coordinate of the pixel of the result with scales is the original coordinate in the bit image. E.g. (3,1,2,0,0) in the down scaled image comes from position (6,4,2,0,0,0) if scales is (2,4,1,1,1,1). NULL is returned if the original image is empty or the allocation of the result image fails. The user must delete the result after usage.

◆ getExtent()

const ImageVector& ml::BitImage::getExtent ( ) const
inline

Return image size. Never throws controlled diagnostic exceptions.

Definition at line 150 of file mlBitImage.h.

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

◆ getImageMemory()

ML_BIT_IMG_DATA_TYPE* ml::BitImage::getImageMemory ( )
inline

Provide access to the BitImage memory.

It can be used for fast memory copy operations, however, it has to be used very carefully, because it requires detailed knowledge about the internal memory structure.

Definition at line 460 of file mlBitImage.h.

◆ getNumberOfAllocatedImageMemoryWords()

size_t ml::BitImage::getNumberOfAllocatedImageMemoryWords ( ) const
inline

Returns the number of currently allocated ML_BIT_IMG_DATA_TYPE words.

Definition at line 463 of file mlBitImage.h.

◆ getSourceBox()

const SubImageBox& ml::BitImage::getSourceBox ( ) const
inline

Returns the original placement of the bit image corresponding to a potential image the bit image is created from.

Default is always empty if not set by setSourceBox() or updateBitImageFromVolume() or by instance assignment/loading. Note that box sometimes is used differently: v1 contains the location of the BitImage mask relative to the origin of the original image which starts at (0,0,0,0,0) and v2 the extent of the image. Never throws controlled diagnostic exceptions.

Definition at line 162 of file mlBitImage.h.

◆ getStatistics()

MLTOOLS_EXPORT void ml::BitImage::getStatistics ( MLuint64 numBits,
MLuint64 numSetBits,
MLuint64 numClearedBits 
)

◆ getStrides()

const ImageVector& ml::BitImage::getStrides ( ) const
inline

Definition at line 180 of file mlBitImage.h.

◆ getSubBitImageByMask()

MLTOOLS_EXPORT BitImage* ml::BitImage::getSubBitImageByMask ( bool  val,
SubImageBox maskedBox = nullptr 
)

Calculates the bounding box of all bits of value val and returns a new BitImage containing exactly that area.

If the pointer maskedBox is passed non NULL then it will be filled with the bounding box of the determined mask. If NULL (the default) it will be ignored. A NULL pointer is returned on failure or if no bits of value val are found.

◆ invert()

MLTOOLS_EXPORT void ml::BitImage::invert ( const SubImageBox box)

Toggle the area given by box in the bit image.

If area reaches outside the image then it's automatically clamped to a valid region.

◆ is64BitVersion()

MLTOOLS_EXPORT bool ml::BitImage::is64BitVersion ( ) const

Returns true if any member or allocated buffer requires 64 handling, otherwise false is returned.

◆ isEmpty()

bool ml::BitImage::isEmpty ( ) const
inline

Returns true if image is empty. Never throws controlled diagnostic exceptions.

Definition at line 186 of file mlBitImage.h.

◆ isInRange() [1/2]

bool ml::BitImage::isInRange ( const ImageVector p) const
inline

Test for ImageVector coordinates in valid range.

Only the image dimensions are tested. Never throws controlled diagnostic exceptions.

Definition at line 228 of file mlBitImage.h.

◆ isInRange() [2/2]

bool ml::BitImage::isInRange ( const Vector6 p) const
inline

Test for Vector6 coordinates in valid range.

Only the image dimensions are tested. Never throws controlled diagnostic exceptions.

Definition at line 232 of file mlBitImage.h.

◆ isSet()

bool ml::BitImage::isSet ( const ImageVector pos) const
inline

Return true if bit at position pos is set, otherwise false.

If exceptions are on and pos is out of range then the error code ML_OUT_OF_RANGE is thrown. Otherwise program state becomes undefined.

Definition at line 224 of file mlBitImage.h.

References ML_BIT_IMG_INDEX_BITS, ML_BIT_IMG_LOW_BIT, and ML_BIT_IMG_SHIFT.

◆ load()

MLTOOLS_EXPORT MLErrorCode ml::BitImage::load ( const std::string &  path)

Read bit image from file specified by path and returns ML_RESULT_OK success or another error code in case of failure.

Content of *this will be undefined in case of non ML_RESULT_OK return value .

◆ moveCursorC()

void ml::BitImage::moveCursorC ( )
inline

Definition at line 277 of file mlBitImage.h.

◆ moveCursorT()

void ml::BitImage::moveCursorT ( )
inline

Definition at line 278 of file mlBitImage.h.

◆ moveCursorU()

void ml::BitImage::moveCursorU ( )
inline

Definition at line 279 of file mlBitImage.h.

◆ moveCursorX()

void ml::BitImage::moveCursorX ( )
inline

Definition at line 274 of file mlBitImage.h.

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

◆ moveCursorXWrapAround()

MLTOOLS_EXPORT bool ml::BitImage::moveCursorXWrapAround ( )

Special cursor move: Increment x coordinate of cursor.

When going out of image set x to zero and increase y. If y overflows then increment z etc. So an image can easily scanned as a one dimensional sequence. If the cursor is on the last voxel it won't be moved outside the image; it remains there without throwing exceptions or causing errors. It just returns false instead of true. So the sequence resetCursor(); do {} while (moveCursorXWrapAround()); permits easy bit image scanning. Throws no controlled diagnostic exceptions even if exception handling is on.

◆ moveCursorY()

void ml::BitImage::moveCursorY ( )
inline

Definition at line 275 of file mlBitImage.h.

◆ moveCursorZ()

void ml::BitImage::moveCursorZ ( )
inline

Definition at line 276 of file mlBitImage.h.

◆ operator=()

MLTOOLS_EXPORT const BitImage& ml::BitImage::operator= ( const BitImage bitImg)

Assignment operator.

Assigns bitImg to this instance. Throws ML_NO_MEMORY as diagnostic exceptions if exception handling is on and assignment fails due to lack of memory. In such a case *this is left unchanged.

◆ operator[]()

bool ml::BitImage::operator[] ( const ImageVector pos) const
inline

Constant vector index read access to voxel value at position pos.

If exceptions are on and pos is out of range then the error code ML_OUT_OF_RANGE is thrown. Otherwise program state becomes undefined.

Definition at line 199 of file mlBitImage.h.

◆ readFromFile()

MLTOOLS_EXPORT bool ml::BitImage::readFromFile ( const std::string &  path)

Reads a bit image from file specified by path and returns true on success, false on error.

Only for backward compatibility, use load() instead.

◆ reset()

void ml::BitImage::reset ( void  )
inline

Make image empty and restore default construction state with disabled exceptions.

Never throws controlled diagnostic exceptions.

Definition at line 110 of file mlBitImage.h.

◆ resetCursor()

MLTOOLS_EXPORT void ml::BitImage::resetCursor ( )

◆ reverseMoveCursorC()

void ml::BitImage::reverseMoveCursorC ( )
inline

Definition at line 287 of file mlBitImage.h.

◆ reverseMoveCursorT()

void ml::BitImage::reverseMoveCursorT ( )
inline

Definition at line 288 of file mlBitImage.h.

◆ reverseMoveCursorU()

void ml::BitImage::reverseMoveCursorU ( )
inline

Definition at line 289 of file mlBitImage.h.

◆ reverseMoveCursorX()

void ml::BitImage::reverseMoveCursorX ( )
inline

Definition at line 284 of file mlBitImage.h.

◆ reverseMoveCursorY()

void ml::BitImage::reverseMoveCursorY ( )
inline

Definition at line 285 of file mlBitImage.h.

◆ reverseMoveCursorZ()

void ml::BitImage::reverseMoveCursorZ ( )
inline

Definition at line 286 of file mlBitImage.h.

◆ save()

MLTOOLS_EXPORT MLErrorCode ml::BitImage::save ( const std::string &  path,
bool  overwrite = true 
)

Writes bit image content into file specified by path.

Return ML_RESULT_OK on success or another error code on failure. If overwrite is true (default) then existing files are overwritten, otherwise they won't be harmed and ML_OBJECT_OR_FILE_EXISTS is returned.

◆ selfTest()

static MLTOOLS_EXPORT MLuint32 ml::BitImage::selfTest ( )
static

Starts a self test of the mlBitImage class.

Returns a nonzero value if test failed. Return value is 0 if everything is okay.

◆ set()

void ml::BitImage::set ( const ImageVector pos)
inline

Set bit at position pos optimized for all extents of a bit image.

If exceptions are on and pos is out of range then the error code ML_OUT_OF_RANGE is thrown. Otherwise program state becomes undefined.

Definition at line 209 of file mlBitImage.h.

References ML_BIT_IMG_DATA_TYPE, ML_BIT_IMG_INDEX_BITS, ML_BIT_IMG_LOW_BIT, and ML_BIT_IMG_SHIFT.

◆ setCursorPosition()

void ml::BitImage::setCursorPosition ( const ImageVector pos)
inline

Definition at line 241 of file mlBitImage.h.

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

◆ setCursorValue() [1/2]

void ml::BitImage::setCursorValue ( )
inline

Sets the bit under the cursor to 1. Never throws controlled diagnostic exceptions.

Definition at line 253 of file mlBitImage.h.

References ML_BIT_IMG_DATA_TYPE, ML_BIT_IMG_INDEX_BITS, ML_BIT_IMG_LOW_BIT, and ML_BIT_IMG_SHIFT.

◆ setCursorValue() [2/2]

void ml::BitImage::setCursorValue ( const bool  val)
inline

Sets the bit under the cursor to 1 if true is passed as val, otherwise 0 is set. Never throws controlled diagnostic exceptions.

Definition at line 250 of file mlBitImage.h.

References setCursorValue().

Referenced by setCursorValue().

◆ setExtent()

bool ml::BitImage::setExtent ( const ImageVector ext)
inline

Definition at line 140 of file mlBitImage.h.

◆ setSourceBox()

void ml::BitImage::setSourceBox ( const SubImageBox box)
inline

Sets the original placement of the bit image corresponding to a potential image the bit image is created from.

Default is always empty if not set by this method, updateBitImageFromVolume() or by instance assignment/loading. Never throws controlled diagnostic exceptions. Note that box sometimes is used differently: v1 contains the location of the BitImage mask relative to the origin of the original image which starts at (0,0,0,0,0) and v2 the extent of the image.

Definition at line 171 of file mlBitImage.h.

◆ setValue()

void ml::BitImage::setValue ( const ImageVector pos,
const bool  v 
)
inline

Set bit at position pos to value v.

If exceptions are on and pos is out of range then the error code ML_OUT_OF_RANGE is thrown. Otherwise program state becomes undefined.

Definition at line 204 of file mlBitImage.h.

◆ toggle()

void ml::BitImage::toggle ( const ImageVector pos)
inline

Toggle bit at position pos.

If exceptions are on and pos is out of range then the error code ML_OUT_OF_RANGE is thrown. Otherwise program state becomes undefined.

Definition at line 219 of file mlBitImage.h.

References ML_BIT_IMG_DATA_TYPE, ML_BIT_IMG_INDEX_BITS, ML_BIT_IMG_LOW_BIT, and ML_BIT_IMG_SHIFT.

◆ toggleCursorValue()

void ml::BitImage::toggleCursorValue ( )
inline

Toggles the bit under the cursor. Never throws controlled diagnostic exceptions.

Definition at line 256 of file mlBitImage.h.

References ML_BIT_IMG_DATA_TYPE, ML_BIT_IMG_INDEX_BITS, ML_BIT_IMG_LOW_BIT, and ML_BIT_IMG_SHIFT.

◆ updateBitImageFromVolume()

MLTOOLS_EXPORT long ml::BitImage::updateBitImageFromVolume ( const void *  data,
const MLDataType  dType,
const SubImageBox origBox,
const double  minVal,
const double  maxVal,
const unsigned char  addBorderPixels = 0 
)

Scan volume given by data and origBox and filter all values through the interval given by [minVal, maxVal).

Find a bounding box so that all values within this interval are within that box and set the bitImage to this size. All voxels within the interval result in a set bit in the bitImage all others result to false. The method returns the number of set bits in bitImage and the resulting bounding box is stored in _sourceBox. If addBorderPixels has bits set of its first six bits then the corresponding dimensions get a surrounding border pixel filled with false bits. E.g. if addBorderPixels is 6 the bits 1 and 2 are set, so dimension y and z get border pixels. Note that border pixels are created only if borders still fit in origBox. So the BitImage never becomes bigger than origBox. If no valid input volume (origBox empty or data is NULL) exists then -1 is returned. If no result volume could be created (e.g. memory allocation error) then -2 is returned.

◆ useExceptionHandling() [1/2]

bool ml::BitImage::useExceptionHandling ( ) const
inline

Return true if exception handling is on, otherwise return false.

Never throws controlled diagnostic exceptions.

Definition at line 114 of file mlBitImage.h.

◆ useExceptionHandling() [2/2]

MLTOOLS_EXPORT void ml::BitImage::useExceptionHandling ( bool  useExceptions)

Pass true to enable exception handling, false to disable it.

Never throws controlled diagnostic exceptions.

◆ writeToFile()

MLTOOLS_EXPORT bool ml::BitImage::writeToFile ( const std::string &  path,
bool  overwrite = true 
)

Writes bit image content into file specified by path path and return true on success and false on failure.

If overwrite is true (default) then existing files are overwritten, otherwise they won't be harmed and false is returned. Only for backward compatibility, use save() instead.


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