gpufilter
GPU-Efficient Recursive Filtering and Summed-Area Tables
Utility classes and functions

Classes

class  gpufilter::dvector< T >
 Device Vector class. More...
struct  gpufilter::_clamp
 Access pattern: clamp-to-border. More...
struct  gpufilter::_repeat
 Access pattern: repeat. More...
struct  gpufilter::_mirror
 Access pattern: mirror. More...
class  gpufilter::base_timer
 Base timer class. More...
class  gpufilter::gpu_timer
 GPU specialization of the timer class. More...
class  gpufilter::cpu_timer
 CPU specialization of the timer class. More...
class  gpufilter::scoped_timer_stop
 Scope-limited timer class. More...
class  gpufilter::timer_pool
 Pool of timers. More...
class  gpufilter::Vector< T, N >
 Vector class. More...
class  gpufilter::Matrix< T, M, N >
 Matrix class. More...

Enumerations

enum  gpufilter::initcond { gpufilter::zero, gpufilter::clamp, gpufilter::repeat, gpufilter::mirror }
 Enumerates possible initial conditions for 2D-image access. More...

Functions

template<class T >
T * gpufilter::cuda_new (size_t elements)
 Allocates a new memory space in the GPU.
template<class T >
void gpufilter::cuda_delete (T *d_ptr)
 Deallocates a memory space in the GPU.
void gpufilter::calc_borders (int &left, int &top, int &right, int &bottom, const int &w, const int &h, const int &extb)
 Calculate image borders.
bool gpufilter::extend (const int &w, const int &h, const int &extb)
 Verify if an image needs to be extended.
void gpufilter::cuda_error (const std::string &msg)
 Check error in device.
template<class T >
gpufilter::lookat (const T *in, const int &i, const int &n, const initcond &ic, const int &p=1)
 Look in an input at a given index range.
template<class T >
gpufilter::lookat (const T *img, const int &i, const int &j, const int &h, const int &w, const initcond &ic)
 Look in an image at a given position.
template<class T >
gpufilter::qs (const T &s)
 Compute recursive filtering scaling factor.
template<class T >
std::complex< T > gpufilter::ds (const std::complex< T > &d, const T &s)
 Rescale poles of the recursive filtering z-transform.
template<class T >
gpufilter::ds (const T &d, const T &s)
 Rescale poles in the real-axis of the recursive filtering z-transform.
template<class T1 , class T2 >
void gpufilter::weights1 (const T1 &s, T2 &b0, T2 &a1)
 Compute first-order weights.
template<class T1 , class T2 >
void gpufilter::weights2 (const T1 &s, T2 &b0, T2 &a1, T2 &a2)
 Compute first- and second-order weights.
template<class T >
void gpufilter::copy_to_symbol (const std::string &name, const T &value)
 Copy value(s) to symbol.
void gpufilter::copy_to_symbol (const std::string &name, unsigned long value)
void gpufilter::copy_to_symbol (const std::string &name, long value)
template<class T >
void gpufilter::copy_to_symbol (const std::string &name, const std::string &size_name, const std::vector< T > &items)
template<class T >
void gpufilter::copy_to_symbol (const std::string &name, const std::vector< T > &items)

Variables

timer_pool gpufilter::timers
 Global pool of timers.

Enumeration Type Documentation

Enumerates possible initial conditions for 2D-image access.

Enumerator:
zero 

Zero-border (outside image everything is zero)

clamp 

Clamp-to-border (image border continues forever)

repeat 

Repeat (image repeats itself forever)

mirror 

Mirror (image repeats itself mirrored forever)


Function Documentation

void gpufilter::calc_borders ( int &  left,
int &  top,
int &  right,
int &  bottom,
const int &  w,
const int &  h,
const int &  extb 
)

Calculate image borders.

Given the image size and an extension to consider calculates the four-directional border pixels (left, top, right and bottom) needed by algorithm 4 and 5.

Parameters:
[out]leftExtension (in pixels) in the left border of the image
[out]topExtension (in pixels) in the top border of the image
[out]rightExtension (in pixels) in the right border of the image
[out]bottomExtension (in pixels) in the bottom border of the image
[in]wWidth of the image
[in]hHeight of the image
[in]extbExtension (in blocks) to consider outside image (default 0)
template<class T >
void gpufilter::copy_to_symbol ( const std::string &  name,
const T &  value 
)

Copy value(s) to symbol.

Parameters:
[in]nameName of the symbol in device (GPU)
[in]valueValue to copy to symbol
Template Parameters:
TValue type used in the GPU
void gpufilter::copy_to_symbol ( const std::string &  name,
unsigned long  value 
) [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
[in]nameName of the symbol in device (GPU)
[in]valueValue to copy to symbol
void gpufilter::copy_to_symbol ( const std::string &  name,
long  value 
) [inline]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
[in]nameName of the symbol in device (GPU)
[in]valueValue to copy to symbol
template<class T >
void gpufilter::copy_to_symbol ( const std::string &  name,
const std::string &  size_name,
const std::vector< T > &  items 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
[in]nameName of the symbol in device (GPU)
[in]size_nameName of the symbol storing the size of the items to be copied
[in]itemsHost (STL) Vector values
Template Parameters:
TVector values type used in the CPU and the GPU
template<class T >
void gpufilter::copy_to_symbol ( const std::string &  name,
const std::vector< T > &  items 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters:
[in]nameName of the symbol in device (GPU)
[in]itemsHost (STL) Vector values
Template Parameters:
TVector values type used in the CPU and the GPU
template<class T >
void gpufilter::cuda_delete ( T *  d_ptr)

Deallocates a memory space in the GPU.

This function deletes device (GPU) memory space.

Parameters:
[in]d_ptrDevice pointer (in the GPU memory)
Template Parameters:
TMemory values type
void gpufilter::cuda_error ( const std::string &  msg) [inline]

Check error in device.

This function checks if there is a device error.

Parameters:
[in]msgMessage to appear in case of a device error
template<class T >
T* gpufilter::cuda_new ( size_t  elements)

Allocates a new memory space in the GPU.

This function allocates device (GPU) memory space.

Parameters:
[in]elementsNumber of elements to allocate
Returns:
Pointer to the device memory allocated
Template Parameters:
TMemory values type
template<class T >
std::complex<T> gpufilter::ds ( const std::complex< T > &  d,
const T &  s 
)

Rescale poles of the recursive filtering z-transform.

Given a complex-valued pole on |z|=1 ROC of the recursive filter z-transform compute a rescaled pole representing a true Gaussian filter convolution with arbitrary support sigma.

See also:
[vanVliet:1998] cited in weights2()
Parameters:
[in]dComplex-valued pole of a stable recursive filter
[in]sSigma support of the true Gaussian filter
Returns:
Rescaled complex-valued pole of the recursive filter approximation
Template Parameters:
TSigma value type
template<class T >
T gpufilter::ds ( const T &  d,
const T &  s 
)

Rescale poles in the real-axis of the recursive filtering z-transform.

Given a real pole on |z|=1 ROC of the recursive filter z-transform compute a rescaled pole representing a true Gaussian filter convolution with arbitrary support sigma.

See also:
[vanVliet:1998] cited in weights2()
Parameters:
[in]dReal pole of a stable recursive filter
[in]sSigma support of the true Gaussian filter
Returns:
Rescaled real pole of the recursive filter approximation
Template Parameters:
TSigma value type
bool gpufilter::extend ( const int &  w,
const int &  h,
const int &  extb 
)

Verify if an image needs to be extended.

Given the image size and an extension to consider verifies if the image should be extended to met the requirement of each dimension be a multiple of 32.

Parameters:
[in]wWidth of the image
[in]hHeight of the image
[in]extbExtension (in blocks) to consider outside image (default 0)
Returns:
True if corresponding image should be extended
template<class T >
T gpufilter::lookat ( const T *  in,
const int &  i,
const int &  n,
const initcond &  ic,
const int &  p = 1 
)

Look in an input at a given index range.

This function looks in an input array at an arbitrary index (possibly outside the input array) using a given initial condition and a pitch value for arrays with 2D geometry.

Parameters:
[in]inInput array
[in]iIndex to look at
[in]nInput range [0,n)
[in]icInitial condition
[in]pPitch (e.g. image width represented by the input array)
Returns:
Value at given position
Template Parameters:
TInput array value type
template<class T >
T gpufilter::lookat ( const T *  img,
const int &  i,
const int &  j,
const int &  h,
const int &  w,
const initcond &  ic 
)

Look in an image at a given position.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. This function looks in an input image at an arbitrary position (possibly outside the image) using a given initial condition and the 2D image size.

Parameters:
[in]imgInput image
[in]iRow index
[in]jColumn index
[in]hImage height
[in]wImage width
[in]icInitial condition
Returns:
Value at given position
Template Parameters:
TInput image value type
template<class T >
T gpufilter::qs ( const T &  s)

Compute recursive filtering scaling factor.

Compute the scaling factor of the recursive filter representing a true Gaussian filter convolution with arbitrary support sigma.

See also:
[vanVliet:1998] cited in weights2()
Parameters:
[in]sSigma support of the true Gaussian filter
Returns:
Scaling factor q of the recursive filter approximation
Template Parameters:
TSigma value type
template<class T1 , class T2 >
void gpufilter::weights1 ( const T1 &  s,
T2 &  b0,
T2 &  a1 
)

Compute first-order weights.

Given a Gaussian sigma value compute the feedforward and feedback first-order coefficients.

See also:
[vanVliet:1998] cited in weights2()
Parameters:
[in]sGaussian sigma
[out]b0Feedforward coefficient
[out]a1Feedback first-order coefficient
Template Parameters:
T1Sigma value type
T2Coefficients value type
template<class T1 , class T2 >
void gpufilter::weights2 ( const T1 &  s,
T2 &  b0,
T2 &  a1,
T2 &  a2 
)

Compute first- and second-order weights.

Given a Gaussian sigma value compute the feedforward and feedback first- and second-order coefficients. Refer to the following paper for more information:

@inproceedings{vanVliet:1998,
  author = {L. J. {van Vliet} and I. T. Young and P. W. Verbeek},
  title = {Recursive {Gaussian} derivative filters},
  booktitle = {Proceedings of the 14th International Conference on Pattern Recognition},
  year = {1998},
  pages = {509--514 (v. 1)}
}   
Parameters:
[in]sGaussian sigma
[out]b0Feedforward coefficient
[out]a1Feedback first-order coefficient
[out]a2Feedback second-order coefficient
Template Parameters:
T1Sigma value type
T2Coefficients value type