Image Component Library (ICL)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Private Attributes | List of all members
icl::filter::ConvolutionKernel Struct Reference

Utility struct for managing convolution kernel data. More...

#include <ConvolutionKernel.h>

Public Types

enum  fixedType {
  gauss3x3 =0, gauss5x5 =10, sobelX3x3 =1, sobelX5x5 =11,
  sobelY3x3 =2, sobelY5x5 =12, laplace3x3 =3, laplace5x5 =13,
  custom
}
 this enum contains several predefined convolution kernel types More...
 

Public Member Functions

 ConvolutionKernel ()
 creates an empty null kernel More...
 
 ConvolutionKernel (const ConvolutionKernel &other)
 crates a copied kernel More...
 
 ConvolutionKernel (int *data, const utils::Size &size, int factor=1, bool deepCopy=true) throw (utils::InvalidSizeException)
 create an integer based kernel More...
 
 ConvolutionKernel (float *data, const utils::Size &size, bool deepCopy=true) throw (utils::InvalidSizeException)
 create a float valued kernel More...
 
 ConvolutionKernel (fixedType t, bool useFloats=false)
 create a fixed kernel (optionally as float kernel) More...
 
 ~ConvolutionKernel ()
 Destructor. More...
 
ConvolutionKerneloperator= (const ConvolutionKernel &other)
 Assignment operator. More...
 
void toFloat ()
 converts internal idata to float data regarding 'factor' More...
 
void toInt (bool force=false)
 converts fdata to idata if possible and/or if force flag is true More...
 
int getDim () const
 returns kernels width * height More...
 
const utils::SizegetSize () const
 returns the kernels size More...
 
int getWidth () const
 returns the kernels width More...
 
int getHeight () const
 returns the kernels height More...
 
bool isFloat () const
 returns whether this kernel has float data More...
 
const float * getFloatData () const
 returns the kernels float data pointer (const) (which may be 0) More...
 
float * getFloatData ()
 returns the kernels float data pointer (which may be 0) More...
 
const int * getIntData () const
 returns the kernels int data pointer (const) (which may be 0) More...
 
int * getIntData ()
 returns the kernels int data pointer (which may be 0) More...
 
int getFactor () const
 returns the kernels scaling factor (only used if its an integer kernel) More...
 
bool isNull () const
 return whether idata or fdata is not null More...
 
fixedType getFixedType () const
 returns the kernels fixed type (necessary for IPP-optimization) More...
 
void detach ()
 ensures shallow copied data is copied deeply More...
 

Private Attributes

utils::Size size
 associated size More...
 
float * fdata
 float data pointer More...
 
int * idata
 int data pointer More...
 
int factor
 scaling factor for integer kernels More...
 
bool isnull
 is already initialized More...
 
bool owned
 is data owned More...
 
fixedType ft
 fixed type set More...
 

Detailed Description

Utility struct for managing convolution kernel data.

This structure provides a shallow as well as deep wrapper for int- and float-pointers into ConvolutionKernel-instances. Convolution Kernels can be float- or integer valued.

copies of shallow copied instances are shallow!

Member Enumeration Documentation

this enum contains several predefined convolution kernel types

kernelSobleX

The sobel x filter is a combined filter. It performs a symmetrical border filter operation in x-direction, followed by a smoothing operation in y-direction:

                ---------     ---        
               | 1  0 -1 |   | 1 |    ---------
kernelSobelX = | 2  0 -2 | = | 2 | * | 1  0 -1 |
               | 1  0 -1 |   | 1 |    ---------
                ---------     ---

kernelSobelY

The sobel y filter is essentially equal to the sobel y filter. The border detection will run in y-direction, and the smoothing x-direction.

                ---------     ---        
               | 1  2  1 |   | 1 |    ---------
kernelSobelY = | 0  0  0 | = | 0 | * | 1  2  1 |
               |-1 -2 -1 |   |-1 |    ---------
                ---------     ---

kernelGauss3x3

This is a 3x3-Pixel approximation of a 2D Gaussian. It is separable into smoothing filters in x- and y-direction.

                         ---------     ---        
                        | 1  2  1 |   | 1 |    ---------
kernelGauss3x3 = 1/16 * | 2  4  2 | = | 2 | * | 1  2  1 | * (1/4) *(1/4) 
                        | 1  2  1 |   | 1 |    ---------
                         ---------     ---

kernelGauss5x5

This is a 5x5-Pixel approximation of a 2D Gaussian. It is separable into smoothing filters in x- and y-direction.

                          ----------------- 
                         | 2   7  12  7  2 |
                         | 7  31  52 31  7 |
kernelGauss5x5 = 1/571 * |12  52 127 52 12 |
                         | 7  31  52 31  7 |
                         | 2   7  12  7  2 |
                          -----------------

kernelLaplace

The Laplacian kernel is a discrete approximation of the 2nd derivation of a 2D function.

                 --------- 
                | 1  1  1 |
kernelLaplace = | 1 -8  1 |
                | 1  1  1 |
                 --------- 
Enumerator
gauss3x3 

3x3 approximation of a Gaussian

gauss5x5 

5x5 approximation of a Gaussian

sobelX3x3 

3x3 sobel x filter

sobelX5x5 

5x5 sobel x filter

sobelY3x3 

3x3 sobel y filter

sobelY5x5 

5x5 sobel y filter

laplace3x3 

3x3 approximation of the 2nd derivation

laplace5x5 

5x5 approximation of the 2nd derivation

custom 

Constructor & Destructor Documentation

icl::filter::ConvolutionKernel::ConvolutionKernel ( )

creates an empty null kernel

icl::filter::ConvolutionKernel::ConvolutionKernel ( const ConvolutionKernel other)

crates a copied kernel

shallow wrapped kernels are copied shallowly !

icl::filter::ConvolutionKernel::ConvolutionKernel ( int *  data,
const utils::Size size,
int  factor = 1,
bool  deepCopy = true 
)
throw (utils::InvalidSizeException
)

create an integer based kernel

factor can be used to rescale convolution results by given factor: Result(x,y) = ( src *(x,y)* kernel ) / factor where *(x,y)* is a convolution at location (x,y)

icl::filter::ConvolutionKernel::ConvolutionKernel ( float *  data,
const utils::Size size,
bool  deepCopy = true 
)
throw (utils::InvalidSizeException
)

create a float valued kernel

icl::filter::ConvolutionKernel::ConvolutionKernel ( fixedType  t,
bool  useFloats = false 
)

create a fixed kernel (optionally as float kernel)

icl::filter::ConvolutionKernel::~ConvolutionKernel ( )

Destructor.

Member Function Documentation

void icl::filter::ConvolutionKernel::detach ( )

ensures shallow copied data is copied deeply

int icl::filter::ConvolutionKernel::getDim ( ) const
inline

returns kernels width * height

int icl::filter::ConvolutionKernel::getFactor ( ) const
inline

returns the kernels scaling factor (only used if its an integer kernel)

fixedType icl::filter::ConvolutionKernel::getFixedType ( ) const
inline

returns the kernels fixed type (necessary for IPP-optimization)

const float* icl::filter::ConvolutionKernel::getFloatData ( ) const
inline

returns the kernels float data pointer (const) (which may be 0)

float* icl::filter::ConvolutionKernel::getFloatData ( )
inline

returns the kernels float data pointer (which may be 0)

int icl::filter::ConvolutionKernel::getHeight ( ) const
inline

returns the kernels height

const int* icl::filter::ConvolutionKernel::getIntData ( ) const
inline

returns the kernels int data pointer (const) (which may be 0)

int* icl::filter::ConvolutionKernel::getIntData ( )
inline

returns the kernels int data pointer (which may be 0)

const utils::Size& icl::filter::ConvolutionKernel::getSize ( ) const
inline

returns the kernels size

int icl::filter::ConvolutionKernel::getWidth ( ) const
inline

returns the kernels width

bool icl::filter::ConvolutionKernel::isFloat ( ) const
inline

returns whether this kernel has float data

bool icl::filter::ConvolutionKernel::isNull ( ) const
inline

return whether idata or fdata is not null

ConvolutionKernel& icl::filter::ConvolutionKernel::operator= ( const ConvolutionKernel other)

Assignment operator.

Shallow-wrapped kernels are copied shallowly

void icl::filter::ConvolutionKernel::toFloat ( )

converts internal idata to float data regarding 'factor'

void icl::filter::ConvolutionKernel::toInt ( bool  force = false)

converts fdata to idata if possible and/or if force flag is true

'possible' means that all float values do not show decimals

Member Data Documentation

int icl::filter::ConvolutionKernel::factor
private

scaling factor for integer kernels

float* icl::filter::ConvolutionKernel::fdata
private

float data pointer

fixedType icl::filter::ConvolutionKernel::ft
private

fixed type set

int* icl::filter::ConvolutionKernel::idata
private

int data pointer

bool icl::filter::ConvolutionKernel::isnull
private

is already initialized

bool icl::filter::ConvolutionKernel::owned
private

is data owned

utils::Size icl::filter::ConvolutionKernel::size
private

associated size


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