ML Reference
|
TypedCalculateOutputImageHandler can be used as a base class for a custom CalculateOutputImageHandler and supports up to four variable types. More...
#include <mlTypedHandlers.h>
Additional Inherited Members | |
Public Types inherited from ml::internal::TypedHandlerBase< CalculateOutputImageHandler, Derived, NumberOfInputImages > | |
enum | |
Public Member Functions inherited from ml::internal::TypedHandlerBase< CalculateOutputImageHandler, Derived, NumberOfInputImages > | |
TypedHandlerBase () | |
void | calculateOutputSubImage (SubImage *outImg, SubImage *inImgs, UserThreadData *userThreadData) override |
Overrides the calculateOutputSubImage of CalculateOutputImageHandler. More... | |
Public Member Functions inherited from ml::CalculateOutputImageHandler | |
virtual | ~CalculateOutputImageHandler () |
Destructor. More... | |
virtual SubImageBox | calculateInputSubImageBox (int, const SubImageBox &outputSubImageBox) |
Called by the host to determine which input image region (tile) of input inputIndex is required to calculate a certain output image region (page) of output image. More... | |
virtual UserThreadData * | createUserThreadData () |
Creates the thread local user data for a thread. More... | |
Static Public Member Functions inherited from ml::internal::TypedHandlerBase< CalculateOutputImageHandler, Derived, NumberOfInputImages > | |
static void | setupKnownProperties (PagedImage *outImg) |
Sets up the properties of the outImg and its input subimages according to the settings of OutputSubImage_Type, InputSubImage[0-9]_Type, ... More... | |
static bool | verifyProperties (PagedImage *outImg) |
Verifies the properties of outImg (its data type and the datatypes of the input subimages, comparing them with the static properties of the variable types and fixed datatypes). More... | |
TypedCalculateOutputImageHandler can be used as a base class for a custom CalculateOutputImageHandler and supports up to four variable types.
Its main feature is that it provides a mapping of the untyped SubImage instances of CalculateOutputImageHandler::calculateOutputSubImage to a call to a method called typedCalculateOutputSubImage() with typed subimages (TSubImage).
A derived class can pass up to four VariableType classes as template parameters and assign either variable types or fixed types to each output and input subimage. This configuration is provided by an anonymous enum that must be included in your derived handler class. This is necessary due to the template magic happening underneath, as all of this needs to be known at compile time.
In addition to that, the class has two static methods:
These methods can be called from Module::calculateOutputImageProperties() to set up the datatypes and read-only flags based on the static information, and to verify whether the given datatypes are valid and compatible with the VariableTypes used. This enables auto-invalidation of the output image if the current data type is not supported by the typedCalculateOutputSubImage instantiations.
Below follows a simple handler that supports one output and one input subimage of the same type:
If the above handler should support all datatypes, use AllTypes instead of StandardTypes as template argument.
Now to a more complex example that has different output and input types (only showing the configuration parts):
If the above input subimage should support all standard types, you could pass StandardTypes as second argument. Note that it is important that each template argument specifies on MLVariantType[0-3] and if each output/input subimage should support a different data type on its own (compared to having the same data type for all subimages), you need to pass the same VariableType multiple times (instead of, e.g., passing StandardTypes once, you need to pass it two times if input and output data type shall/may be different).
Another useful configuration is to have a fixed data type on the output image (e.g., because it always generates a MLint16 mask), but to support a variable data type on the input images. The example below illustrates this:
And now finally a more complex example, using all features of the typed handler:
Definition at line 942 of file mlTypedHandlers.h.