MeVisLab Toolbox Reference
ml::KernelLineApplicator< DATATYPE, KDATATYPE > Class Template Reference

The KernelLineApplicator class takes a Kernel instance and filters one line of an mlSubImage and writes it to an output also given by another mlSubImage. More...

#include <mlKernelLineApplicator.h>

Inheritance diagram for ml::KernelLineApplicator< DATATYPE, KDATATYPE >:
ml::KernelLineApplicatorBase< DATATYPE, KDATATYPE > ml::LineApplicator< DATATYPE >

Public Types

enum  ApplyMode {
  APPLY_COPY = 0 , APPLY_NORMALLY , APPLY_USER_FILTER , APPLY_IMAGE_INTERVAL_FILTER ,
  APPLY_KERNEL_INTERVAL_FILTER , APPLY_IMAGE_AND_KERNEL_INTERVAL_FILTER , NUM_APPLY_MODES
}
 The ApplyModes decide about the way how the kernel is used to filter the input image and which parts of it. More...
 

Public Member Functions

 KernelLineApplicator ()
 Default constructor. More...
 
 KernelLineApplicator (const KernelLineApplicator &kernLineApp)
 Copy constructor. More...
 
 KernelLineApplicator (const TKernel< KDATATYPE > &kernel, ApplyMode applyMode, MLdouble iIntMin=-DBL_MIN, MLdouble iIntMax=DBL_MAX, MLdouble kIntMin=-DBL_MIN, MLdouble kIntMax=DBL_MAX)
 Convenience constructor to create a complete line applicator with all important parameters set. More...
 
virtual ~KernelLineApplicator ()
 Destructor. Frees dynamic members. More...
 
const KernelLineApplicatoroperator= (const KernelLineApplicator &kernLineApp)
 Assignment operator. Assures that dynamic and normal members are copied correctly. More...
 
void setImageInterval (MLdouble min=-DBL_MAX, MLdouble max=DBL_MAX)
 Correlations can be applied to a subset of voxels by setting a threshold interval which includes the convoluted voxels. More...
 
void setKernelInterval (MLdouble min=-DBL_MAX, MLdouble max=DBL_MAX)
 When filtering an image then voxels covered by the kernel elements outside a certain grey level interval can be excluded. More...
 
bool isInImageInterval (DATATYPE v) const
 Test whether the value v is within image interval. More...
 
bool isInKernelInterval (DATATYPE v) const
 Test whether the value v is within kernel interval. More...
 
void applyToLine (TSubImageWithCursor< DATATYPE > *inSubImg, TSubImageWithCursor< DATATYPE > *outSubImg, size_t numVox)
 Selects the correct line filter mode and filters a row with the currently specified kernel. More...
 
virtual void applyUserFilterToLine (TSubImageWithCursor< DATATYPE > *inSubImg, TSubImageWithCursor< DATATYPE > *outSubImg, long numVox) const
 Filter a row with the current kernel with a user defined algorithm. More...
 
Set/Get the mode how the kernel is applied to the image.
void setApplyMode (ApplyMode mode)
 
ApplyMode getApplyMode () const
 
Return the interval limits for image and kernel interval.
DATATYPE getImageIntervalMin () const
 
DATATYPE getImageIntervalMax () const
 
DATATYPE getKernelIntervalMin () const
 
DATATYPE getKernelIntervalMax () const
 
- Public Member Functions inherited from ml::KernelLineApplicatorBase< DATATYPE, KDATATYPE >
 KernelLineApplicatorBase ()
 Default constructor. More...
 
 KernelLineApplicatorBase (const KernelLineApplicatorBase< DATATYPE, KDATATYPE > &kernLineAppBase)
 Copy constructor. More...
 
 KernelLineApplicatorBase (const TKernel< KDATATYPE > &kernel)
 Convenience constructor to create a complete line applicator with all important parameters set. More...
 
 ~KernelLineApplicatorBase () override
 Destructor. Frees dynamic members. More...
 
const KernelLineApplicatorBase< DATATYPE, KDATATYPE > & operator= (const KernelLineApplicatorBase< DATATYPE, KDATATYPE > &kernLineAppBase)
 Assignment operator. Assures that dynamic and normal members are copied correctly. More...
 
void applyToLine (TSubImageWithCursor< DATATYPE > *inSubImg, TSubImageWithCursor< DATATYPE > *, size_t) override
 Applies the kernel to a row of the input subimage. More...
 
ImageVector getNegativeExtent () const override
 Returns the negative extent of a kernel used for filtering. More...
 
ImageVector getPositiveExtent () const override
 Returns the positive extent of a kernel used for filtering. More...
 
void setKernel (const TKernel< KDATATYPE > &kernel)
 
const TKernel< KDATATYPE > & getKernel () const
 
- Public Member Functions inherited from ml::LineApplicator< DATATYPE >
virtual ~LineApplicator ()
 Virtual destructor. Currently it does nothing. More...
 

Static Public Attributes

static const char *const ApplyModeNames []
 Strings for ApplyMode names. See mlKernalLineApplicator.cpp for the names. More...
 

Protected Member Functions

void _init ()
 Initialization the current instance of mlKernelApplicator. To be called by constructors. More...
 
- Protected Member Functions inherited from ml::KernelLineApplicatorBase< DATATYPE, KDATATYPE >
void _init ()
 Initialization the current instance of mlKernelApplicatorBase. To be called by constructors. More...
 
virtual void _defineIndices (const SubImage &inSubImg)
 Create the table of offsets from the voxel (0,0,0,0,0,0) of the kernel to any other voxel of the kernel in an inSubImg. More...
 
virtual void _clearIndices ()
 Removes the current _indexTab. More...
 

Protected Attributes

ApplyMode _applyMode
 The mode how the kernel is applied to the image. More...
 
bool _normOrigI
 _normOrigI==true indicates that the interval is used exclusively. More...
 
bool _normKernI
 _normKernI==true indicates that the interval is used exclusively. More...
 
Minimum/Maximum limits of interval limiting the input image voxels to be filtered.
MLdouble _origIMin
 
MLdouble _origIMax
 
DATATYPE _origIMinDT
 
DATATYPE _origIMaxDT
 
Minimum/Maximum limits of interval limiting the input image voxels used for filtering.
MLdouble _kernIMin
 
MLdouble _kernIMax
 
DATATYPE _kernIMinDT
 
DATATYPE _kernIMaxDT
 
- Protected Attributes inherited from ml::KernelLineApplicatorBase< DATATYPE, KDATATYPE >
const TKernel< KDATATYPE > * _kernel
 Pointer to the kernel used to filter an input page. More...
 
MLsoffset_indexTab
 Table and variables defined temporarily while filtering a page. More...
 
size_t _indexTabSize
 Size of _indexTab. Default is 0. More...
 
MLsoffset _srcVoxOffset
 Offset from origin of kernel in input image to the voxel under the replaced voxel in output image. More...
 

Detailed Description

template<typename DATATYPE, typename KDATATYPE>
class ml::KernelLineApplicator< DATATYPE, KDATATYPE >

The KernelLineApplicator class takes a Kernel instance and filters one line of an mlSubImage and writes it to an output also given by another mlSubImage.

This class is derived from the KernelLineApplicatorBase where it needs to overload the central method

applyToLine(TSubImageWithCursor<DATATYPE> *inSubImg, TSubImageWithCursor<DATATYPE> *outSubImg, size_t numVox)

which applies the currently set kernel to a line of numVox voxels in the inSubImg and writes the result to outSubImg. Before doing that in both subimages the cursor position must be set adequately. This is usually done by applyFiltering functions from the KernelTools class. So usually there is no need to use this class explicitly if it's not overloaded.

There are some modes how the kernel can be applied to inSubImg and the user can implement its own mode by overloading the method

applyUserFilterToLine(TSubImageWithCursor<DATATYPE> *inSubImg, TSubImageWithCursor<DATATYPE> *outSubImg, int numVox)

Then pass an instance of your KernelLineApplicator to an applyFiltering functions from the KernelTools class which filters an entire subimage with it.

For related code and more information see mlKernelExample.h, mlKernel.h, mlKernelBaseModule.h, mlKernelModule.h, mlKernelEditor.h, mlRankFilter.h, mlExtConvolutionFilter.h, mlKernelMacros, mlKernelTools.h and mlConvolutionFilter.h.

Definition at line 67 of file mlKernelLineApplicator.h.

Member Enumeration Documentation

◆ ApplyMode

template<typename DATATYPE , typename KDATATYPE >
enum ml::KernelLineApplicator::ApplyMode

The ApplyModes decide about the way how the kernel is used to filter the input image and which parts of it.

-APPLY_COPY Copy those row voxels from input subimage which correspond to the row to be modified in the output image.

-APPLY_NORMALLY Filter a row with the current kernel.

-APPLY_USER_FILTER Filter a row with the current kernel with a user defined algorithm.

-APPLY_IMAGE_INTERVAL_FILTER Filter a row with the current kernel. Apply kernel only to voxels which fulfil the image interval.

-APPLY_KERNEL_INTERVAL_FILTER Filter a voxel with the current kernel. All input image voxels under kernel elements which are not in the kernel interval are not multiplied with kernel element values and are not added to result value.

-APPLY_IMAGE_AND_KERNEL_INTERVAL_FILTER Filter a voxel with the current kernel. All input image voxels under kernel elements which are not in the kernel interval are not multiplied with kernel element values and are not added to result value. Only input image voxels are filtered which fulfil the image interval.

Enumerator
APPLY_COPY 
APPLY_NORMALLY 
APPLY_USER_FILTER 
APPLY_IMAGE_INTERVAL_FILTER 
APPLY_KERNEL_INTERVAL_FILTER 
APPLY_IMAGE_AND_KERNEL_INTERVAL_FILTER 
NUM_APPLY_MODES 

Definition at line 101 of file mlKernelLineApplicator.h.

Constructor & Destructor Documentation

◆ KernelLineApplicator() [1/3]

template<typename DATATYPE , typename KDATATYPE >
ml::KernelLineApplicator< DATATYPE, KDATATYPE >::KernelLineApplicator ( )
inline

Default constructor.

Default settings are an invalid kernel, empty index tables, unlimited image and filter intervals and _srcVoxOffset=0. _applyMode is ApplyNormally.

Definition at line 121 of file mlKernelLineApplicator.h.

References ml::KernelLineApplicatorBase< DATATYPE, KDATATYPE >::_init().

◆ KernelLineApplicator() [2/3]

template<typename DATATYPE , typename KDATATYPE >
ml::KernelLineApplicator< DATATYPE, KDATATYPE >::KernelLineApplicator ( const KernelLineApplicator< DATATYPE, KDATATYPE > &  kernLineApp)
inline

Copy constructor.

Definition at line 129 of file mlKernelLineApplicator.h.

References ml::KernelLineApplicatorBase< DATATYPE, KDATATYPE >::_init().

◆ KernelLineApplicator() [3/3]

template<typename DATATYPE , typename KDATATYPE >
ml::KernelLineApplicator< DATATYPE, KDATATYPE >::KernelLineApplicator ( const TKernel< KDATATYPE > &  kernel,
ApplyMode  applyMode,
MLdouble  iIntMin = -DBL_MIN,
MLdouble  iIntMax = DBL_MAX,
MLdouble  kIntMin = -DBL_MIN,
MLdouble  kIntMax = DBL_MAX 
)
inline

Convenience constructor to create a complete line applicator with all important parameters set.

An instance of an mlKernelApplicator and the kernel application mode must be passed. Image and kernel interval are optional and default to unlimited intervals.

Definition at line 142 of file mlKernelLineApplicator.h.

References ml::KernelLineApplicatorBase< DATATYPE, KDATATYPE >::_init(), and ml::KernelLineApplicatorBase< DATATYPE, KDATATYPE >::setKernel().

◆ ~KernelLineApplicator()

template<typename DATATYPE , typename KDATATYPE >
virtual ml::KernelLineApplicator< DATATYPE, KDATATYPE >::~KernelLineApplicator ( )
inlinevirtual

Destructor. Frees dynamic members.

Definition at line 165 of file mlKernelLineApplicator.h.

References ml::KernelLineApplicatorBase< DATATYPE, KDATATYPE >::_clearIndices().

Member Function Documentation

◆ _init()

template<typename DATATYPE , typename KDATATYPE >
void ml::KernelLineApplicator< DATATYPE, KDATATYPE >::_init ( )
inlineprotected

Initialization the current instance of mlKernelApplicator. To be called by constructors.

Definition at line 398 of file mlKernelLineApplicator.h.

References ml::KernelLineApplicatorBase< DATATYPE, KDATATYPE >::_init().

◆ applyToLine()

template<typename DATATYPE , typename KDATATYPE >
void ml::KernelLineApplicator< DATATYPE, KDATATYPE >::applyToLine ( TSubImageWithCursor< DATATYPE > *  inSubImg,
TSubImageWithCursor< DATATYPE > *  outSubImg,
size_t  numVox 
)
inlinevirtual

Selects the correct line filter mode and filters a row with the currently specified kernel.

Cursors must have been set in input and output subimage. Define the index table before using this method. On empty index tables the voxel of the input image is copied to the output.

Reimplemented from ml::LineApplicator< DATATYPE >.

Definition at line 299 of file mlKernelLineApplicator.h.

References ml::KernelLineApplicatorBase< DATATYPE, KDATATYPE >::_defineIndices(), ml::KernelTools::copyLine(), ml::KernelTools::correlateLine(), ml::KernelTools::correlateLineWithImageAndKernelInterval(), ml::KernelTools::correlateLineWithImageInterval(), ml::KernelTools::correlateLineWithKernelInterval(), and ml::TSubImageWithCursor< DATATYPE >::getCursorPos().

◆ applyUserFilterToLine()

template<typename DATATYPE , typename KDATATYPE >
virtual void ml::KernelLineApplicator< DATATYPE, KDATATYPE >::applyUserFilterToLine ( TSubImageWithCursor< DATATYPE > *  inSubImg,
TSubImageWithCursor< DATATYPE > *  outSubImg,
long  numVox 
) const
inlinevirtual

Filter a row with the current kernel with a user defined algorithm.

Cursors in input and output subimage and index table must be up to date. Overload this method to implement you own algorithm to apply the kernel to the image.

Definition at line 382 of file mlKernelLineApplicator.h.

References ml::KernelTools::copyLine(), and ml::TSubImageWithCursor< DATATYPE >::getCursorPos().

◆ getApplyMode()

template<typename DATATYPE , typename KDATATYPE >
ApplyMode ml::KernelLineApplicator< DATATYPE, KDATATYPE >::getApplyMode ( ) const
inline

Definition at line 199 of file mlKernelLineApplicator.h.

◆ getImageIntervalMax()

template<typename DATATYPE , typename KDATATYPE >
DATATYPE ml::KernelLineApplicator< DATATYPE, KDATATYPE >::getImageIntervalMax ( ) const
inline

Definition at line 208 of file mlKernelLineApplicator.h.

◆ getImageIntervalMin()

template<typename DATATYPE , typename KDATATYPE >
DATATYPE ml::KernelLineApplicator< DATATYPE, KDATATYPE >::getImageIntervalMin ( ) const
inline

Definition at line 207 of file mlKernelLineApplicator.h.

◆ getKernelIntervalMax()

template<typename DATATYPE , typename KDATATYPE >
DATATYPE ml::KernelLineApplicator< DATATYPE, KDATATYPE >::getKernelIntervalMax ( ) const
inline

Definition at line 210 of file mlKernelLineApplicator.h.

◆ getKernelIntervalMin()

template<typename DATATYPE , typename KDATATYPE >
DATATYPE ml::KernelLineApplicator< DATATYPE, KDATATYPE >::getKernelIntervalMin ( ) const
inline

Definition at line 209 of file mlKernelLineApplicator.h.

◆ isInImageInterval()

template<typename DATATYPE , typename KDATATYPE >
bool ml::KernelLineApplicator< DATATYPE, KDATATYPE >::isInImageInterval ( DATATYPE  v) const
inline

Test whether the value v is within image interval.

Note that the interval is considered exclusively if maximum is smaller than minimum, i.e. all values between maximum and minimum are excluded and all others are included. Default is false.

Definition at line 252 of file mlKernelLineApplicator.h.

◆ isInKernelInterval()

template<typename DATATYPE , typename KDATATYPE >
bool ml::KernelLineApplicator< DATATYPE, KDATATYPE >::isInKernelInterval ( DATATYPE  v) const
inline

Test whether the value v is within kernel interval.

Note that the interval is considered exclusively if maximum is smaller than minimum, i.e. all values between maximum and minimum are excluded and all other are included. Default is false.

Definition at line 277 of file mlKernelLineApplicator.h.

◆ operator=()

◆ setApplyMode()

template<typename DATATYPE , typename KDATATYPE >
void ml::KernelLineApplicator< DATATYPE, KDATATYPE >::setApplyMode ( ApplyMode  mode)
inline

Definition at line 198 of file mlKernelLineApplicator.h.

◆ setImageInterval()

template<typename DATATYPE , typename KDATATYPE >
void ml::KernelLineApplicator< DATATYPE, KDATATYPE >::setImageInterval ( MLdouble  min = -DBL_MAX,
MLdouble  max = DBL_MAX 
)
inline

Correlations can be applied to a subset of voxels by setting a threshold interval which includes the convoluted voxels.

If used then only voxels >= min and <=max are modified by correlations. Default is (-DBL_MAX, DBL_MAX).

Definition at line 219 of file mlKernelLineApplicator.h.

◆ setKernelInterval()

template<typename DATATYPE , typename KDATATYPE >
void ml::KernelLineApplicator< DATATYPE, KDATATYPE >::setKernelInterval ( MLdouble  min = -DBL_MAX,
MLdouble  max = DBL_MAX 
)
inline

When filtering an image then voxels covered by the kernel elements outside a certain grey level interval can be excluded.

If used then only voxels >= min and <=max are multiplied with kernel values. Otherwise these products are not added to the resulting output image voxel. Default is (-DBL_MAX, DBL_MAX).

Definition at line 236 of file mlKernelLineApplicator.h.

Member Data Documentation

◆ _applyMode

template<typename DATATYPE , typename KDATATYPE >
ApplyMode ml::KernelLineApplicator< DATATYPE, KDATATYPE >::_applyMode
protected

The mode how the kernel is applied to the image.

Definition at line 420 of file mlKernelLineApplicator.h.

Referenced by ml::KernelLineApplicator< DATATYPE, KDATATYPE >::operator=().

◆ _kernIMax

template<typename DATATYPE , typename KDATATYPE >
MLdouble ml::KernelLineApplicator< DATATYPE, KDATATYPE >::_kernIMax
protected

◆ _kernIMaxDT

template<typename DATATYPE , typename KDATATYPE >
DATATYPE ml::KernelLineApplicator< DATATYPE, KDATATYPE >::_kernIMaxDT
protected

Definition at line 443 of file mlKernelLineApplicator.h.

◆ _kernIMin

template<typename DATATYPE , typename KDATATYPE >
MLdouble ml::KernelLineApplicator< DATATYPE, KDATATYPE >::_kernIMin
protected

◆ _kernIMinDT

template<typename DATATYPE , typename KDATATYPE >
DATATYPE ml::KernelLineApplicator< DATATYPE, KDATATYPE >::_kernIMinDT
protected

Definition at line 442 of file mlKernelLineApplicator.h.

◆ _normKernI

template<typename DATATYPE , typename KDATATYPE >
bool ml::KernelLineApplicator< DATATYPE, KDATATYPE >::_normKernI
protected

_normKernI==true indicates that the interval is used exclusively.

Definition at line 447 of file mlKernelLineApplicator.h.

◆ _normOrigI

template<typename DATATYPE , typename KDATATYPE >
bool ml::KernelLineApplicator< DATATYPE, KDATATYPE >::_normOrigI
protected

_normOrigI==true indicates that the interval is used exclusively.

Definition at line 434 of file mlKernelLineApplicator.h.

◆ _origIMax

template<typename DATATYPE , typename KDATATYPE >
MLdouble ml::KernelLineApplicator< DATATYPE, KDATATYPE >::_origIMax
protected

◆ _origIMaxDT

template<typename DATATYPE , typename KDATATYPE >
DATATYPE ml::KernelLineApplicator< DATATYPE, KDATATYPE >::_origIMaxDT
protected

Definition at line 430 of file mlKernelLineApplicator.h.

◆ _origIMin

template<typename DATATYPE , typename KDATATYPE >
MLdouble ml::KernelLineApplicator< DATATYPE, KDATATYPE >::_origIMin
protected

◆ _origIMinDT

template<typename DATATYPE , typename KDATATYPE >
DATATYPE ml::KernelLineApplicator< DATATYPE, KDATATYPE >::_origIMinDT
protected

Definition at line 429 of file mlKernelLineApplicator.h.

◆ ApplyModeNames

template<typename DATATYPE , typename KDATATYPE >
const char *const ml::KernelLineApplicator< DATATYPE, KDATATYPE >::ApplyModeNames
static
Initial value:
= {
"ApplyCopy",
"ApplyNormally",
"ApplyUserFilter",
"ApplyImageIntervalFilter",
"ApplyKernelIntervalFilter",
"ApplyImageAndKernelInterval"
}

Strings for ApplyMode names. See mlKernalLineApplicator.cpp for the names.

Strings for mlApplyModeNames.

Definition at line 115 of file mlKernelLineApplicator.h.


The documentation for this class was generated from the following file: