Image Component Library (ICL)
|
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 | |
ConvolutionKernel (const ConvolutionKernel &other) | |
crates a copied kernel | |
ConvolutionKernel (int *data, const utils::Size &size, int factor=1, bool deepCopy=true) throw (utils::InvalidSizeException) | |
create an integer based kernel | |
ConvolutionKernel (float *data, const utils::Size &size, bool deepCopy=true) throw (utils::InvalidSizeException) | |
create a float valued kernel | |
ConvolutionKernel (fixedType t, bool useFloats=false) | |
create a fixed kernel (optionally as float kernel) | |
~ConvolutionKernel () | |
Destructor. | |
ConvolutionKernel & | operator= (const ConvolutionKernel &other) |
Assignment operator. | |
void | toFloat () |
converts internal idata to float data regarding 'factor' | |
void | toInt (bool force=false) |
converts fdata to idata if possible and/or if force flag is true | |
int | getDim () const |
returns kernels width * height | |
const utils::Size & | getSize () const |
returns the kernels size | |
int | getWidth () const |
returns the kernels width | |
int | getHeight () const |
returns the kernels height | |
bool | isFloat () const |
returns whether this kernel has float data | |
const float * | getFloatData () const |
returns the kernels float data pointer (const) (which may be 0) | |
float * | getFloatData () |
returns the kernels float data pointer (which may be 0) | |
const int * | getIntData () const |
returns the kernels int data pointer (const) (which may be 0) | |
int * | getIntData () |
returns the kernels int data pointer (which may be 0) | |
int | getFactor () const |
returns the kernels scaling factor (only used if its an integer kernel) | |
bool | isNull () const |
return whether idata or fdata is not null | |
fixedType | getFixedType () const |
returns the kernels fixed type (necessary for IPP-optimization) | |
void | detach () |
ensures shallow copied data is copied deeply | |
Private Attributes | |
utils::Size | size |
associated size | |
float * | fdata |
float data pointer | |
int * | idata |
int data pointer | |
int | factor |
scaling factor for integer kernels | |
bool | isnull |
is already initialized | |
bool | owned |
is data owned | |
fixedType | ft |
fixed type set |
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!
this enum contains several predefined convolution kernel types
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 | --------- --------- ---
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 | --------- --------- ---
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 | --------- --------- ---
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 | -----------------
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 | ---------
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)
Destructor.
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
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
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
associated size