MeVisLab Toolbox Reference
mlKernelModule.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 // For related code and more information see \c mlKernelExample.h,
17 // \c mlKernel.h, \c mlKernelBaseModule.h, \c mlKernelModule.h,
18 // \c mlKernelEditor.h, \c mlRankFilter.h, \c mlExtConvolutionFilter.h,
19 // \c mlKernelMacros, \c mlKernelTools.h and \c mlConvolutionFilter.h.
20 
21 #if !defined(__mlKernelModule_H)
22 #define __mlKernelModule_H
23 
24 // ML-includes
25 #include "mlInitSystemKernel.h"
26 #include "mlKernelBaseModule.h"
27 
28 ML_START_NAMESPACE
29 
30  //----------------------------------------------------------------------
36  //----------------------------------------------------------------------
38 
39  public:
40 
45  KernelModule(int inputNum=1, int outputNum=1);
46 
47 
50 
52  inline IntField *getKernelXFld() const { return _kernelXFld; }
54  inline IntField *getKernelYFld() const { return _kernelYFld; }
56  inline IntField *getKernelZFld() const { return _kernelZFld; }
58  inline IntField *getKernelCFld() const { return _kernelCFld; }
60  inline IntField *getKernelTFld() const { return _kernelTFld; }
62  inline IntField *getKernelUFld() const { return _kernelUFld; }
63 
68  inline BoolField *getMakeSphericalFld() const { return _makeSphericalFld; }
70 
71 
72 
79  inline BoolField *getNormalizeFld() const { return _normalizeFld; }
81 
82 
83 
91  inline StringField *getExternalKernelFld() const { return _externalKernelFld; }
92 
97  inline BoolField *getUseExternalKernelFld() const { return _useExternalKernelFld; }
98 
104  inline StringField *getKernelOutputFld() const { return _kernelOutputFld; }
106 
107 
113  inline StringField *getKernelInfoFld() const { return _kernelInfoFld; }
114 
123  inline DoubleField *getKernelElementsSumFld() const { return _kernelElementsSumFld; }
124 
130  inline IntField *getNumKernelElementsFld() const { return _numKernelElementsFld; }
132 
133 
134 
142  inline DoubleField *getImageIntervalMinFld() const { return _imageIntervalMinFld; }
143 
149  inline DoubleField *getImageIntervalMaxFld() const { return _imageIntervalMaxFld; }
150 
156  inline BoolField *getUseImageIntervalFld() const { return _useImageIntervalFld; }
158 
159 
160 
168  inline DoubleField *getKernelIntervalMinFld() const { return _kernelIntervalMinFld; }
169 
175  inline DoubleField *getKernelIntervalMaxFld() const { return _kernelIntervalMaxFld; }
176 
182  inline BoolField *getUseKernelIntervalFld() const { return _useKernelIntervalFld; }
184 
185 
186 
200  inline BoolField *getAutoCalcMinMaxFld() const { return _autoCalcMinMaxFld; }
201 
208  inline NotifyField *getSetAutoMinMaxFld() const { return _setAutoMinMaxFld; }
210 
211 
212 
218  inline DoubleField *getOutputMinFld() const { return _outputMinFld; }
219 
223  inline DoubleField *getOutputMaxFld() const { return _outputMaxFld; }
224 
229  inline BoolField *getUseMinMaxFld() const { return _useMinMaxFld; }
231 
232  protected:
233 
234  //-------------------------------------------------------------------------------------------
235  // Stuff often overloaded in derived classes.
236  //-------------------------------------------------------------------------------------------
237 
238  //-------------------------------------------------------------------------------------------
241  //-------------------------------------------------------------------------------------------
248  virtual void _userKernelPreUpdate() { };
249 
258  virtual void _userKernelPostUpdate() { };
260 
261 
262 
263  //-------------------------------------------------------------------------------------------
264  // Stuff often called - but usually not overloaded - by derived classes.
265  //-------------------------------------------------------------------------------------------
266  //-------------------------------------------------------------------------------------------
269  //-------------------------------------------------------------------------------------------
270 
280  virtual void _createKernelExtentFields(int numDim=6,
281  const ImageVector &defaultExt=ImageVector(3,3,1,1,1,1));
282 
285  virtual void _validateKernelExtents();
286 
296  virtual void _createMakeSphericalField(bool defaultVal=false);
297 
307  virtual void _createNormalizeField(bool defaultVal=false);
308 
327  virtual void _createMinMaxCalcFields(bool defaultValue=false, bool createSetOutputMinMax=false);
328 
342  virtual void _createMinMaxFields(MLdouble minVal=0, MLdouble maxVal=0, bool defaultValue=false);
343 
355  virtual void _createExternalKernelFields(bool createUseToggle=false, bool defaultVal=false);
356 
363  virtual void _createKernelOutputField();
364 
378  virtual void _createImageIntervalFields(MLdouble min=0, MLdouble max=1024,
379  bool createToggle=false, bool useIt=false);
380 
395  virtual void _createKernelIntervalFields(MLdouble min=0, MLdouble max=1024,
396  bool createToggle=false, bool useIt=false);
397 
398 
399 
404  virtual void _createKernelInfoField();
405 
414 
424 
425 
426 
427 
428  //-------------------------------------------------------------------------------------------
431  //-------------------------------------------------------------------------------------------
432 
437  virtual void _updateKernel(){ _updateKernel(true); };
438 
500  virtual void _updateKernel(bool permitExtentChanges);
501 
504  virtual void _updateKernelOutputField();
505 
508  virtual std::string _composeKernelInfo(bool valid=true) const;
510 
511 
512  //-------------------------------------------------------------------------------------------
515  //-------------------------------------------------------------------------------------------
516 
522  void _setImageInterval(MLdouble minVal=-DBL_MAX, MLdouble maxVal=DBL_MAX);
523 
530  void _setKernelInterval(MLdouble minVal=-DBL_MAX, MLdouble maxVal=DBL_MAX);
531 
537 
544 
545 
546 
547 
548  //-------------------------------------------------------------------------------------------
551  //-------------------------------------------------------------------------------------------
552 
555  void handleNotification(Field* field) override;
556 
559  void activateAttachments() override;
560 
567  void calculateOutputImageProperties(int outputIndex, PagedImage* outputImage) override;
568 
569 #if ML_DEPRECATED_SINCE(3,6,0)
570  void calculateOutputImageProperties(int outputIndex) override;
571 #else
572 private: void calculateOutputImageProperties(int outputIndex) override;
573 protected:
574 #endif
575 
585  void calcOutSubImagePostProcessing(SubImage *outSubImg, int outIndex, SubImage *inSubImgs) override;
587 
588  private:
589 
590  //-------------------------------------------------------------------------------------------
593  //-------------------------------------------------------------------------------------------
594 
596  IntField *_kernelXFld;
598  IntField *_kernelYFld;
600  IntField *_kernelZFld;
602  IntField *_kernelCFld;
604  IntField *_kernelTFld;
606  IntField *_kernelUFld;
607 
612  BoolField *_makeSphericalFld;
614 
615 
616 
617  //-------------------------------------------------------------------------------------------
620  //-------------------------------------------------------------------------------------------
626  BoolField *_normalizeFld;
628 
629 
630 
631  //-------------------------------------------------------------------------------------------
634  //-------------------------------------------------------------------------------------------
640  StringField *_externalKernelFld;
641 
647  BoolField *_useExternalKernelFld;
648 
655  StringField *_kernelOutputFld;
657 
658 
659 
660  //-------------------------------------------------------------------------------------------
663  //-------------------------------------------------------------------------------------------
670  DoubleField *_imageIntervalMinFld;
671 
678  DoubleField *_imageIntervalMaxFld;
679 
686  BoolField *_useImageIntervalFld;
688 
689 
690 
691  //-------------------------------------------------------------------------------------------
694  //-------------------------------------------------------------------------------------------
701  DoubleField *_kernelIntervalMinFld;
702 
709  DoubleField *_kernelIntervalMaxFld;
710 
717  BoolField *_useKernelIntervalFld;
719 
720 
721  //-------------------------------------------------------------------------------------------
724  //-------------------------------------------------------------------------------------------
729  StringField *_kernelInfoFld;
730 
739  IntField *_numKernelElementsFld;
740 
749  DoubleField *_kernelElementsSumFld;
751 
752 
753  //-------------------------------------------------------------------------------------------
756  //-------------------------------------------------------------------------------------------
769  BoolField *_autoCalcMinMaxFld;
770 
778  NotifyField *_setAutoMinMaxFld;
780 
781 
782 
783  //-------------------------------------------------------------------------------------------
786  //-------------------------------------------------------------------------------------------
790  DoubleField *_outputMinFld;
791 
795  DoubleField *_outputMaxFld;
796 
801  BoolField *_useMinMaxFld;
803 
804 
805 
806  //-------------------------------------------------------------------------------------------
809  //-------------------------------------------------------------------------------------------
810 
813  MLdouble _autoMin;
814 
817  MLdouble _autoMax;
818 
822  bool _autoMinMaxValid;
824 
825 
828  bool _normImageInterval;
829 
831  bool _normKernelInterval;
832 
835  MLdouble _imageIntervalMin;
836 
839  MLdouble _imageIntervalMax;
840 
843  MLdouble _kernelIntervalMin;
844 
847  MLdouble _kernelIntervalMax;
849 
850 
851 
857  };
858 
859 #if ML_DEPRECATED_SINCE(3,5,0)
860 
863  class MLKERNELEXPORT ML_DEPRECATED KernelOp : public KernelModule
864  {
865  public:
866  KernelOp(int inputNum=1, int outputNum=1):KernelModule(inputNum,outputNum)
867  {};
868 
870  };
871 
872 #endif
873 
874 
875 
876 ML_END_NAMESPACE
877 
878 #endif //of __mlKernelModule_H
#define ML_DEPRECATED
Definition: CSOGroup.h:371
Field to encapsulate a boolean value.
Definition: mlFields.h:62
Field to encapsulate a double value.
Definition: mlFields.h:806
Base class for all fields used in the ML.
Definition: mlField.h:73
Field to encapsulate an integer value.
Definition: mlFields.h:161
The module base class to apply kernels to an image.
void calculateOutputImageProperties(int outputIndex, PagedImage *outputImage) override
Set properties of output image outputImage with output index outputIndex.
The typically used convenience class to apply a kernel to an image.
BoolField * getUseImageIntervalFld() const
A field enabling the usage of the _imageIntervalMinFld and _imageIntervalMaxFld if true.
DoubleField * getKernelIntervalMinFld() const
virtual void _createExternalKernelFields(bool createUseToggle=false, bool defaultVal=false)
Creates a kernel input field and an information field.
void calcOutSubImagePostProcessing(SubImage *outSubImg, int outIndex, SubImage *inSubImgs) override
Called to postProcess the output image outSubImg with the index outIndex from the input subimage inIm...
virtual void _updateKernel()
Convenience routine to call the typically used _updateKernel() functionality, e.g.
void handleNotification(Field *field) override
Called when any parameter field is changed.
BoolField * getUseKernelIntervalFld() const
A field enabling the usage of the _kernelIntervalMinFld and _kernelIntervalMaxFld if true.
StringField * getKernelOutputFld() const
A field containing the current kernel.
DoubleField * getImageIntervalMinFld() const
virtual void _createKernelElementsSumField()
Creates an information field which will contain the sum of all kernel elements.
virtual void _userKernelPostUpdate()
Typical method to be overloaded by derived modules to apply kernel changes.
IntField * getNumKernelElementsFld() const
If created this field contains the number of voxels in the kernel.
virtual void _createKernelInfoField()
Creates an information field about the current kernel and its creation process.
virtual void _createKernelOutputField()
Creates a kernel output field.
BoolField * getAutoCalcMinMaxFld() const
BoolField * getMakeSphericalFld() const
Controls whether kernel is circular or rectangular (in 6D).
IntField * getKernelUFld() const
U extent of kernel. The field name will be "kernelU". Field default is 1 if created.
IntField * getKernelZFld() const
Z extent of kernel. The field name will be "kernelZ". Field default is 1 if created.
void _setKernelInterval(MLdouble minVal=-DBL_MAX, MLdouble maxVal=DBL_MAX)
Update private test members for fast kernel testings.
NotifyField * getSetAutoMinMaxFld() const
Field which assigns the current settings of automatically determined minimum/maximum values of alread...
bool _isInImageInterval(MLdouble v) const
Test whether the value v is within image interval.
virtual void _createMinMaxFields(MLdouble minVal=0, MLdouble maxVal=0, bool defaultValue=false)
Creates a minimum and a maximum field containing minimum/maximum values for the output image.
virtual void _createNormalizeField(bool defaultVal=false)
Creates a bool field which enables/disables the automatic normalization of the kernel after each chan...
BoolField * getUseExternalKernelFld() const
A field enabling the usage of the _externalKernelFld if true.
KernelModule(int inputNum=1, int outputNum=1)
Constructor.
void _setImageInterval(MLdouble minVal=-DBL_MAX, MLdouble maxVal=DBL_MAX)
Update private test members for fast image interval testings.
void calculateOutputImageProperties(int outputIndex, PagedImage *outputImage) override
Computes the output image properties for output outIndex.
StringField * getExternalKernelFld() const
DoubleField * getOutputMinFld() const
IntField * getKernelCFld() const
C extent of kernel. The field name will be "kernelC". Field default is 1 if created.
virtual void _createMakeSphericalField(bool defaultVal=false)
Creates a bool field which enables/disables the usage of a connected kernel.
IntField * getKernelYFld() const
Y extent of kernel. The field name will be "kernelY". Field default is 3 if created.
BoolField * getUseMinMaxFld() const
If enabled then contents of _outputMinFld and _outputMaxFld will be used as minimum and maximum value...
virtual void _createNumKernelElementsField()
Creates an information field which will contain the number of kernel elements.
virtual void _validateKernelExtents()
Checks all existing kernel extent fields and corrects all to values >= 0 if necessary.
void activateAttachments() override
Called when field loading or module cloning has finished.
virtual void _createKernelExtentFields(int numDim=6, const ImageVector &defaultExt=ImageVector(3, 3, 1, 1, 1, 1))
Creates the fields _kernelXFld, ...
virtual void _createImageIntervalFields(MLdouble min=0, MLdouble max=1024, bool createToggle=false, bool useIt=false)
Creates two limit fields to specify an interval and - if createToggle is passed as true - a toggle to...
virtual void _updateKernel(bool permitExtentChanges)
This is the method to update the kernel, it should be called if the kernel requires an update,...
virtual void _updateKernelOutputField()
Updates the kernel output to the value of the kernel if the _kernelOutputFld is defined.
virtual void _userKernelPreUpdate()
Typical method to be overloaded by derived modules to apply kernel changes.
virtual std::string _composeKernelInfo(bool valid=true) const
Create a string containing all important kernel information.
IntField * getKernelXFld() const
X extent of kernel. The field name will be "kernelX". Field default is 3 if created.
IntField * getKernelTFld() const
T extent of kernel. The field name will be "kernelT". Field default is 1 if created.
DoubleField * getKernelElementsSumFld() const
If created this methods returns the pointer to the field containing the sum of all kernel elements,...
DoubleField * getOutputMaxFld() const
The maximum value used for the output image if _useAutoMinMax is on.
virtual void _createKernelIntervalFields(MLdouble min=0, MLdouble max=1024, bool createToggle=false, bool useIt=false)
Creates two limit fields to specify an interval and - if createToggle is passed as true - a toggle to...
DoubleField * getKernelIntervalMaxFld() const
A field containing the maximum limit of an interval specifying the values of voxels under kernel elem...
virtual void _createMinMaxCalcFields(bool defaultValue=false, bool createSetOutputMinMax=false)
Creates a toggle field which enables the scan of calculated output pages for min/max values if enable...
DoubleField * getImageIntervalMaxFld() const
A field containing the maximum limit of an interval specifying the values of voxels to be filtered.
bool _isInKernelInterval(MLdouble v) const
Test whether the value v is within kernel interval.
BoolField * getNormalizeFld() const
StringField * getKernelInfoFld() const
Field without value for notifications.
Definition: mlFields.h:1049
Class which represents an image, which manages properties of an image and image data which is located...
Definition: mlPagedImage.h:70
Field to encapsulate a string value.
Definition: mlFields.h:1000
This class manages/represents a rectangular 6d image region which is organized linearly in memory.
Definition: mlSubImage.h:75
#define ML_ABSTRACT_MODULE_CLASS_HEADER(className)
Like 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...
double MLdouble
Definition: mlTypeDefs.h:223
TImageVector< MLint > ImageVector
Defines the standard ImageVector type which is used by the ML for indexing and coordinates.