MeVisLab Toolbox Reference
ml::TKernel< KDATATYPE > Class Template Reference

Class to manage a filtering kernel for images. More...

#include <mlKernel.h>

Public Types

enum  KernModifier {
  KERN_SET = 0 , KERN_MULT , KERN_ADD , KERN_INVDIV ,
  KERN_INVSUB , KERN_SQR , KERN_SQRT , KERN_POW ,
  KERN_LOG , KERN_NORMALIZE , KERN_GAUSS , KERN_SPHERE ,
  KERN_MIRROR , KERN_MIRROR_X , KERN_MIRROR_Y , KERN_MIRROR_Z ,
  KERN_MIRROR_C , KERN_MIRROR_T , KERN_MIRROR_U , NUM_KERN_MODIFYERS
}
 Manipulation modes for kernel values with a given value v: More...
 

Public Member Functions

 TKernel ()
 Constructor. Builds an empty kernel. More...
 
 TKernel (const TKernel &kern)
 Copy constructor. Builds a kernel with contents of kern. More...
 
virtual ~TKernel ()
 Destructor. Cleans up and removes instance of kernel. More...
 
const TKerneloperator= (const TKernel &kern)
 Assignment operator. Sets current instance to contents of kern. More...
 
void reset ()
 Reset kernel to construction state. More...
 
size_t getTabSize () const
 Returns the current number of kernel elements. More...
 
const ImageVectorgetCoordTab (size_t dim=0) const
 Gets a table of coordinates pointing to all kernel elements which are currently defined. More...
 
const KDATATYPE * getValueTab (size_t dim=0) const
 Gets the table of kernel element values which are currently defined. More...
 
KDATATYPE getValueTabSum () const
 Return the sum of all kernel element values. More...
 
KDATATYPE getMinValue () const
 Return the minimum value of all kernel element values If kernel value table is empty then 0 is returned. More...
 
KDATATYPE getMaxValue () const
 Return the maximum value of all kernel element values If kernel value table is empty then 1 is returned. More...
 
KDATATYPE getNegativeValueSum () const
 Return the sum of all negative kernel element values. More...
 
KDATATYPE getPositiveValueSum () const
 Return the sum of all positive kernel element values. More...
 
void manipulateKernelElements (KernModifier mode, KDATATYPE v)
 Modify all kernel element values with the value v. More...
 
const ImageVectorgetExtent () const
 Returns the kernel extents in 6D. More...
 
const ImageVectorgetNegativeExtent () const
 The extent of the kernel to both sides. More...
 
const ImageVectorgetPositiveExtent () const
 See getNegativeExtent(). More...
 
MLint findIndex (const ImageVector &pos) const
 Return index to kernel element if it exists; otherwise return -1. More...
 
void setPartialKernel (size_t numElems, ImageVector *const coords, KDATATYPE *const values=nullptr)
 Defines a set of local kernel coordinates and optionally a set of values which define the kernel elements. More...
 
std::string getKernel (bool asLines=false, MLint fieldWidth=0, MLint precision=10) const
 Returns the current kernel elements and values as string: The string needs has the following format:
. More...
 
std::string setKernel (const std::string &kernString)
 Defines elements and values of the kernel matrix by a string. More...
 
void setKernel (const ImageVector &ext, const KDATATYPE *const values=nullptr, bool *const mask=nullptr)
 Defines a complete kernel matrix whose extents are defined by ext. More...
 
template<typename KDATATYPE2 >
void setKernel (const ImageVector &ext, const KDATATYPE2 *const xaxis, const KDATATYPE2 *const yaxis, const KDATATYPE2 *const zaxis, const KDATATYPE2 *const caxis, const KDATATYPE2 *const taxis, const KDATATYPE2 *const uaxis, bool normalize)
 Defines a complete kernel matrix whose extents are defined by ext. More...
 
void setSeparableKernel (const std::vector< typename std::vector< KDATATYPE > > &separableRows)
 Create kernel coordinate and value tables in separable table format, that means a 2-D kernel where each rows describes the elements of 1-D kernels. More...
 
void resizeKernel (const ImageVector &ext, KDATATYPE newVal=0)
 Resizes the kernel to a new state and tries to maintain the previous elements if possible. More...
 
void fillUndefinedElements (KDATATYPE newVal=0)
 Fill all undefined kernel elements with newVal. More...
 
void makeCircular ()
 Takes the current kernel, computes radii from the extents of the kernel and removes all kernel elements which are outside the ellipsoid defined by these radii. More...
 
void mirror (int dimension=-1)
 Applies a point symmetric mirroring of all kernel elements. More...
 
void setGauss (const ImageVector &ext)
 Replaces the current kernel by a normalized gauss kernel. More...
 
Support for an interpretation as separable kernel.
void setSeparable (bool isSeparableVal)
 Set/unset a flag to indicate that the first 6 rows of the first kernel slice is considered as 1-D axes of a separable filter kernel. More...
 
bool isSeparable () const
 Indicates whether the first 6 rows of the first kernel slice are interpreted as 1-D axes of a separable filter kernel; default is false. More...
 
ImageVector getSeparableDimEntries () const
 Returns a ImageVector with the number of entries of the separable kernel for the dimensions 0,...,5. More...
 
ImageVector getSeparableOneDimExtents () const
 Returns a vector where the components 0,...,5 contain the extent of the region spanned by the 6 separated 1-D kernels if the kernel is interpreted as a separable kernel. More...
 
size_t getSeparableDimIndex (size_t dim=0) const
 Returns the index to entries of valueTab or coordTab which are related to the 1-D separable kernel for the dimension dim where dim must be from [0,5]. More...
 
const std::vector< ImageVector > & getSeparableCoordTab () const
 Returns the table of with all coordinates for filtering with separable kernels. More...
 

Static Public Member Functions

static MLint coordToIndex (MLint x, MLint y, MLint z, MLint c, MLint t, MLint u, const ImageVector &size)
 Converts the coordinate (x,y,z,c,t,u) into the kernel to an index into an array with 6D extents given by size. More...
 
static MLint coordToIndex (const ImageVector &p, const ImageVector &size)
 Converts the coordinate into the kernel with extents size to an index. More...
 
static ImageVector indexToCoord (MLint idx, const ImageVector &ext)
 Converts an index into an array with extents ext to a coordinate. More...
 
static ImageVector calculateNegativeExtentFromExtent (const ImageVector &ext)
 Calculate the negative extent of a kernel from a kernel extent. More...
 
static ImageVector calculatePositiveExtentFromExtent (const ImageVector &ext)
 Calculate the positive extent of a kernel from a kernel extent. More...
 
static MLldouble binomialcoeff (MLint n, MLint k)
 Calculate binomial coefficients for (n) (k) More...
 
static std::vector< KDATATYPE > get1DGauss (size_t numSamples, bool normalize=true)
 Returns a vector with numSample values binomial coefficients. More...
 

Protected Member Functions

void _init ()
 Initialization. Should be called only by constructors. More...
 
void _clearTables ()
 Clear all internal (dynamic) tables. More...
 
void _addCoordinate (const ImageVector &pos, KDATATYPE value, bool update)
 Add a new coordinate with value to the coordinate and value table. More...
 
void _calculateRealKernelExt ()
 Calculate the correct maximum kernel extent for used kernel elements. More...
 
void _validateSeparabilityInfos () const
 This method updates all members which are needed in query methods for separability properties of the kernel. More...
 
void _invalidateSeparableInfos ()
 Invalidate separability information. More...
 

Detailed Description

template<typename KDATATYPE>
class ml::TKernel< KDATATYPE >

Class to manage a filtering kernel for images.

This file contains the TKernel class to manage a 6D kernel which can be applied to images. It handles a set of coordinates (see getCoordTab()) and values for those coordinates (see getValueTab()). This permits the specification of kernels with gaps or only a few defined elements. So big kernels with few elements can be manipulated and applied fast. A set of operations is available on a kernel instance which includes arithmetics on the kernel values, gauss presets, normalization, different kernel set and get routines to created/save partially defined kernels, get/set methods to load/save kernels as strings or arrays and much more.

This TKernel class is implemented as template dependent on KDATATYPE to have different precisions for kernel elements. Normally the kernel is instantiated with double as KDATATYPE. You can also instantiate this class as MLfloat or MLldouble kernel. Instantiating this class with integer types as KDATATYPE is legal, however results of numeric operations are not rounded but cast. Also note that the usage of integer for KDATATYPE is not really useful since pure integer kernel operations are rare and some operations would suffer, because of the mentioned cast operations, because of integer overflows when many kernel elements are summed up or when creating default initializations where the sum of (all equal valued) kernel elements shall be one which is normally impossible with integer types.

The same consideration also holds for non scalar voxel values which could be used as kernel element type KDATATYPE; however no tests have been applied for that. At least conversions from/to strings will reduce values to scalars.

Since this class does not have any support to apply the kernel to the image since this is usually the algorithmic part of the modules. However there are some helper functions available in mlKernelTools for standard convolutions which can be called directly from the modules filtering (sub)images.

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 73 of file mlKernel.h.

Member Enumeration Documentation

◆ KernModifier

template<typename KDATATYPE >
enum ml::TKernel::KernModifier

Manipulation modes for kernel values with a given value v:

  • KERN_SET : Set all kernel elements to v.
  • KERN_MULT : Multiply all kernel elements with v.
  • KERN_ADD : Add v to kernel elements.
  • KERN_INVDIV : Each kernel element is replaced by v divided by the kernel element. Zero kernel elements are left unchanged.
  • KERN_INVSUB : Each kernel element is replaced by v minus the kernel element.
  • KERN_SQR : Compute squares of all kernel elements.
  • KERN_SQRT : Compute square roots of all kernel elements. Negative kernel elements are left unchanged.
  • KERN_POW : Compute all kernel elements raised to the power of v.
  • KERN_LOG : Compute logarithm of v of all kernel elements.
  • KERN_NORMALIZE : Multiply the all kernel element values with a value so that their sum is 1. If sum is zero then values are left unchanged.
  • KERN_GAUSS : Set all kernel elements to binomial values and normalize.
  • KERN_SPHERE : Throw away corners of the kernel value table to make it approximately spherical.
  • KERN_MIRROR : Applies a point symmetric mirroring of all kernel elements.
  • KERN_MIRROR_X : Applies a point symmetric mirroring of all kernel elements in x direction.
  • KERN_MIRROR_Y : Applies a point symmetric mirroring of all kernel elements in y direction.
  • KERN_MIRROR_Z : Applies a point symmetric mirroring of all kernel elements in z direction.
  • KERN_MIRROR_C : Applies a point symmetric mirroring of all kernel elements in c direction.
  • KERN_MIRROR_T : Applies a point symmetric mirroring of all kernel elements in t direction.
  • KERN_MIRROR_U : Applies a point symmetric mirroring of all kernel elements in u direction.
Enumerator
KERN_SET 
KERN_MULT 
KERN_ADD 
KERN_INVDIV 
KERN_INVSUB 
KERN_SQR 
KERN_SQRT 
KERN_POW 
KERN_LOG 
KERN_NORMALIZE 
KERN_GAUSS 
KERN_SPHERE 
KERN_MIRROR 
KERN_MIRROR_X 
KERN_MIRROR_Y 
KERN_MIRROR_Z 
KERN_MIRROR_C 
KERN_MIRROR_T 
KERN_MIRROR_U 
NUM_KERN_MODIFYERS 

Definition at line 102 of file mlKernel.h.

Constructor & Destructor Documentation

◆ TKernel() [1/2]

template<typename KDATATYPE >
ml::TKernel< KDATATYPE >::TKernel
inline

Constructor. Builds an empty kernel.

Definition at line 593 of file mlKernel.h.

◆ TKernel() [2/2]

template<typename KDATATYPE >
ml::TKernel< KDATATYPE >::TKernel ( const TKernel< KDATATYPE > &  kern)
inline

Copy constructor. Builds a kernel with contents of kern.

Definition at line 602 of file mlKernel.h.

◆ ~TKernel()

template<typename KDATATYPE >
ml::TKernel< KDATATYPE >::~TKernel
inlinevirtual

Destructor. Cleans up and removes instance of kernel.

Definition at line 612 of file mlKernel.h.

Member Function Documentation

◆ _addCoordinate()

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::_addCoordinate ( const ImageVector pos,
KDATATYPE  value,
bool  update 
)
protected

Add a new coordinate with value to the coordinate and value table.

Still not tested! If update is true (default) then the kernel extents are updated.

Definition at line 1890 of file mlKernel.h.

References ML_NO_MEMORY, and ML_PRINT_FATAL_ERROR.

◆ _calculateRealKernelExt()

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::_calculateRealKernelExt
protected

Calculate the correct maximum kernel extent for used kernel elements.

The maximum extent in all dimensions is reduced as much that all kernel coordinates just remain in valid extent. Leading empty entries in the kernel are not removed. Empty kernels are considered as kernels with extent (1,1,1,1,1,1).

Definition at line 1948 of file mlKernel.h.

References ml::compMax(), ML_PRINT_FATAL_ERROR, and ML_PROGRAMMING_ERROR.

◆ _clearTables()

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::_clearTables
protected

Clear all internal (dynamic) tables.

Definition at line 1867 of file mlKernel.h.

◆ _init()

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::_init
protected

Initialization. Should be called only by constructors.

Definition at line 1840 of file mlKernel.h.

◆ _invalidateSeparableInfos()

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::_invalidateSeparableInfos
protected

Invalidate separability information.

Definition at line 2097 of file mlKernel.h.

◆ _validateSeparabilityInfos()

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::_validateSeparabilityInfos
protected

This method updates all members which are needed in query methods for separability properties of the kernel.

Note: This method changes mutable members since it is required for get-methods on information about separability information.

Definition at line 2110 of file mlKernel.h.

References ml::TImageVector< CompIntType >::set(), ml::TVector6DBase< CompIntType >::x, and ml::TVector6DBase< CompIntType >::y.

◆ binomialcoeff()

template<typename KDATATYPE >
MLldouble ml::TKernel< KDATATYPE >::binomialcoeff ( MLint  n,
MLint  k 
)
static

Calculate binomial coefficients for (n) (k)

Definition at line 1758 of file mlKernel.h.

◆ calculateNegativeExtentFromExtent()

template<typename KDATATYPE >
ImageVector ml::TKernel< KDATATYPE >::calculateNegativeExtentFromExtent ( const ImageVector ext)
inlinestatic

◆ calculatePositiveExtentFromExtent()

template<typename KDATATYPE >
ImageVector ml::TKernel< KDATATYPE >::calculatePositiveExtentFromExtent ( const ImageVector ext)
inlinestatic

◆ coordToIndex() [1/2]

template<typename KDATATYPE >
MLint ml::TKernel< KDATATYPE >::coordToIndex ( const ImageVector p,
const ImageVector size 
)
inlinestatic

Converts the coordinate into the kernel with extents size to an index.

Definition at line 1011 of file mlKernel.h.

◆ coordToIndex() [2/2]

template<typename KDATATYPE >
MLint ml::TKernel< KDATATYPE >::coordToIndex ( MLint  x,
MLint  y,
MLint  z,
MLint  c,
MLint  t,
MLint  u,
const ImageVector size 
)
inlinestatic

Converts the coordinate (x,y,z,c,t,u) into the kernel to an index into an array with 6D extents given by size.

Definition at line 1002 of file mlKernel.h.

◆ fillUndefinedElements()

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::fillUndefinedElements ( KDATATYPE  newVal = 0)

Fill all undefined kernel elements with newVal.

Definition at line 1583 of file mlKernel.h.

◆ findIndex()

template<typename KDATATYPE >
MLint ml::TKernel< KDATATYPE >::findIndex ( const ImageVector pos) const

Return index to kernel element if it exists; otherwise return -1.

Note that this method needs to search; so it's not very efficient.

Definition at line 1049 of file mlKernel.h.

Referenced by ml::TKernel< KDATATYPE >::resizeKernel().

◆ get1DGauss()

template<typename KDATATYPE >
std::vector< KDATATYPE > ml::TKernel< KDATATYPE >::get1DGauss ( size_t  numSamples,
bool  normalize = true 
)
static

Returns a vector with numSample values binomial coefficients.

If numSamples is passed as 0 then an empty vector is returned. if normalize is passed true (the default) then all values are normalized to the sum of absolute values 1.

Definition at line 1782 of file mlKernel.h.

References ml::mlAbs().

◆ getCoordTab()

template<typename KDATATYPE >
const ImageVector * ml::TKernel< KDATATYPE >::getCoordTab ( size_t  dim = 0) const
inline

Gets a table of coordinates pointing to all kernel elements which are currently defined.

The size of the returned table is given by getTabSize(). In the case of separable filtering it returns those coordinates which are valid for the current pass of separable kernel filtering. It is then a subset of the array given by getSeparableCoordTab().

Definition at line 684 of file mlKernel.h.

◆ getExtent()

template<typename KDATATYPE >
const ImageVector & ml::TKernel< KDATATYPE >::getExtent
inline

Returns the kernel extents in 6D.

It defines the rectangular region in which all coordinates returned by getCoordTab() are found. Note that the returned region might be larger than required e.g. after removing elements from kernel. In the case of separable filtering it returns a vector where the components 0,...,5 contain the extent of the region spanned by the 6 separated 1-D kernels. Note that components for those dimensions where no filtering takes place are set to 1.

Definition at line 953 of file mlKernel.h.

◆ getKernel()

template<typename KDATATYPE >
std::string ml::TKernel< KDATATYPE >::getKernel ( bool  asLines = false,
MLint  fieldWidth = 0,
MLint  precision = 10 
) const

Returns the current kernel elements and values as string: The string needs has the following format:
.

(x_0, y_0, z_0, c_0, t_0, u_0):v_0
...
(x_n, y_n, z_n, c_n, t_n, u_n):v_n
where the coordinates left from ':' specify the 6d coordinate of the kernel element; the value v_x right from ':' specifies the value of the kernel element. If asLines is true then a second string format is used:
(*, y_0, z_0, c_0, t_0, u_0):x_0 ... x_n
...
(*, y_n, z_n, c_n, t_n, u_n):y_n ... y_n
So all kernel elements of a row are saved in a string line; so the x coordinates becomes invalid and is set as an asterisk. To have a minimum field width pass fieldWidth and the digits after the period if given by precision. Note that these settings are used only if asLines is true.

Definition at line 1137 of file mlKernel.h.

References ml::TVector< TVectorBase >::print().

◆ getMaxValue()

template<typename KDATATYPE >
KDATATYPE ml::TKernel< KDATATYPE >::getMaxValue

Return the maximum value of all kernel element values If kernel value table is empty then 1 is returned.

Definition at line 731 of file mlKernel.h.

◆ getMinValue()

template<typename KDATATYPE >
KDATATYPE ml::TKernel< KDATATYPE >::getMinValue

Return the minimum value of all kernel element values If kernel value table is empty then 0 is returned.

Definition at line 718 of file mlKernel.h.

◆ getNegativeExtent()

template<typename KDATATYPE >
const ImageVector & ml::TKernel< KDATATYPE >::getNegativeExtent
inline

The extent of the kernel to both sides.

The sum of both +1 is the extent of the kernel. Using getNegativeExtent() as negative extent of an image and getPositiveExtent() as positive extent increment for the image then the kernel can be placed correctly on all normal image voxels without having voxel accesses out of range.

Definition at line 971 of file mlKernel.h.

◆ getNegativeValueSum()

template<typename KDATATYPE >
KDATATYPE ml::TKernel< KDATATYPE >::getNegativeValueSum

Return the sum of all negative kernel element values.

If kernel value table is empty then 0 is returned.

Definition at line 745 of file mlKernel.h.

◆ getPositiveExtent()

template<typename KDATATYPE >
const ImageVector & ml::TKernel< KDATATYPE >::getPositiveExtent
inline

See getNegativeExtent().

Definition at line 986 of file mlKernel.h.

◆ getPositiveValueSum()

template<typename KDATATYPE >
KDATATYPE ml::TKernel< KDATATYPE >::getPositiveValueSum

Return the sum of all positive kernel element values.

If kernel value table is empty then 0 is returned.

Definition at line 760 of file mlKernel.h.

◆ getSeparableCoordTab()

template<typename KDATATYPE >
const std::vector< ImageVector > & ml::TKernel< KDATATYPE >::getSeparableCoordTab

Returns the table of with all coordinates for filtering with separable kernels.

Definition at line 2087 of file mlKernel.h.

◆ getSeparableDimEntries()

template<typename KDATATYPE >
ImageVector ml::TKernel< KDATATYPE >::getSeparableDimEntries
inline

Returns a ImageVector with the number of entries of the separable kernel for the dimensions 0,...,5.

That means the n-th index contains the number of valueTab entries of row n, where n is from [0,...,5].

Definition at line 2018 of file mlKernel.h.

◆ getSeparableDimIndex()

template<typename KDATATYPE >
size_t ml::TKernel< KDATATYPE >::getSeparableDimIndex ( size_t  dim = 0) const

Returns the index to entries of valueTab or coordTab which are related to the 1-D separable kernel for the dimension dim where dim must be from [0,5].

Smaller values are clamped to 0, higher to 5. With the default parameter the index to the entries for the 1-D kernel of the x-dimension is returned.

Definition at line 2047 of file mlKernel.h.

References ML_PRINT_FATAL_ERROR, and ML_PROGRAMMING_ERROR.

◆ getSeparableOneDimExtents()

template<typename KDATATYPE >
ImageVector ml::TKernel< KDATATYPE >::getSeparableOneDimExtents
inline

Returns a vector where the components 0,...,5 contain the extent of the region spanned by the 6 separated 1-D kernels if the kernel is interpreted as a separable kernel.

Note that components of the extent are 0 for those dimensions where no entries are available.

Definition at line 2032 of file mlKernel.h.

◆ getTabSize()

template<typename KDATATYPE >
size_t ml::TKernel< KDATATYPE >::getTabSize
inline

Returns the current number of kernel elements.

Definition at line 664 of file mlKernel.h.

◆ getValueTab()

template<typename KDATATYPE >
const KDATATYPE * ml::TKernel< KDATATYPE >::getValueTab ( size_t  dim = 0) const
inline

Gets the table of kernel element values which are currently defined.

The size of the returned table is given by getTabSize(). In the case of separable filtering the subset of kernel elements for the pass dim can be requested.

Definition at line 696 of file mlKernel.h.

Referenced by ml::TKernel< KDATATYPE >::resizeKernel().

◆ getValueTabSum()

template<typename KDATATYPE >
KDATATYPE ml::TKernel< KDATATYPE >::getValueTabSum

Return the sum of all kernel element values.

Definition at line 705 of file mlKernel.h.

◆ indexToCoord()

template<typename KDATATYPE >
ImageVector ml::TKernel< KDATATYPE >::indexToCoord ( MLint  idx,
const ImageVector ext 
)
inlinestatic

Converts an index into an array with extents ext to a coordinate.

Definition at line 1020 of file mlKernel.h.

◆ isSeparable()

template<typename KDATATYPE >
bool ml::TKernel< KDATATYPE >::isSeparable
inline

Indicates whether the first 6 rows of the first kernel slice are interpreted as 1-D axes of a separable filter kernel; default is false.

Definition at line 2007 of file mlKernel.h.

◆ makeCircular()

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::makeCircular

Takes the current kernel, computes radii from the extents of the kernel and removes all kernel elements which are outside the ellipsoid defined by these radii.

Note that filter properties of kernel changes by this operation.

Definition at line 1625 of file mlKernel.h.

References ml::TVector6DBase< CompIntType >::c, ml::TVector6DBase< CompIntType >::t, ml::TVector6DBase< CompIntType >::u, ml::TVector6DBase< CompIntType >::x, ml::TVector6DBase< CompIntType >::y, and ml::TVector6DBase< CompIntType >::z.

◆ manipulateKernelElements()

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::manipulateKernelElements ( KernModifier  mode,
KDATATYPE  v 
)

Modify all kernel element values with the value v.

Definition at line 772 of file mlKernel.h.

References ML_BAD_PARAMETER, ML_PRINT_ERROR, ML_PROGRAMMING_ERROR, MLValueIs0WOM(), and MLValuesDifferWOM().

◆ mirror()

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::mirror ( int  dimension = -1)

Applies a point symmetric mirroring of all kernel elements.

The dimension specifies a mirroring dimension if in range [0,5], otherwise mirroring is applied in all dimensions. Default is -1.

Definition at line 1700 of file mlKernel.h.

◆ operator=()

template<typename KDATATYPE >
const TKernel< KDATATYPE > & ml::TKernel< KDATATYPE >::operator= ( const TKernel< KDATATYPE > &  kern)

Assignment operator. Sets current instance to contents of kern.

Definition at line 621 of file mlKernel.h.

◆ reset()

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::reset ( void  )

Reset kernel to construction state.

Definition at line 650 of file mlKernel.h.

◆ resizeKernel()

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::resizeKernel ( const ImageVector ext,
KDATATYPE  newVal = 0 
)

Resizes the kernel to a new state and tries to maintain the previous elements if possible.

Note that new kernel size may differ from desired one if empty areas are at border of the resized kernel so that only a smaller real kernel remains. Regions which are created newly get kernel elements with value newVal.

Definition at line 1529 of file mlKernel.h.

References ml::TVector6DBase< CompIntType >::c, ml::TKernel< KDATATYPE >::findIndex(), ml::TKernel< KDATATYPE >::getValueTab(), ml::TVector6DBase< CompIntType >::t, ml::TVector6DBase< CompIntType >::u, ml::TVector6DBase< CompIntType >::x, ml::TVector6DBase< CompIntType >::y, and ml::TVector6DBase< CompIntType >::z.

◆ setGauss()

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::setGauss ( const ImageVector ext)

◆ setKernel() [1/3]

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::setKernel ( const ImageVector ext,
const KDATATYPE *const  values = nullptr,
bool *const  mask = nullptr 
)

Defines a complete kernel matrix whose extents are defined by ext.

If desired the set of kernel values can be passed in values. Otherwise all kernel values are set to 1.0/(KDATATYPE)ext.compMul(), i.e. to the number of entries of the matrix. If desired a set of mask values can be specified. If mask[n] is true then tab[n] is included in the kernel; otherwise it's not part of the kernel. Internally the specified kernel matrix is handled as a table of kernel elements. Note that values and mask must have ext.compMul() elements if they are defined.

Definition at line 1403 of file mlKernel.h.

References ml::TVector< TVectorBase >::compMul(), ML_CALCULATION_ERROR, ML_NO_MEMORY, and ML_PRINT_FATAL_ERROR.

◆ setKernel() [2/3]

template<typename KDATATYPE >
template<typename KDATATYPE2 >
void ml::TKernel< KDATATYPE >::setKernel ( const ImageVector ext,
const KDATATYPE2 *const  xaxis,
const KDATATYPE2 *const  yaxis,
const KDATATYPE2 *const  zaxis,
const KDATATYPE2 *const  caxis,
const KDATATYPE2 *const  taxis,
const KDATATYPE2 *const  uaxis,
bool  normalize 
)
inline

Defines a complete kernel matrix whose extents are defined by ext.

The values of the kernel elements are products of the corresponding values along the six axis given as parameters. This is a convenient way to build a kernel from separated axis. If desired the kernel is normalized. Note: The following function definition must be implemented in the class definition See BUG: LNK2001 on Member Function When Use Nested Class Template, Article ID: Q128789

Definition at line 296 of file mlKernel.h.

References ml::TVector6DBase< CompIntType >::c, ml::TVector< TVectorBase >::compMul(), ML_FATAL_MEMORY_ERROR, ml::TVector6DBase< CompIntType >::t, ml::TVector6DBase< CompIntType >::u, ml::TVector6DBase< CompIntType >::x, ml::TVector6DBase< CompIntType >::y, and ml::TVector6DBase< CompIntType >::z.

◆ setKernel() [3/3]

template<typename KDATATYPE >
std::string ml::TKernel< KDATATYPE >::setKernel ( const std::string &  kernString)

Defines elements and values of the kernel matrix by a string.

The string needs to have the following format:
(x_0, y_0, z_0, c_0, t_0, u_0):v_0
...
(x_n, y_n, z_n, c_n, t_n, u_n):v_n
where the coordinates left from ':' specify the 6d coordinate of the kernel element; the value v_x right from ':' specifies the value of the kernel element. Only one coordinate entry is scanned per line. So big kernels with a few elements can be set easily. As long as lines with kernel elements are found elements are set in the kernel table. Return string is empty on successful scan. On errors it contains the number of error lines.

A second way to specify more kernel elements at once is with the following string line format:
(*, y_0, z_0, c_0, t_0, u_0):x_0, ... ,x_n
...
(*, y_n, z_n, c_n, t_n, u_n):y_n, ... ,y_n
So all kernel elements of a row are found in a string line. Note that the x coordinates becomes invalid and must set as an asterisk. Empty elements in the kernel can be left empty before between and after commas.

Definition at line 1255 of file mlKernel.h.

References ML_FATAL_MEMORY_ERROR.

Referenced by itk::MLITKStructuringElementBase< TPixel, VDimension, TAllocator, SuperClss >::setKernelFromString().

◆ setPartialKernel()

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::setPartialKernel ( size_t  numElems,
ImageVector *const  coords,
KDATATYPE *const  values = nullptr 
)

Defines a set of local kernel coordinates and optionally a set of values which define the kernel elements.

numElems defines the number of coordinates. If desired the corresponding set of kernel values can be passed in values. Otherwise all kernel values are set to 1.0/(KDATATYPE)_tabSize. Note that coords and values have to contain numElems entries if passed.

Definition at line 1070 of file mlKernel.h.

◆ setSeparable()

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::setSeparable ( bool  isSeparableVal)
inline

Set/unset a flag to indicate that the first 6 rows of the first kernel slice is considered as 1-D axes of a separable filter kernel.

Note that this flag only denotes how applications shall interpret this kernel; however it does NOT change any behaviour of this class.

Definition at line 1993 of file mlKernel.h.

◆ setSeparableKernel()

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::setSeparableKernel ( const std::vector< typename std::vector< KDATATYPE > > &  separableRows)

Create kernel coordinate and value tables in separable table format, that means a 2-D kernel where each rows describes the elements of 1-D kernels.

At most 6 rows make sense, because the maximum kernel dimension is 6. It is legal to leave out any axis by passing empty vectors to define lower dimensional separable kernels. The separability flag is set to true.

Definition at line 1476 of file mlKernel.h.

References ml::TVector6DBase< CompIntType >::x, and ml::TVector6DBase< CompIntType >::y.


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