ML Reference
Image Processing

The following classes are the main classes that are involved when implementing an image processing Module in the ML. More...

Classes

class  ml::ImageProperties
 This class represents basic image properties: More...
 
class  ml::MedicalImageProperties
 This class encapsulates basic medical image properties: More...
 
class  ml::Module
 Base class for an image processing module of the ML. More...
 
class  ml::CalculateOutputImageHandler
 Base class for the calculation of pages of an output image (PagedImage) of a Module. More...
 
class  ml::PagedImage
 Class which represents an image, which manages properties of an image and image data which is located in pages. More...
 
class  ml::ProcessAllPagesHandler
 Base class for handlers that are used for the Module::processAllPages facility. More...
 
class  ml::SubImage
 This class manages/represents a rectangular 6d image region which is organized linearly in memory. More...
 
class  ml::TSubImage< DATATYPE >
 This template class manages/represents a rectangular 6d image region in memory which is organized linearly. More...
 
class  ml::ConstTSubImageCursor< DATATYPE >
 Predeclaration for const cursor. More...
 
class  ml::TSubImageCursor< DATATYPE >
 Predeclaration for cursor. More...
 
class  ml::TypedProcessAllPagesHandler< Derived, NumberOfInputImages, VariableType0, VariableType1, VariableType2, VariableType3 >
 TypedProcessAllPagesHandler can be used as a base class for an own ProcessAllPages handler and supports up to 4 type variable types. More...
 
class  ml::TypedCalculateOutputImageHandler< Derived, NumberOfInputImages, VariableType0, VariableType1, VariableType2, VariableType3 >
 TypedCalculateOutputImageHandler can be used as a base class for an own CalculateOutputImageHandler and supports up to 4 variable types. More...
 

Enumerations

enum  ml::PagedImage::ThreadSupport { ml::PagedImage::NO_THREAD_SUPPORT = 0, ml::PagedImage::MULTITHREADED = 1, ml::PagedImage::IO_THREAD = 4, ml::PagedImage::USE_MODULE_THREAD_SUPPORT = -1 }
 Defines the multi-threading support of the paged image. More...
 

Image processing and general properties of the module.

enum  ml::Module::THREAD_SUPPORT {
  ml::Module::NO_THREAD_SUPPORT = PagedImage::NO_THREAD_SUPPORT, ml::Module::MULTITHREADED = PagedImage::MULTITHREADED, ml::Module::IO_THREAD = PagedImage::IO_THREAD, ml::Module::ML_CALCULATEOUTPUTSUBIMAGE_ON_STD_TYPES = PagedImage::MULTITHREADED,
  ml::Module::ML_CALCULATEOUTPUTSUBIMAGE_ON_ALL_TYPES = PagedImage::MULTITHREADED, ml::Module::CALC_OUTSUBIMAGE_ON_STD_TYPES = PagedImage::MULTITHREADED, ml::Module::CALC_OUTSUBIMAGE_ON_ALL_TYPES = PagedImage::MULTITHREADED
}
 Enumerator deciding whether and which type of multithreading is supported by this module. More...
 
MLint ml::Module::getOutputImageInplace (MLint outputIndex=0) const
 Return optimization flag: Return index of input image whose input tile is used also as output page for output outputIndex in calculateOutputSubImage() (instead of allocating its own memory). More...
 
MLint ml::Module::getBypass (MLint outputIndex=0) const
 Returns the currently bypass index or -1 if bypassing is disabled (default). More...
 
THREAD_SUPPORT ml::Module::getThreadSupport () const
 Returns the multithreading mode supported by this module, default is NO_THREAD_SUPPORT. More...
 
bool ml::Module::areRecursiveHandleNotificationsPermitted () const
 Returns if recursive entries in handleNotification are permitted. More...
 
MLint ml::Module::getHandleNotificationEntryCounter () const
 A counter returning the current number of (recursive re)entries in handleNotification. More...
 
void ml::Module::setOutputImageInplace (MLint outputIndex=0, MLint inputIndex=0)
 Set optimization flag: If calculating a page in calculateOutputSubImage(), the output image page of output outputIndex shall use the same memory as the input page of input inputIndex. More...
 
void ml::Module::unsetOutputImageInplace (MLint outputIndex=0)
 Clear optimization flag: output page of output at outputIndex and input tile shall use different memory buffers in calculateOutputSubImage(). More...
 
void ml::Module::setBypass (MLint outputIndex=0, MLint inputIndex=0)
 Sets the input image whose pages can also be used instead of output pages for the output image at outputIndex to avoid recalculations. More...
 
void ml::Module::setThreadSupport (THREAD_SUPPORT supportMode)
 Pass any THREAD_SUPPORT supportMode to decide whether and what type of multithreading is supported by this module. More...
 
void ml::Module::permitRecursiveHandleNotifications (bool enable)
 If this flag is set to enable =true, recursive entries in handleNotification are permitted. More...
 

Data type support of this module.

enum  ml::Module::PERMITTED_TYPES {
  ml::Module::ONLY_SCALAR_TYPES, ml::Module::ONLY_DEFAULT_TYPES, ml::Module::ALL_REGISTERED_TYPES, ml::Module::ONLY_STANDARD_TYPES = ONLY_SCALAR_TYPES,
  ml::Module::FULLY_OPERATIONAL = ONLY_DEFAULT_TYPES, ml::Module::MINIMUM_OPERATIONAL = ALL_REGISTERED_TYPES
}
 See documentation of setVoxelDataTypeSupport. More...
 
PERMITTED_TYPES ml::Module::getVoxelDataTypeSupport () const
 Returns the current state of supported voxel data types. More...
 
bool ml::Module::isSupportedVoxelDataType (MLDataType dt) const
 Check if a given data type is supported on the module as configured with setVoxelDataTypeSupport. More...
 
void ml::Module::setVoxelDataTypeSupport (PERMITTED_TYPES permTypes)
 Specifies which types this module supports. More...
 

Input handling

enum  ml::Module::INPUT_STATE {
  ml::Module::DISCONNECTED = 0, ml::Module::CONNECTED_BUT_INVALID = 1, ml::Module::CONNECTED_AND_VALID = 2, ml::Module::CONNECTED_BUT_NEEDS_UPDATE = 3,
  ml::Module::OPEN = DISCONNECTED, ml::Module::UNDEFINED_CLOSED = CONNECTED_BUT_INVALID
}
 See documentation of handleInput. More...
 
enum  ml::Module::INPUT_HANDLE { ml::Module::INVALIDATE = 0, ml::Module::ALLOW_INVALID_INPUT = 2, ml::Module::REDIRECT_TO_DUMMY_OP = 1 }
 See documentation of handleInput. More...
 
virtual INPUT_HANDLE ml::Module::handleInput (int, INPUT_STATE) const
 This method may be reimplemented to enable support for invalid input images on the module. More...
 
INPUT_STATE ml::Module::getInputState (MLint index)
 Returns the current state of the input connection. More...
 
INPUT_STATE ml::Module::getUpdatedInputState (MLint index)
 Returns the updated state of the input image by calling updateImageProperties(index) and returning getInputState(index) afterwards. More...
 

Detailed Description

The following classes are the main classes that are involved when implementing an image processing Module in the ML.

Enumeration Type Documentation

See documentation of handleInput.

Enumerator
INVALIDATE 
ALLOW_INVALID_INPUT 
REDIRECT_TO_DUMMY_OP 

Definition at line 352 of file mlModule.h.

See documentation of handleInput.

Enumerator
DISCONNECTED 
CONNECTED_BUT_INVALID 
CONNECTED_AND_VALID 
CONNECTED_BUT_NEEDS_UPDATE 
OPEN 
UNDEFINED_CLOSED 

Definition at line 340 of file mlModule.h.

See documentation of setVoxelDataTypeSupport.

Enumerator
ONLY_SCALAR_TYPES 
ONLY_DEFAULT_TYPES 
ALL_REGISTERED_TYPES 
ONLY_STANDARD_TYPES 
Deprecated:
use ONLY_SCALAR_TYPES instead
FULLY_OPERATIONAL 
Deprecated:
use ONLY_DEFAULT_TYPES instead
MINIMUM_OPERATIONAL 
Deprecated:
use ALL_REGISTERED_TYPES instead

Definition at line 282 of file mlModule.h.

Enumerator deciding whether and which type of multithreading is supported by this module.

Enumerator
NO_THREAD_SUPPORT 

The module is not thread safe at all.

MULTITHREADED 

The calculation of the image data can be called from multiple threads.

IO_THREAD 

The calculation of the image data can be called from a designated IO thread.

ML_CALCULATEOUTPUTSUBIMAGE_ON_STD_TYPES 
Deprecated:
use MULTITHREADED instead
ML_CALCULATEOUTPUTSUBIMAGE_ON_ALL_TYPES 
Deprecated:
use MULTITHREADED instead
CALC_OUTSUBIMAGE_ON_STD_TYPES 
Deprecated:
use MULTITHREADED instead
CALC_OUTSUBIMAGE_ON_ALL_TYPES 
Deprecated:
use MULTITHREADED instead

Definition at line 236 of file mlModule.h.

Defines the multi-threading support of the paged image.

Enumerator
NO_THREAD_SUPPORT 

< The image can only be calculated from the main thread

MULTITHREADED 

< The calculation of the image data can be called from multiple threads

IO_THREAD 

< The calculation of the image data can be called from a designated IO thread

USE_MODULE_THREAD_SUPPORT 

< Use the overall thread support flag of the module.

Definition at line 71 of file mlPagedImage.h.

Function Documentation

bool ml::Module::areRecursiveHandleNotificationsPermitted ( ) const

Returns if recursive entries in handleNotification are permitted.

By default this setting is false.

MLint ml::Module::getBypass ( MLint  outputIndex = 0) const

Returns the currently bypass index or -1 if bypassing is disabled (default).

Bypassing requires that image (data) content, image extent, page extent and voxel data type remain unchanged or errors will occur.

MLint ml::Module::getHandleNotificationEntryCounter ( ) const

A counter returning the current number of (recursive re)entries in handleNotification.

It typically has the value 1 in handleNotification() and 0 outside. It can only return higher values if permitRecursiveHandleNotification() permits recursions in handleNotification().

INPUT_STATE ml::Module::getInputState ( MLint  index)

Returns the current state of the input connection.

NOTE: This does not update the input image, so it will return Module::CONNECTED_BUT_NEEDS_UPDATE if the input image state is unknown and could be updated via updateImageProperties(). When this method is called from within calculateOutputImageProperties(), you can be sure that Module::CONNECTED_BUT_NEEDS_UPDATE is never returned, because the ML host calls updateImageProperties() on each input image prior to calling calculateOutputImageProperties().

MLint ml::Module::getOutputImageInplace ( MLint  outputIndex = 0) const

Return optimization flag: Return index of input image whose input tile is used also as output page for output outputIndex in calculateOutputSubImage() (instead of allocating its own memory).

If inplace calculation is off, -1 is returned.

THREAD_SUPPORT ml::Module::getThreadSupport ( ) const

Returns the multithreading mode supported by this module, default is NO_THREAD_SUPPORT.

See THREAD_SUPPORT for possible return values.

INPUT_STATE ml::Module::getUpdatedInputState ( MLint  index)

Returns the updated state of the input image by calling updateImageProperties(index) and returning getInputState(index) afterwards.

It will never return Module::CONNECTED_BUT_NEEDS_UPDATE.

Warning
This method may NOT be called from the calculate*() methods, use getInputState() instead.
PERMITTED_TYPES ml::Module::getVoxelDataTypeSupport ( ) const

Returns the current state of supported voxel data types.

See also Module::PERMITTED_TYPES and setVoxelDataTypeSupport. Default is Module::ONLY_SCALAR_TYPES.

virtual INPUT_HANDLE ml::Module::handleInput ( int  ,
INPUT_STATE   
) const
inlinevirtual

This method may be reimplemented to enable support for invalid input images on the module.

If all inputs are connected and valid, this method is not called at all.

The handleInput method is called for each disconnected or invalid input image that is encountered. It allows to consider two cases separately:

The two cases are indicated by the passed state. If you do not care about the difference between a disconnected and an invalid connected image, just return the same handling and ignore the state flag. The default implementation returns Module::INVALIDATE to indicate that all input images need to be connected and valid.

The reimplemented version may return one of the following flags for each of the two cases:

It is strongly advised to not use REDIRECT_TO_DUMMY_OP in new code, please use Module::ALLOW_INVALID_INPUT instead.

If Module::ALLOW_INVALID_INPUT is returned, getInputImage() will return NULL for the invalid input image, so you need to handle this in your code, e.g., when calling getInputImage() in calculateOutputImageProperties() you need to handle a possible NULL return value. The same applies to calculateOutputSubImage(), where the input sub images for invalid inputs will be empty (isEmpty()==true) and and will contain no data (getData()==NULL).

IMPORTANT: For one input configuration handleInput must return a unique value. Input handling cannot change during life time of the Module instance. If it changes image processing may become instable.

Definition at line 387 of file mlModule.h.

bool ml::Module::isSupportedVoxelDataType ( MLDataType  dt) const

Check if a given data type is supported on the module as configured with setVoxelDataTypeSupport.

void ml::Module::permitRecursiveHandleNotifications ( bool  enable)
protected

If this flag is set to enable =true, recursive entries in handleNotification are permitted.

By default this setting is false and should only be enabled with care.

void ml::Module::setBypass ( MLint  outputIndex = 0,
MLint  inputIndex = 0 
)
protected

Sets the input image whose pages can also be used instead of output pages for the output image at outputIndex to avoid recalculations.

Setting an inputIndex of -1 disables bypassing (which is the default). Bypassing requires that image (data) content, image extent, page extent and voxel data type remain unchanged or errors will occur.

void ml::Module::setOutputImageInplace ( MLint  outputIndex = 0,
MLint  inputIndex = 0 
)
protected

Set optimization flag: If calculating a page in calculateOutputSubImage(), the output image page of output outputIndex shall use the same memory as the input page of input inputIndex.

This way less allocations occur because the read and written buffer are identical. Usually only useful for pixel operations or algorithms which do not modify the image data. Setting inIndex = -1 disables inplace optimization for the given outputIndex.

void ml::Module::setThreadSupport ( THREAD_SUPPORT  supportMode)
protected

Pass any THREAD_SUPPORT supportMode to decide whether and what type of multithreading is supported by this module.

See THREAD_SUPPORT for possible modes.

void ml::Module::setVoxelDataTypeSupport ( PERMITTED_TYPES  permTypes)
protected

Specifies which types this module supports.

If Module::ALL_REGISTERED_TYPES is set then the module might work on all registered data types.

If Module::ONLY_DEFAULT_TYPES is set then the module only supports operations on the default scalar and extended types. See the macro ML_INSTANTIATE_DEFAULT_EXTENDED_TYPES for the list of the default extended types.

Default is Module::ONLY_SCALAR_TYPES, i.e., the module can work only with the standard built-in data types. (MLuint8, MLint8,..., MLint64, MLfloat, MLdouble).

The set of allowed types can still be further restricted in calculateOutputSubImageProperties by setting the output image to invalid for not supported combinations of types and modes/parameters.

void ml::Module::unsetOutputImageInplace ( MLint  outputIndex = 0)
protected

Clear optimization flag: output page of output at outputIndex and input tile shall use different memory buffers in calculateOutputSubImage().

This is an equivalent to setOutImgInplace(outIndex, -1).