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.
 
 KernelLineApplicator (const KernelLineApplicator &kernLineApp)
 Copy constructor.
 
 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.
 
virtual ~KernelLineApplicator ()
 Destructor. Frees dynamic members.
 
const KernelLineApplicatoroperator= (const KernelLineApplicator &kernLineApp)
 Assignment operator. Assures that dynamic and normal members are copied correctly.
 
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.
 
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.
 
bool isInImageInterval (DATATYPE v) const
 Test whether the value v is within image interval.
 
bool isInKernelInterval (DATATYPE v) const
 Test whether the value v is within kernel interval.
 
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.
 
virtual void applyUserFilterToLine (TSubImageWithCursor< DATATYPE > *inSubImg, TSubImageWithCursor< DATATYPE > *outSubImg, long numVox) const
 Filter a row with the current kernel with a user defined algorithm.
 
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.
 
 KernelLineApplicatorBase (const KernelLineApplicatorBase< DATATYPE, KDATATYPE > &kernLineAppBase)
 Copy constructor.
 
 KernelLineApplicatorBase (const TKernel< KDATATYPE > &kernel)
 Convenience constructor to create a complete line applicator with all important parameters set.
 
 ~KernelLineApplicatorBase () override
 Destructor. Frees dynamic members.
 
const KernelLineApplicatorBase< DATATYPE, KDATATYPE > & operator= (const KernelLineApplicatorBase< DATATYPE, KDATATYPE > &kernLineAppBase)
 Assignment operator. Assures that dynamic and normal members are copied correctly.
 
void applyToLine (TSubImageWithCursor< DATATYPE > *inSubImg, TSubImageWithCursor< DATATYPE > *, size_t) override
 Applies the kernel to a row of the input subimage.
 
ImageVector getNegativeExtent () const override
 Returns the negative extent of a kernel used for filtering.
 
ImageVector getPositiveExtent () const override
 Returns the positive extent of a kernel used for filtering.
 
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.
 

Static Public Attributes

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

Protected Member Functions

void _init ()
 Initialization the current instance of mlKernelApplicator. To be called by constructors.
 
- Protected Member Functions inherited from ml::KernelLineApplicatorBase< DATATYPE, KDATATYPE >
void _init ()
 Initialization the current instance of mlKernelApplicatorBase. To be called by constructors.
 
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.
 
virtual void _clearIndices ()
 Removes the current _indexTab.
 

Protected Attributes

ApplyMode _applyMode
 The mode how the kernel is applied to the image.
 
bool _normOrigI
 _normOrigI==true indicates that the interval is used exclusively.
 
bool _normKernI
 _normKernI==true indicates that the interval is used exclusively.
 
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.
 
MLsoffset_indexTab
 Table and variables defined temporarily while filtering a page.
 
size_t _indexTabSize
 Size of _indexTab. Default is 0.
 
MLsoffset _srcVoxOffset
 Offset from origin of kernel in input image to the voxel under the replaced voxel in output image.
 

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

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]

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]

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(), and mlrange_cast().

◆ KernelLineApplicator() [3/3]

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(), mlrange_cast(), and ml::KernelLineApplicatorBase< DATATYPE, KDATATYPE >::setKernel().

◆ ~KernelLineApplicator()

Member Function Documentation

◆ _init()

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(), and mlrange_cast().

◆ applyToLine()

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 mlrange_cast().

◆ applyUserFilterToLine()

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 mlrange_cast().

◆ getApplyMode()

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

Definition at line 199 of file mlKernelLineApplicator.h.

◆ getImageIntervalMax()

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

Definition at line 208 of file mlKernelLineApplicator.h.

◆ getImageIntervalMin()

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

Definition at line 207 of file mlKernelLineApplicator.h.

◆ getKernelIntervalMax()

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

Definition at line 210 of file mlKernelLineApplicator.h.

◆ getKernelIntervalMin()

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

Definition at line 209 of file mlKernelLineApplicator.h.

◆ isInImageInterval()

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()

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=()

Assignment operator. Assures that dynamic and normal members are copied correctly.

Definition at line 173 of file mlKernelLineApplicator.h.

References mlrange_cast(), and ml::KernelLineApplicatorBase< DATATYPE, KDATATYPE >::operator=().

◆ setApplyMode()

Definition at line 198 of file mlKernelLineApplicator.h.

◆ setImageInterval()

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.

References mlrange_cast().

◆ setKernelInterval()

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.

References mlrange_cast().

Member Data Documentation

◆ _applyMode

The mode how the kernel is applied to the image.

Definition at line 420 of file mlKernelLineApplicator.h.

◆ _kernIMax

Definition at line 441 of file mlKernelLineApplicator.h.

◆ _kernIMaxDT

Definition at line 443 of file mlKernelLineApplicator.h.

◆ _kernIMin

Definition at line 440 of file mlKernelLineApplicator.h.

◆ _kernIMinDT

Definition at line 442 of file mlKernelLineApplicator.h.

◆ _normKernI

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

Definition at line 447 of file mlKernelLineApplicator.h.

◆ _normOrigI

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

Definition at line 434 of file mlKernelLineApplicator.h.

◆ _origIMax

Definition at line 428 of file mlKernelLineApplicator.h.

◆ _origIMaxDT

Definition at line 430 of file mlKernelLineApplicator.h.

◆ _origIMin

Definition at line 427 of file mlKernelLineApplicator.h.

◆ _origIMinDT

Definition at line 429 of file mlKernelLineApplicator.h.

◆ ApplyModeNames

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: