MeVisLabToolboxReference
ml::TKernel< KDATATYPE > Class Template Reference

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

#include <mlKernel.h>

List of all members.

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.
 TKernel (const TKernel &kern)
 Copy constructor. Builds a kernel with contents of kern.
virtual ~TKernel ()
 Destructor. Cleans up and removes instance of kernel.
const TKerneloperator= (const TKernel &kern)
 Assignment operator. Sets current instance to contents of kern.
void reset ()
 Reset kernel to construction state.
size_t getTabSize () const
 Returns the current number of kernel elements.
const ImageVectorgetCoordTab (size_t dim=0) const
 Gets a table of coordinates pointing to all kernel elements which are currently defined.
const KDATATYPE * getValueTab (size_t dim=0) const
 Gets the table of kernel element values which are currently defined.
KDATATYPE getValueTabSum () const
 Return the sum of all kernel element values.
KDATATYPE getMinValue () const
 Return the minimum value of all kernel element values If kernel value table is empty then 0 is returned.
KDATATYPE getMaxValue () const
 Return the maximum value of all kernel element values If kernel value table is empty then 1 is returned.
KDATATYPE getNegativeValueSum () const
 Return the sum of all negative kernel element values.
KDATATYPE getPositiveValueSum () const
 Return the sum of all positive kernel element values.
void manipulateKernelElements (KernModifier mode, KDATATYPE v)
 Modify all kernel element values with the value v.
const ImageVectorgetExtent () const
 Returns the kernel extents in 6D.
const ImageVectorgetNegativeExtent () const
 The extent of the kernel to both sides.
const ImageVectorgetPositiveExtent () const
 See getNegativeExtent().
MLint findIndex (const ImageVector &pos) const
 Return index to kernel element if it exists; otherwise return -1.
void setPartialKernel (size_t numElems, ImageVector *const coords, KDATATYPE *const values=NULL)
 Defines a set of local kernel coordinates and optionally a set of values which define the kernel elements.
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:
.
std::string setKernel (const std::string &kernString)
 Defines elements and values of the kernel matrix by a string.
void setKernel (const ImageVector &ext, const KDATATYPE *const values=NULL, bool *const mask=NULL)
 Defines a complete kernel matrix whose extents are defined by ext.
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.
void setSeparableKernel (const std::vector< ML_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.
void resizeKernel (const ImageVector &ext, KDATATYPE newVal=0)
 Resizes the kernel to a new state and tries to maintain the previous elements if possible.
void fillUndefinedElements (KDATATYPE newVal=0)
 Fill all undefined kernel elements with newVal.
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.
void mirror (int dimension=-1)
 Applies a point symmetric mirroring of all kernel elements.
void setGauss (const ImageVector &ext)
 Replaces the current kernel by a normalized gauss kernel.
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.
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.
ImageVector getSeparableDimEntries () const
 Returns a ImageVector with the number of entries of the separable kernel for the dimensions 0,...,5.
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.
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].
const std::vector< ImageVector > & getSeparableCoordTab () const
 Returns the table of with all coordinates for filtering with separable kernels.

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.
static MLint coordToIndex (const ImageVector &p, const ImageVector &size)
 Converts the coordinate into the kernel with extents size to an index.
static ImageVector indexToCoord (MLint idx, const ImageVector &ext)
 Converts an index into an array with extents ext to a coordinate.
static ImageVector calculateNegativeExtentFromExtent (const ImageVector &ext)
 Calculate the negative extent of a kernel from a kernel extent.
static ImageVector calculatePositiveExtentFromExtent (const ImageVector &ext)
 Calculate the positive extent of a kernel from a kernel extent.
static MLldouble binomialcoeff (MLint n, MLint k)
 Calculate binomial coefficients for (n) (k)
static std::vector< KDATATYPE > get1DGauss (size_t numSamples, bool normalize=true)
 Returns a vector with numSample values binomial coefficients.

Protected Member Functions

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

Deprecated methods.

KDATATYPE getNegValueSum () const
KDATATYPE getPosValueSum () const
const ImageVectorgetExt () const
const ImageVectorgetNegExt () const
const ImageVectorgetPosExt () const
static ImageVector calcNegExtFromExt (const ImageVector &ext)
static ImageVector calcPosExtFromExt (const ImageVector &ext)

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 (ML carrier types) 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 70 of file mlKernel.h.


Member Enumeration Documentation

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


Constructor & Destructor Documentation

template<typename KDATATYPE >
ml::TKernel< KDATATYPE >::TKernel ( ) [inline]

Constructor. Builds an empty kernel.

Definition at line 595 of file mlKernel.h.

References ML_TRACE_IN.

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

Copy constructor. Builds a kernel with contents of kern.

Definition at line 606 of file mlKernel.h.

References ML_TRACE_IN.

template<typename KDATATYPE >
ml::TKernel< KDATATYPE >::~TKernel ( ) [inline, virtual]

Destructor. Cleans up and removes instance of kernel.

Definition at line 618 of file mlKernel.h.

References ML_CATCH, ML_TRACE_IN, and ML_TRY.


Member Function Documentation

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

References ml::ImageVector, ML_CATCH_BLOCK, ML_CHECK, ML_CHECK_NEW, ML_DELETE_ARRAY, ML_NO_MEMORY, ML_PRINT_FATAL_ERROR, ML_TRACE_IN, and ML_TRY.

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

References ml::compMax(), ml::ImageVector, ML_CATCH_RETHROW, ML_PRINT_FATAL_ERROR, ML_PROGRAMMING_ERROR, ML_TRACE_IN, and ML_TRY.

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::_clearTables ( ) [protected]

Clear all internal (dynamic) tables.

Definition at line 2034 of file mlKernel.h.

References ML_CATCH_RETHROW, ML_DELETE_ARRAY, ML_TRACE_IN, and ML_TRY.

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::_init ( ) [protected]

Initialization. Should be called only by constructors.

Definition at line 2005 of file mlKernel.h.

References ML_TRACE_IN.

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::_invalidateSeparableInfos ( ) [protected]

Invalidate separability information.

Definition at line 2306 of file mlKernel.h.

References ML_TRACE_IN_TIME_CRITICAL.

template<typename KDATATYPE >
void ml::TKernel< KDATATYPE >::_validateSeparabilityInfos ( ) const [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 2321 of file mlKernel.h.

References ml::ImageVector, ML_CATCH_BLOCK, ML_TRACE_IN, ML_TRY, and ml::TVector6DBase< CompIntType >::x.

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

Calculate binomial coefficients for (n) (k)

Definition at line 1870 of file mlKernel.h.

References ML_TRACE_IN.

template<typename KDATATYPE>
static ImageVector ml::TKernel< KDATATYPE >::calcNegExtFromExt ( const ImageVector ext) [inline, static]
Deprecated:
Use calculateNegativeExtentFromExtent instead.

Definition at line 471 of file mlKernel.h.

template<typename KDATATYPE>
static ImageVector ml::TKernel< KDATATYPE >::calcPosExtFromExt ( const ImageVector ext) [inline, static]
Deprecated:
Use calculatePositiveExtentFromExtent instead.

Definition at line 475 of file mlKernel.h.

template<typename KDATATYPE >
ImageVector ml::TKernel< KDATATYPE >::calculateNegativeExtentFromExtent ( const ImageVector ext) [inline, static]

Calculate the negative extent of a kernel from a kernel extent.

Definition at line 1083 of file mlKernel.h.

References ml::ImageVector, and ML_TRACE_IN.

template<typename KDATATYPE >
ImageVector ml::TKernel< KDATATYPE >::calculatePositiveExtentFromExtent ( const ImageVector ext) [inline, static]

Calculate the positive extent of a kernel from a kernel extent.

Definition at line 1093 of file mlKernel.h.

References ml::ImageVector, and ML_TRACE_IN.

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

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

References ML_TRACE_IN.

template<typename KDATATYPE >
MLint ml::TKernel< KDATATYPE >::coordToIndex ( const ImageVector p,
const ImageVector size 
) [inline, static]

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

Definition at line 1061 of file mlKernel.h.

References ML_TRACE_IN.

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

Fill all undefined kernel elements with newVal.

Definition at line 1678 of file mlKernel.h.

References ml::ImageVector, ML_CATCH_RETHROW, ML_TRACE_IN, and ML_TRY.

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

References ML_TRACE_IN.

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

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

References ML_CATCH_RETHROW, ML_TRACE_IN, and ML_TRY.

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

References ML_TRACE_IN_TIME_CRITICAL.

template<typename KDATATYPE>
const ImageVector& ml::TKernel< KDATATYPE >::getExt ( ) const [inline]
Deprecated:
Use getExtent() instead.

Definition at line 459 of file mlKernel.h.

template<typename KDATATYPE >
const ImageVector & ml::TKernel< KDATATYPE >::getExtent ( ) const [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 995 of file mlKernel.h.

References ML_TRACE_IN_TIME_CRITICAL.

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

References ml::ImageVector, ML_CATCH_RETHROW, ML_TRACE_IN, ML_TRY, MLsnprintf, and snprintf.

template<typename KDATATYPE >
KDATATYPE ml::TKernel< KDATATYPE >::getMaxValue ( ) const

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

Definition at line 762 of file mlKernel.h.

References ML_TRACE_IN.

template<typename KDATATYPE >
KDATATYPE ml::TKernel< KDATATYPE >::getMinValue ( ) const

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

Definition at line 747 of file mlKernel.h.

References ML_TRACE_IN.

template<typename KDATATYPE >
const ImageVector & ml::TKernel< KDATATYPE >::getNegativeExtent ( ) const [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 1015 of file mlKernel.h.

References ML_TRACE_IN_TIME_CRITICAL.

template<typename KDATATYPE >
KDATATYPE ml::TKernel< KDATATYPE >::getNegativeValueSum ( ) const

Return the sum of all negative kernel element values.

If kernel value table is empty then 0 is returned.

Definition at line 778 of file mlKernel.h.

References ML_TRACE_IN.

template<typename KDATATYPE>
const ImageVector& ml::TKernel< KDATATYPE >::getNegExt ( ) const [inline]
Deprecated:
Use getNegativeExtent() instead.

Definition at line 463 of file mlKernel.h.

template<typename KDATATYPE>
KDATATYPE ml::TKernel< KDATATYPE >::getNegValueSum ( ) const [inline]
Deprecated:
Use getNegativeValueSum() instead.

Definition at line 451 of file mlKernel.h.

template<typename KDATATYPE>
const ImageVector& ml::TKernel< KDATATYPE >::getPosExt ( ) const [inline]
Deprecated:
Use getPositiveExtent() instead.

Definition at line 467 of file mlKernel.h.

template<typename KDATATYPE >
const ImageVector & ml::TKernel< KDATATYPE >::getPositiveExtent ( ) const [inline]

See getNegativeExtent().

Definition at line 1032 of file mlKernel.h.

References ML_TRACE_IN_TIME_CRITICAL.

template<typename KDATATYPE >
KDATATYPE ml::TKernel< KDATATYPE >::getPositiveValueSum ( ) const

Return the sum of all positive kernel element values.

If kernel value table is empty then 0 is returned.

Definition at line 795 of file mlKernel.h.

References ML_TRACE_IN.

template<typename KDATATYPE>
KDATATYPE ml::TKernel< KDATATYPE >::getPosValueSum ( ) const [inline]
Deprecated:
Use getPositiveValueSum() instead.

Definition at line 455 of file mlKernel.h.

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

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

Definition at line 2289 of file mlKernel.h.

References ML_CATCH_RETHROW, ML_TRACE_IN, and ML_TRY.

template<typename KDATATYPE >
ImageVector ml::TKernel< KDATATYPE >::getSeparableDimEntries ( ) const [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 2210 of file mlKernel.h.

References ML_TRACE_IN.

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

References ML_CATCH_RETHROW, ML_PRINT_FATAL_ERROR, ML_PROGRAMMING_ERROR, ML_TRACE_IN, and ML_TRY.

template<typename KDATATYPE >
ImageVector ml::TKernel< KDATATYPE >::getSeparableOneDimExtents ( ) const [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 2226 of file mlKernel.h.

References ML_TRACE_IN.

template<typename KDATATYPE >
size_t ml::TKernel< KDATATYPE >::getTabSize ( ) const [inline]

Returns the current number of kernel elements.

Definition at line 685 of file mlKernel.h.

References ML_TRACE_IN_TIME_CRITICAL.

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

References ML_TRACE_IN_TIME_CRITICAL.

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

template<typename KDATATYPE >
KDATATYPE ml::TKernel< KDATATYPE >::getValueTabSum ( ) const

Return the sum of all kernel element values.

Definition at line 732 of file mlKernel.h.

References ML_TRACE_IN.

template<typename KDATATYPE >
ImageVector ml::TKernel< KDATATYPE >::indexToCoord ( MLint  idx,
const ImageVector ext 
) [inline, static]

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

Definition at line 1072 of file mlKernel.h.

References ML_TRACE_IN.

template<typename KDATATYPE >
bool ml::TKernel< KDATATYPE >::isSeparable ( ) const [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 2197 of file mlKernel.h.

References ML_TRACE_IN_TIME_CRITICAL.

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

References ml::ImageVector, ML_CATCH_RETHROW, ML_DELETE_ARRAY, ML_TRACE_IN, and ML_TRY.

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

Modify all kernel element values with the value v.

Definition at line 809 of file mlKernel.h.

References ML_BAD_PARAMETER, ML_CATCH_RETHROW, ML_PRINT_ERROR, ML_PROGRAMMING_ERROR, ML_TRACE_IN, ML_TRY, MLValueIs0WOM(), and MLValuesDifferWOM().

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

References ml::ImageVector, ML_CATCH_RETHROW, ML_DELETE_ARRAY, ML_TRACE_IN, and ML_TRY.

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

References ML_CATCH_RETHROW, ML_TRACE_IN, and ML_TRY.

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

Reset kernel to construction state.

Definition at line 666 of file mlKernel.h.

References ML_CATCH_RETHROW, ML_TRACE_IN, and ML_TRY.

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

References ml::TKernel< KDATATYPE >::findIndex(), ml::TKernel< KDATATYPE >::getValueTab(), ml::ImageVector, ML_CATCH_RETHROW, ML_TRACE_IN, and ML_TRY.

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

Replaces the current kernel by a normalized gauss kernel.

Definition at line 1965 of file mlKernel.h.

References ml::ImageVector, ML_CATCH_BLOCK, ML_CHECK, ML_TRACE_IN, and ML_TRY.

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

References ml::ImageVector, ML_CATCH_BLOCK, ML_CHECK, ML_FATAL_MEMORY_ERROR, ML_TRACE_IN, ML_TRY, MLsnprintf, and MLsscanf.

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

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

References ml::ImageVector, ML_CALCULATION_ERROR, ML_CATCH_RETHROW, ML_CHECK_NEW, ML_NO_MEMORY, ML_PRINT_FATAL_ERROR, ML_TRACE_IN, and ML_TRY.

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

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

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

References ml::ImageVector, ML_CATCH_RETHROW, ML_CHECK_NEW, ML_TRACE_IN, and ML_TRY.

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

References ML_CATCH_RETHROW, ML_TRACE_IN_TIME_CRITICAL, and ML_TRY.

template<typename KDATATYPE>
void ml::TKernel< KDATATYPE >::setSeparableKernel ( const std::vector< ML_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 1561 of file mlKernel.h.

References ml::ImageVector, ML_CATCH_RETHROW, ML_TRACE_IN, and ML_TRY.


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