libtpcimgp
 All Data Structures Files Functions Variables Typedefs Defines
Functions
include/imgfilter.h File Reference
#include <img.h>
Include dependency graph for imgfilter.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int imgFillGaussKernel (float **kernel, float stdev, int size)
int imgConvolute2D (float ***data, float **buffer, int frame, int width, int height, float **kernel, int size, int border, int verbose, char *errmsg)
int imgGaussianFilter (IMG *img, float gauss_sd, int size, int border, int verbose, char *errmsg)
float ** mallocMatrix (float w, float h)
float ** imgGaussKernel (int size)
 Make a gaussian convolution kernel.
void imgFreeKernel (float **kernel, int size)
 Free a convolution kernel.
void imgConvoluteData (float ***data, float **buffer, int frame, int width, int height, float **kernel, int size)
 Perform a convolution operation on float data.
int imgConvolute (IMG *img, int frame, int plane, float **kernel, int size)
 Perform a convolution operation on image.

Function Documentation

int imgConvolute ( IMG *  img,
int  frame,
int  plane,
float **  kernel,
int  size 
)

Perform a convolution operation on image.

The bordering size/2 pixels of the image do not containg valid data. imgConvolute is quite memory efficient. Only (img->dimx+size)*size*sizeof(float) bytes are consumed by a temporary buffer. When processing multiple planes/frames/images with equal width and kernel size, efficiency can be improved further by allocating the temporary buffer yourself and calling imgConvoluteData directly.

Parameters:
imgimage
frameframe to perform operation on
planeplane to perform operation on
kernelconvolution kernel
sizeconvolution kernel size
Precondition:
size must be smaller than img->dimx and img->dimy
Returns:
nonzero in case of (malloc) error

Definition at line 491 of file imgfilter.c.

References imgConvoluteData(), and mallocMatrix().

Here is the call graph for this function:

int imgConvolute2D ( float ***  data,
float **  buffer,
int  frame,
int  width,
int  height,
float **  kernel,
int  size,
int  border,
int  verbose,
char *  errmsg 
)

Perform a convolution operation on one image matrix.

Returns:
Returns 0 when successful, otherwise <>0.
Parameters:
dataImage matrix data[height][width][frame]
bufferTemporary preallocated memory buffer[size][width+size-1]
frameframe [0..dimt] of data matrix which is processed
widthWidth of image matrix (dimx)
heightHeight of image matrix (dimy)
kernelConvolution kernel[size][size] matrix
sizeConvolution kernel size; must be an odd number and >=3
borderFill borders with zero (0) or with closest image pixel (<>0)
verboseVerbose level; if zero, then only warnings are printed into stderr
errmsgPointer to error message, at least 128 characters; NULL, if not needed

Definition at line 101 of file imgfilter.c.

Referenced by imgGaussianFilter().

void imgConvoluteData ( float ***  data,
float **  buffer,
int  frame,
int  width,
int  height,
float **  kernel,
int  size 
)

Perform a convolution operation on float data.

Parameters:
datadata in format float[y][x][frame]
buffertemporary buffer to use. Size must be float[size][data width+size]
frameframe to extract from data
widthwidth of the image
heightheight of the image
kernelconvolution kernel
sizeconvolution kernel size

Definition at line 418 of file imgfilter.c.

Referenced by imgConvolute().

int imgFillGaussKernel ( float **  kernel,
float  stdev,
int  size 
)

Make a gaussian convolution kernel.

Returns:
Returns 0 when successful, otherwise <>0.
Parameters:
kernelGaussian convolution kernel matrix[size][size], filled here
stdevGaussian S.D. in pixels (decimals are ok)
sizeKernel dimension

Definition at line 52 of file imgfilter.c.

Referenced by imgGaussianFilter().

void imgFreeKernel ( float **  kernel,
int  size 
)

Free a convolution kernel.

Parameters:
kernelthe convolution kernel
sizesize of the kernel

Definition at line 401 of file imgfilter.c.

int imgGaussianFilter ( IMG *  img,
float  gauss_sd,
int  size,
int  border,
int  verbose,
char *  errmsg 
)

Apply Gaussian filter to whole dynamic image in IMG struct.

Returns:
If an error is encountered, function returns a non-zero value. Otherwise 0 is returned.
Parameters:
imgImage data to be processed; data is overwritten with filtered image
gauss_sdGaussian S.D. in pixels (decimals are ok)
sizeGaussian kernel size (must be odd number); typically 6*gauss_sd is sufficient
borderIn filtering, fill borders with zero (0) or with closest image pixel (<>0)
verboseVerbose level; if zero, then only warnings are printed into stderr
errmsgPointer to error message, at least 128 characters; NULL, if not needed

Definition at line 251 of file imgfilter.c.

References imgConvolute2D(), and imgFillGaussKernel().

Here is the call graph for this function:

float** imgGaussKernel ( int  size)

Make a gaussian convolution kernel.

Parameters:
sizekernel size
Returns:
the convolution kernel. NULL on error

Definition at line 376 of file imgfilter.c.

References mallocMatrix().

Here is the call graph for this function:

float** mallocMatrix ( float  w,
float  h 
)

Definition at line 352 of file imgfilter.c.

Referenced by imgConvolute(), and imgGaussKernel().