Image Component Library (ICL)
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)
 create an integer based kernel More...
 
 ConvolutionKernel (float *data, const utils::Size &size, bool deepCopy=true)
 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

◆ fixedType

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

◆ ConvolutionKernel() [1/5]

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

creates an empty null kernel

◆ ConvolutionKernel() [2/5]

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

crates a copied kernel

shallow wrapped kernels are copied shallowly !

◆ ConvolutionKernel() [3/5]

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

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)

◆ ConvolutionKernel() [4/5]

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

create a float valued kernel

◆ ConvolutionKernel() [5/5]

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

create a fixed kernel (optionally as float kernel)

◆ ~ConvolutionKernel()

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

Destructor.

Member Function Documentation

◆ detach()

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

ensures shallow copied data is copied deeply

◆ getDim()

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

returns kernels width * height

◆ getFactor()

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

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

◆ getFixedType()

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

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

◆ getFloatData() [1/2]

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

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

◆ getFloatData() [2/2]

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

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

◆ getHeight()

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

returns the kernels height

◆ getIntData() [1/2]

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

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

◆ getIntData() [2/2]

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

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

◆ getSize()

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

returns the kernels size

◆ getWidth()

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

returns the kernels width

◆ isFloat()

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

returns whether this kernel has float data

◆ isNull()

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

return whether idata or fdata is not null

◆ operator=()

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

Assignment operator.

Shallow-wrapped kernels are copied shallowly

◆ toFloat()

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

converts internal idata to float data regarding 'factor'

◆ toInt()

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

◆ factor

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

scaling factor for integer kernels

◆ fdata

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

float data pointer

◆ ft

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

fixed type set

◆ idata

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

int data pointer

◆ isnull

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

is already initialized

◆ owned

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

is data owned

◆ size

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

associated size


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