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
29
30 //----------------------------------------------------------------------
36 //----------------------------------------------------------------------
38
39 public:
40
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
281 const ImageVector &defaultExt=ImageVector(3,3,1,1,1,1));
282
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
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
405
414
424
425
426
427
428 //-------------------------------------------------------------------------------------------
431 //-------------------------------------------------------------------------------------------
432
437 virtual void _updateKernel(){ _updateKernel(true); };
438
501
505
508 virtual std::string _composeKernelInfo(bool valid=true) const;
510
511
512 //-------------------------------------------------------------------------------------------
515 //-------------------------------------------------------------------------------------------
516
523
531
537
544
545
546
547
548 //-------------------------------------------------------------------------------------------
551 //-------------------------------------------------------------------------------------------
552
556
559 void activateAttachments() override;
560
568
569protected:
581
582 private:
583
584 //-------------------------------------------------------------------------------------------
587 //-------------------------------------------------------------------------------------------
588
590 IntField *_kernelXFld;
592 IntField *_kernelYFld;
594 IntField *_kernelZFld;
596 IntField *_kernelCFld;
598 IntField *_kernelTFld;
600 IntField *_kernelUFld;
601
606 BoolField *_makeSphericalFld;
608
609
610
611 //-------------------------------------------------------------------------------------------
614 //-------------------------------------------------------------------------------------------
620 BoolField *_normalizeFld;
622
623
624
625 //-------------------------------------------------------------------------------------------
628 //-------------------------------------------------------------------------------------------
634 StringField *_externalKernelFld;
635
641 BoolField *_useExternalKernelFld;
642
649 StringField *_kernelOutputFld;
651
652
653
654 //-------------------------------------------------------------------------------------------
657 //-------------------------------------------------------------------------------------------
664 DoubleField *_imageIntervalMinFld;
665
672 DoubleField *_imageIntervalMaxFld;
673
680 BoolField *_useImageIntervalFld;
682
683
684
685 //-------------------------------------------------------------------------------------------
688 //-------------------------------------------------------------------------------------------
695 DoubleField *_kernelIntervalMinFld;
696
703 DoubleField *_kernelIntervalMaxFld;
704
711 BoolField *_useKernelIntervalFld;
713
714
715 //-------------------------------------------------------------------------------------------
718 //-------------------------------------------------------------------------------------------
723 StringField *_kernelInfoFld;
724
733 IntField *_numKernelElementsFld;
734
743 DoubleField *_kernelElementsSumFld;
745
746
747 //-------------------------------------------------------------------------------------------
750 //-------------------------------------------------------------------------------------------
763 BoolField *_autoCalcMinMaxFld;
764
772 NotifyField *_setAutoMinMaxFld;
774
775
776
777 //-------------------------------------------------------------------------------------------
780 //-------------------------------------------------------------------------------------------
784 DoubleField *_outputMinFld;
785
789 DoubleField *_outputMaxFld;
790
795 BoolField *_useMinMaxFld;
797
798
799
800 //-------------------------------------------------------------------------------------------
803 //-------------------------------------------------------------------------------------------
804
807 MLdouble _autoMin;
808
811 MLdouble _autoMax;
812
816 bool _autoMinMaxValid;
818
819
822 bool _normImageInterval;
823
825 bool _normKernelInterval;
826
829 MLdouble _imageIntervalMin;
830
833 MLdouble _imageIntervalMax;
834
837 MLdouble _kernelIntervalMin;
838
841 MLdouble _kernelIntervalMax;
843
844
845
851 };
852
854
855#endif //of __mlKernelModule_H
Field to encapsulate a boolean value.
Definition mlFields.h:58
Field to encapsulate a double value.
Definition mlFields.h:538
Base class for all fields used in the ML.
Definition mlField.h:73
Field to encapsulate an integer value.
Definition mlFields.h:126
The module base class to apply kernels to an image.
The typically used convenience class to apply a kernel to an image.
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...
DoubleField * getOutputMinFld() const
StringField * getKernelOutputFld() const
A field containing the current kernel.
virtual void _updateKernel()
Convenience routine to call the typically used _updateKernel() functionality, e.g.
BoolField * getUseKernelIntervalFld() const
A field enabling the usage of the _kernelIntervalMinFld and _kernelIntervalMaxFld if true.
void handleNotification(Field *field) override
Called when any parameter field is changed.
DoubleField * getImageIntervalMinFld() const
DoubleField * getImageIntervalMaxFld() const
A field containing the maximum limit of an interval specifying the values of voxels to be filtered.
virtual void _createKernelElementsSumField()
Creates an information field which will contain the sum of all kernel elements.
BoolField * getNormalizeFld() const
IntField * getKernelUFld() const
U extent of kernel. The field name will be "kernelU". Field default is 1 if created.
virtual void _userKernelPostUpdate()
Typical method to be overloaded by derived modules to apply kernel changes.
virtual void _createKernelInfoField()
Creates an information field about the current kernel and its creation process.
virtual void _createKernelOutputField()
Creates a kernel output field.
BoolField * getUseExternalKernelFld() const
A field enabling the usage of the _externalKernelFld if true.
IntField * getKernelZFld() const
Z extent of kernel. The field name will be "kernelZ". Field default is 1 if created.
NotifyField * getSetAutoMinMaxFld() const
Field which assigns the current settings of automatically determined minimum/maximum values of alread...
void _setKernelInterval(MLdouble minVal=-DBL_MAX, MLdouble maxVal=DBL_MAX)
Update private test members for fast kernel testings.
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.
BoolField * getUseImageIntervalFld() const
A field enabling the usage of the _imageIntervalMinFld and _imageIntervalMaxFld if true.
virtual void _createNormalizeField(bool defaultVal=false)
Creates a bool field which enables/disables the automatic normalization of the kernel after each chan...
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.
BoolField * getAutoCalcMinMaxFld() const
StringField * getKernelInfoFld() const
DoubleField * getOutputMaxFld() const
The maximum value used for the output image if _useAutoMinMax is on.
virtual void _createMakeSphericalField(bool defaultVal=false)
Creates a bool field which enables/disables the usage of a connected kernel.
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.
IntField * getKernelYFld() const
Y extent of kernel. The field name will be "kernelY". Field default is 3 if created.
void activateAttachments() override
Called when field loading or module cloning has finished.
IntField * getKernelCFld() const
C extent of kernel. The field name will be "kernelC". Field default is 1 if created.
virtual void _createKernelExtentFields(int numDim=6, const ImageVector &defaultExt=ImageVector(3, 3, 1, 1, 1, 1))
Creates the fields _kernelXFld, ... _kernelUFld and initializes them with the values 3,...
DoubleField * getKernelElementsSumFld() const
If created this methods returns the pointer to the field containing the sum of all kernel elements,...
DoubleField * getKernelIntervalMinFld() const
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...
StringField * getExternalKernelFld() const
virtual void _updateKernel(bool permitExtentChanges)
This is the method to update the kernel, it should be called if the kernel requires an update,...
DoubleField * getKernelIntervalMaxFld() const
A field containing the maximum limit of an interval specifying the values of voxels under kernel elem...
IntField * getKernelXFld() const
X extent of kernel. The field name will be "kernelX". 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 _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 * getKernelTFld() const
T extent of kernel. The field name will be "kernelT". Field default is 1 if created.
IntField * getNumKernelElementsFld() const
If created this field contains the number of voxels in the kernel.
BoolField * getMakeSphericalFld() const
Controls whether kernel is circular or rectangular (in 6D).
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...
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...
bool _isInKernelInterval(MLdouble v) const
Test whether the value v is within kernel interval.
Field without value for notifications.
Definition mlFields.h:659
Class which represents an image, which manages properties of an image and image data which is located...
Field to encapsulate a string value.
Definition mlFields.h:610
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...
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
double MLdouble
Definition mlTypeDefs.h:217
TImageVector< MLint > ImageVector
Defines the standard ImageVector type which is used by the ML for indexing and coordinates.