MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
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
40public:
45 KernelModule(int inputNum = 1, int outputNum = 1);
46
47
51
53 inline IntField* getKernelXFld() const
54 {
55 return _kernelXFld;
56 }
58 inline IntField* getKernelYFld() const
59 {
60 return _kernelYFld;
61 }
63 inline IntField* getKernelZFld() const
64 {
65 return _kernelZFld;
66 }
68 inline IntField* getKernelCFld() const
69 {
70 return _kernelCFld;
71 }
73 inline IntField* getKernelTFld() const
74 {
75 return _kernelTFld;
76 }
78 inline IntField* getKernelUFld() const
79 {
80 return _kernelUFld;
81 }
82
88 {
89 return _makeSphericalFld;
90 }
92
93
101 {
102 return _normalizeFld;
103 }
105
106
115 {
116 return _externalKernelFld;
117 }
118
124 {
125 return _useExternalKernelFld;
126 }
127
134 {
135 return _kernelOutputFld;
136 }
138
139
146 {
147 return _kernelInfoFld;
148 }
149
159 {
160 return _kernelElementsSumFld;
161 }
162
169 {
170 return _numKernelElementsFld;
171 }
173
174
183 {
184 return _imageIntervalMinFld;
185 }
186
193 {
194 return _imageIntervalMaxFld;
195 }
196
203 {
204 return _useImageIntervalFld;
205 }
207
208
217 {
218 return _kernelIntervalMinFld;
219 }
220
227 {
228 return _kernelIntervalMaxFld;
229 }
230
237 {
238 return _useKernelIntervalFld;
239 }
241
242
257 {
258 return _autoCalcMinMaxFld;
259 }
260
268 {
269 return _setAutoMinMaxFld;
270 }
272
273
280 {
281 return _outputMinFld;
282 }
283
288 {
289 return _outputMaxFld;
290 }
291
297 {
298 return _useMinMaxFld;
299 }
301
302protected:
303 //-------------------------------------------------------------------------------------------
304 // Stuff often overloaded in derived classes.
305 //-------------------------------------------------------------------------------------------
306
307 //-------------------------------------------------------------------------------------------
310 //-------------------------------------------------------------------------------------------
317 virtual void _userKernelPreUpdate() {};
318
327 virtual void _userKernelPostUpdate() {};
329
330
331 //-------------------------------------------------------------------------------------------
332 // Stuff often called - but usually not overloaded - by derived classes.
333 //-------------------------------------------------------------------------------------------
334 //-------------------------------------------------------------------------------------------
337 //-------------------------------------------------------------------------------------------
338
348 virtual void _createKernelExtentFields(int numDim = 6, const ImageVector& defaultExt = ImageVector(3, 3, 1, 1, 1, 1));
349
353
363 virtual void _createMakeSphericalField(bool defaultVal = false);
364
374 virtual void _createNormalizeField(bool defaultVal = false);
375
394 virtual void _createMinMaxCalcFields(bool defaultValue = false, bool createSetOutputMinMax = false);
395
409 virtual void _createMinMaxFields(MLdouble minVal = 0, MLdouble maxVal = 0, bool defaultValue = false);
410
422 virtual void _createExternalKernelFields(bool createUseToggle = false, bool defaultVal = false);
423
431
445 virtual void _createImageIntervalFields(MLdouble min = 0, MLdouble max = 1024, bool createToggle = false,
446 bool useIt = false);
447
462 virtual void _createKernelIntervalFields(MLdouble min = 0, MLdouble max = 1024, bool createToggle = false,
463 bool useIt = false);
464
465
471
480
490
491
492 //-------------------------------------------------------------------------------------------
495 //-------------------------------------------------------------------------------------------
496
501 virtual void _updateKernel()
502 {
503 _updateKernel(true);
504 };
505
568
572
575 virtual std::string _composeKernelInfo(bool valid = true) const;
577
578
579 //-------------------------------------------------------------------------------------------
582 //-------------------------------------------------------------------------------------------
583
590
598
604
611
612
613 //-------------------------------------------------------------------------------------------
616 //-------------------------------------------------------------------------------------------
617
621
624 void activateAttachments() override;
625
633
634protected:
646
647private:
648 //-------------------------------------------------------------------------------------------
651 //-------------------------------------------------------------------------------------------
652
654 IntField* _kernelXFld;
656 IntField* _kernelYFld;
658 IntField* _kernelZFld;
660 IntField* _kernelCFld;
662 IntField* _kernelTFld;
664 IntField* _kernelUFld;
665
670 BoolField* _makeSphericalFld;
672
673
674 //-------------------------------------------------------------------------------------------
677 //-------------------------------------------------------------------------------------------
683 BoolField* _normalizeFld;
685
686
687 //-------------------------------------------------------------------------------------------
690 //-------------------------------------------------------------------------------------------
696 StringField* _externalKernelFld;
697
703 BoolField* _useExternalKernelFld;
704
711 StringField* _kernelOutputFld;
713
714
715 //-------------------------------------------------------------------------------------------
718 //-------------------------------------------------------------------------------------------
725 DoubleField* _imageIntervalMinFld;
726
733 DoubleField* _imageIntervalMaxFld;
734
741 BoolField* _useImageIntervalFld;
743
744
745 //-------------------------------------------------------------------------------------------
748 //-------------------------------------------------------------------------------------------
755 DoubleField* _kernelIntervalMinFld;
756
763 DoubleField* _kernelIntervalMaxFld;
764
771 BoolField* _useKernelIntervalFld;
773
774
775 //-------------------------------------------------------------------------------------------
778 //-------------------------------------------------------------------------------------------
783 StringField* _kernelInfoFld;
784
793 IntField* _numKernelElementsFld;
794
803 DoubleField* _kernelElementsSumFld;
805
806
807 //-------------------------------------------------------------------------------------------
810 //-------------------------------------------------------------------------------------------
823 BoolField* _autoCalcMinMaxFld;
824
832 NotifyField* _setAutoMinMaxFld;
834
835
836 //-------------------------------------------------------------------------------------------
839 //-------------------------------------------------------------------------------------------
843 DoubleField* _outputMinFld;
844
848 DoubleField* _outputMaxFld;
849
854 BoolField* _useMinMaxFld;
856
857
858 //-------------------------------------------------------------------------------------------
861 //-------------------------------------------------------------------------------------------
862
865 MLdouble _autoMin;
866
869 MLdouble _autoMax;
870
874 bool _autoMinMaxValid;
876
877
880 bool _normImageInterval;
881
883 bool _normKernelInterval;
884
887 MLdouble _imageIntervalMin;
888
891 MLdouble _imageIntervalMax;
892
895 MLdouble _kernelIntervalMin;
896
899 MLdouble _kernelIntervalMax;
901
902
908};
909
911
912#endif // of __mlKernelModule_H
Field to encapsulate a boolean value.
Definition mlFields.h:56
Field to encapsulate a double value.
Definition mlFields.h:567
Base class for all fields used in the ML.
Definition mlField.h:73
Field to encapsulate an integer value.
Definition mlFields.h:123
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:687
The class PagedImage, representing a fragmented image that manages properties and data of an image lo...
Field to encapsulate a string value.
Definition mlFields.h:634
This class manages/represents a rectangular 6D image region that is organized linearly in memory.
Definition mlSubImage.h:75
#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...
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 that is used by the ML for indexing and coordinates.