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 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... | |
ConvolutionKernel & | operator= (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::Size & | getSize () 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... | |
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 | ---------
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 |
||
) |
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 |
||
) |
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.
void icl::filter::ConvolutionKernel::detach | ( | ) |
ensures shallow copied data is copied deeply
|
inline |
returns kernels width * height
|
inline |
returns the kernels scaling factor (only used if its an integer kernel)
|
inline |
returns the kernels fixed type (necessary for IPP-optimization)
|
inline |
returns the kernels float data pointer (const) (which may be 0)
|
inline |
returns the kernels float data pointer (which may be 0)
|
inline |
returns the kernels height
|
inline |
returns the kernels int data pointer (const) (which may be 0)
|
inline |
returns the kernels int data pointer (which may be 0)
|
inline |
returns the kernels size
|
inline |
returns the kernels width
|
inline |
returns whether this kernel has float data
|
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
|
private |
scaling factor for integer kernels
|
private |
float data pointer
|
private |
fixed type set
|
private |
int data pointer
|
private |
is already initialized
|
private |
is data owned
|
private |
associated size