MeVisLab Toolbox Reference
mlKernelBaseModule.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 
15 
16 #if !defined (__mlKernelBaseModule_H)
17 #define __mlKernelBaseModule_H
18 
19 // ML-includes
20 #include "mlInitSystemKernel.h"
21 #include "mlKernel.h"
22 #include "mlKernelTools.h"
23 #include "mlKernelMacros.h"
24 
25 ML_START_NAMESPACE
26 
27  //---------------------------------------------------------
226  //---------------------------------------------------------
228 
229  friend class KernelBaseOpCalculateOutputImageHandler;
230 
231  protected:
238  KernelBaseModule(int inputNum=1, int outputNum=1);
239 
240  public:
241 
244  inline Kernel &getKernel() { return _kernel; }
245 
247  inline const Kernel &getConstKernel() const { return _kernel; }
249 
250 
256  inline EnumField *getBorderHandlingFld() const { return _borderHandlingFld; }
257 
261  inline DoubleField *getFillValueFld() const { return _fillValueFld; }
262 
263  // The field value describes the number of filtering iterations to be applied
264  // each page of the output image; the default is 1. Values < 1 are handled as 1.
265  // Still untested.
266  //inline IntField *getNumIterationsFld() const { return _numIterationsFld; }
267 
272  Overlap = 0,
273 
277 
281 
285 
289 
292  NumImageRefExtents
293  };
294 
298  inline EnumField &getReferenceExtentModeFld() const { return *_referenceExtentFld; }
300 
301  protected:
302 
319  virtual void _setCorrectCorrelationMinMax(bool imageIntervalUsed=false,
320  MLdouble intervalMin=0,
321  MLdouble intervalMax=0,
322  MLint inIdx=0,
323  MLint outIdx=0);
324 
328 
339  void calculateOutputImageProperties(int outputIndex, PagedImage* outputImage) override;
340 
345  SubImageBox calculateInputSubImageBox(int inIndex, const SubImageBox& outSubImgBox, int outIndex) override;
346 
353  virtual void calcInSubImagePreparation(int outIndex, SubImage *inSubImgs);
354 
360  virtual void calcOutSubImagePostProcessing(SubImage *outSubImg, int outIndex, SubImage *inSubImgs);
361 
365  virtual SubImageBox calculateAreaToBeCalculated(const SubImageBox& areaToBeCalculated, const SubImageBox& outSubImageBox);
369  virtual ImageVector calculateOutInCoordShift(const ImageVector shift, const SubImageBox& outSubImageBox);
373  virtual SubImageBox calculateValidDestArea(const SubImageBox& validDestArea, const SubImageBox& outSubImageBox);
374 
377  virtual void _connectToAllOutputs(Field *field);
379 
380 
381  protected:
384  virtual void _calcKernelPage(SubImage *outSubImg,
385  int outIndex,
386  SubImage *inSubImgs,
387  int numInSubImgs,
388  MLsoffset *indexTab,
389  size_t indexTabSize,
390  MLsoffset srcVoxelOffset,
391  size_t loopIdx,
392  size_t iteration,
393  const ImageVector &ov1,
394  const ImageVector &ov2,
395  const ImageVector &pOf,
396  size_t numVox)=0;
397 
398  private:
404  virtual void calculateOutputSubImage(SubImage *realOutSubImg, int outIndex, SubImage *inSubImgs, UserThreadData* userThreadData);
405 
407 
410 
414  virtual UserThreadData* createUserThreadData(PagedImage* outImg);
415 
429  static SubImageBox expandBox(const SubImageBox& inBox, const ImageVector &negFilterExt,
430  const ImageVector &posFilterExt,
431  bool isSeparable,
432  MLint numIterations);
433 
434  private:
435 
438 
442  EnumField *_borderHandlingFld;
443 
447  DoubleField *_fillValueFld;
448 
449  // Specifies the number of iterations of the algorithm
450  // onto the page; default is 1.
451  // Still not tested.
452  //IntField *_numIterationsFld;
453 
457  EnumField *_referenceExtentFld;
459 
461  Kernel _kernel;
462 
465  ImageVector _calculatedReferenceInputExt;
466 
471  ImageVector _calcReferenceInputExt() const;
472 
478  };
479 
480 ML_END_NAMESPACE
481 
482 #endif //of __mlKernelBaseModule_H
Base class for the calculation of pages of an output image (PagedImage) of a Module.
Field to encapsulate a double value.
Definition: mlFields.h:494
Field to encapsulate an enumerated value.
Definition: mlFields.h:173
Base class for all fields used in the ML.
Definition: mlField.h:73
The module base class to apply kernels to an image.
virtual SubImageBox calculateValidDestArea(const SubImageBox &validDestArea, const SubImageBox &outSubImageBox)
Function called after the Kernel Framework calculated the valid area in the global destination image.
virtual void _connectToAllOutputs(Field *field)
Helper function to connect a field field to all output fields.
SubImageBox calculateInputSubImageBox(int inIndex, const SubImageBox &outSubImgBox, int outIndex) override
Calculates the region of the input image needed for the calculation of the output image region define...
DoubleField * getFillValueFld() const
The field value is value written in input or output image borders where a border handling requires fi...
virtual void _calcKernelPage(SubImage *outSubImg, int outIndex, SubImage *inSubImgs, int numInSubImgs, MLsoffset *indexTab, size_t indexTabSize, MLsoffset srcVoxelOffset, size_t loopIdx, size_t iteration, const ImageVector &ov1, const ImageVector &ov2, const ImageVector &pOf, size_t numVox)=0
This method is not intended to be overloaded directly, because it is subject to change.
EnumField & getReferenceExtentModeFld() const
Returns how the reference extent for input images is calculated; valid values are InputImageRefExtent...
virtual void calcOutSubImagePostProcessing(SubImage *outSubImg, int outIndex, SubImage *inSubImgs)
Called to postProcess the output image outSubImg with the index outIndex from the input subimage inSu...
virtual ImageVector _getCalculatedReferenceInputExt() const
Return the reference extent of input image dependent on the current value of _referenceExtentFld.
virtual void _setCorrectCorrelationMinMax(bool imageIntervalUsed=false, MLdouble intervalMin=0, MLdouble intervalMax=0, MLint inIdx=0, MLint outIdx=0)
This method calculates and sets the possible min/max values for output image outIdx if a correlation ...
const Kernel & getConstKernel() const
Method to access the kernel as constant object. See also getKernel().
InputImageRefExtent
Enumerator specifying the calculation mode for the extent of the reference extent of the input image.
@ Input0_ExtWithFill
Input 0 defines the reference extent of the input image, filling undefined input areas with fill valu...
@ MaxExtentsWithFill
Maximum component wise extent of all inputs, filling undefined input areas with fill value.
@ Input0_ExtWithoutFill
Input 0 defines the reference extent of the input image, leaving undefined input areas undefined.
@ MaxExtentsWithoutFill
Maximum component wise extent of all inputs, leaving undefined input areas undefined.
virtual void calcInSubImagePreparation(int outIndex, SubImage *inSubImgs)
Does some preprocessing on input subimages if we have more than one.
EnumField * getBorderHandlingFld() const
virtual ImageVector calculateOutInCoordShift(const ImageVector shift, const SubImageBox &outSubImageBox)
Function called after the Kernel Framework calculated the shift vector between input and output.
void calculateOutputImageProperties(int outputIndex, PagedImage *outputImage) override
KernelBaseModule(int inputNum=1, int outputNum=1)
Constructor.
virtual SubImageBox calculateAreaToBeCalculated(const SubImageBox &areaToBeCalculated, const SubImageBox &outSubImageBox)
Function called after the Kernel Framework calculated which box needs to be calculated for the curren...
Base class for an image processing module of the ML.
Definition: mlModule.h:151
virtual CalculateOutputImageHandler * createCalculateOutputImageHandler(PagedImage *outputImage)
Creates the CalculateOutputImageHandler for the given output image outputImage.
virtual void calculateOutputSubImage(SubImage *outputSubImage, int outputIndex, SubImage *inputSubImages)
Calculates page outputSubImage of output image with index outputIndex given the input image tiles in ...
The class PagedImage, representing a fragmented image that manages properties and data of an image lo...
Definition: mlPagedImage.h:66
This class manages/represents a rectangular 6D image region that is organized linearly in memory.
Definition: mlSubImage.h:75
Base class for thread local data that is passed to CalculateOutputImageHandler::calculateOutputSubIma...
#define ML_ABSTRACT_MODULE_CLASS_HEADER(className)
Similar to ML_ABSTRACT_CLASS_HEADER for the usage of derived classes from Module.
#define MLKERNELEXPORT
Includes files used in many parts of the dll, defined dll-specific macros and controls any system dep...
MLint MLsoffset
Signed ML offset type that is a 32-bit signed integer on 32-bit platforms and a 64-bit integer on 64-...
Definition: mlTypeDefs.h:562
double MLdouble
Definition: mlTypeDefs.h:217
MLint64 MLint
A signed ML integer type with at least 64 bits used for index calculations on very large images even ...
Definition: mlTypeDefs.h:490