MeVisLabToolboxReference
MeVisLab/Standard/Sources/ML/MLKernel/mlSurroundFilter.h
Go to the documentation of this file.
00001 // **InsertLicense** code
00002 //-------------------------------------------------------------------------
00005 
00010 //-------------------------------------------------------------------------
00011 // Prevent multiple including of this file.
00012 #if !defined(__mlSurroundFilter_H)
00013 #define __mlSurroundFilter_H
00014 
00015 // ML-includes
00016 #ifndef __mlInitSystemKernel_H
00017 #include "mlInitSystemKernel.h"
00018 #endif
00019 #ifndef __mlKernelModule_H
00020 #include "mlKernelModule.h"
00021 #endif
00022 
00023 ML_START_NAMESPACE
00024 
00025   //--------------------------------------------------
00036   //--------------------------------------------------
00037   class MLKERNELEXPORT SurroundFilter : public KernelModule{
00038 
00039   public:
00040 
00041     //-------------------------------------------------------------------
00043     //-------------------------------------------------------------------
00044     enum DimensionSelect{USE2D                = 0,
00045                          USE3D                ,
00046 
00047                          NUM_DIMENSION_SELECTS};
00048 
00049     //-------------------------------------------------------------------
00051     //-------------------------------------------------------------------
00052     static const char* const DimensionSelectNames[];
00053 
00054     //-------------------------------------------------------------------
00056     //-------------------------------------------------------------------
00057     enum Neighbourhood2DSelect{USE4                        = 0,
00058                                USE8                        ,
00059 
00060                                NUM_NEIGHBOURHOOD_2D_SELECTS};
00061 
00062     //-------------------------------------------------------------------
00064     //-------------------------------------------------------------------
00065     static const char* const Neighbourhood2DSelectNames[];
00066 
00067     //-------------------------------------------------------------------
00069     //-------------------------------------------------------------------
00070     enum Neighbourhood3DSelect{USE6                        = 0,
00071                                USE18                       ,
00072                                USE26                       ,
00073 
00074                                NUM_NEIGHBOURHOOD_3D_SELECTS};
00075 
00076     //-------------------------------------------------------------------
00078     //-------------------------------------------------------------------
00079     static const char* const Neighbourhood3DSelectNames[];
00080 
00081     //-------------------------------------------------------------------
00084     //-------------------------------------------------------------------
00085     enum BorderLocation {SET_INNER_BORDER    = 0,
00086                          SET_OUTER_BORDER    ,
00087                          SET_BOTH_BORDERS    ,
00088 
00089                          NUM_BORDER_LOCATIONS};
00090 
00091     //-------------------------------------------------------------------
00093     //-------------------------------------------------------------------
00094     static const char* const BorderLocationNames[];
00095 
00096 
00097 
00098     //-------------------------------------------------------------------
00106     //-------------------------------------------------------------------
00107     SurroundFilter();
00108 
00109     //-------------------------------------------------------------------
00111 
00112     //-------------------------------------------------------------------
00113     EnumField  * getDimensionSelectFld      () const { return _dimensionSelectFld      ; }
00114     EnumField  * getNeighbourhood2DSelectFld() const { return _neighbourhood2DSelectFld; }
00115     EnumField  * getNeighbourhood3DSelectFld() const { return _neighbourhood3DSelectFld; }
00116     EnumField  * getBorderLocationFld       () const { return _borderLocationFld       ; }
00117     DoubleField* getOuterBorderValueFld     () const { return _outerBorderValueFld     ; }
00118     DoubleField* getInnerBorderValueFld     () const { return _innerBorderValueFld     ; }
00119     DoubleField* getLowerThresholdFld       () const { return _lowerThresholdFld       ; }
00120     DoubleField* getUpperThresholdFld       () const { return _upperThresholdFld       ; }
00121     BoolField  * getOnlyBorderFld           () const { return _onlyBorderFld           ; }
00122     BoolField  * getTakeMaxFld              () const { return _takeMaxFld              ; }
00123     BoolField  * getTakeMiddleFld           () const { return _takeMiddleFld           ; }
00125 
00126 protected:
00127 
00133     CALC_ROW_H();
00134 
00137     template <typename DATATYPE>
00138       void calcRow(MLsoffset    *indexTab,
00139                    size_t       indexTabSize,
00140                    MLsoffset    /*srcVoxelOffset*/,
00141                    size_t       numVox,
00142                    DATATYPE     *inCursor,
00143                    DATATYPE     *outCursor,
00144                    const ImageVector &/*rowStart*/);
00145 
00147     virtual void handleNotification(Field* field);
00148 
00150     virtual void calculateOutputImageProperties(int outIndex);
00151 
00152     // We overload this kernel update method to overwrite kernel settings resulting
00153     // from inherited functionality.
00154     virtual void _userKernelPostUpdate();
00155 
00156 
00157   private:
00158 
00161     EnumField*   _dimensionSelectFld;
00162 
00164     EnumField*   _neighbourhood2DSelectFld;
00165 
00167     EnumField*   _neighbourhood3DSelectFld;
00168 
00170     EnumField*   _borderLocationFld;
00171 
00174     DoubleField* _outerBorderValueFld;
00175 
00178     DoubleField* _innerBorderValueFld;
00179 
00181     DoubleField* _lowerThresholdFld;
00182 
00184     DoubleField* _upperThresholdFld;
00185 
00188     BoolField*   _onlyBorderFld;
00189 
00192     BoolField*   _takeMaxFld;
00193 
00196     BoolField*   _takeMiddleFld;
00197 
00200     BoolField*   _twoDimFld;
00201 
00202 
00203 
00205     MLint          _voxelIndex;
00206 
00208     KernelDataType _values2D[9];
00209 
00211     KernelDataType _values3D[27];
00212 
00215     static bool    _mask2Duse4[9];
00216 
00219     static bool    _mask2Duse8[9];
00220 
00223     static bool    _mask3Duse6[27];
00224 
00227     static bool    _mask3Duse18[27];
00228 
00231     static bool    _mask3Duse26[27];
00232 
00237     ML_MODULE_CLASS_HEADER(SurroundFilter);
00238  };
00239 
00240 ML_END_NAMESPACE
00241 
00242 #endif //of __mlSurroundFilter_H
00243 
00244 
00245 
00246