c_integer_math_ops.c File Reference

#include "Image/c_integer_math_ops.h"
#include "Util/Assert.H"
Include dependency graph for c_integer_math_ops.c:

Go to the source code of this file.

Defines

#define LP5_APPROX_LEVEL   0
#define LP5_APPROX_2_3   2
#define LP5_APPROX_1_3   1
#define LP5_DIV_3   / 3
#define LP9_APPROX_LEVEL   0
#define LP9_APPROX_72_164   72
#define LP9_APPROX_56_164   56
#define LP9_APPROX_28_164   28
#define LP9_APPROX_8_164   8
#define LP9_DIV_164   / 164
#define LP9_APPROX_72_220   72
#define LP9_APPROX_56_220   56
#define LP9_APPROX_28_220   28
#define LP9_APPROX_8_220   8
#define LP9_DIV_220   / 220
#define LP9_APPROX_72_248   72
#define LP9_APPROX_56_248   56
#define LP9_APPROX_28_248   28
#define LP9_APPROX_8_248   8
#define LP9_DIV_248   / 248

Functions

void c_intg_low_pass_5_x_dec_x_manybits (const int *src, const int w, const int h, int *dst, const int w2)
void c_intg_low_pass_5_y_dec_y_manybits (const int *src, const int w, const int h, int *dst, const int h2)
void c_intg_low_pass_5_x_dec_x_fewbits (const int *src, const int w, const int h, int *dst, const int w2)
void c_intg_low_pass_5_y_dec_y_fewbits (const int *src, const int w, const int h, int *dst, const int h2)
void c_intg_low_pass_5_x_dec_x_fewbits_optim (const int *src, const int w, const int h, int *dst, const int w2)
void c_intg_low_pass_5_y_dec_y_fewbits_optim (const int *src, const int w, const int h, int *dst, const int h2)
void c_intg_low_pass_9_x_manybits (const int *src, const int w, const int h, int *dst)
 Convolve in the x direction with a 9-point binomial kernel.
void c_intg_low_pass_9_y_manybits (const int *src, const int w, const int h, int *dst)
 Convolve in the y direction with a 9-point binomial kernel.
void c_intg_low_pass_9_x_fewbits (const int *src, const int w, const int h, int *dst)
 Convolve in the x direction with a 9-point binomial kernel.
void c_intg_low_pass_9_y_fewbits (const int *src, const int w, const int h, int *dst)
 Convolve in the y direction with a 9-point binomial kernel.
void c_intg_low_pass_9_x_fewbits_optim (const int *src, const int w, const int h, int *dst)
 Like c_intg_low_pass_9_x_fewbits() but uses optimized filter coefficients.
void c_intg_low_pass_9_y_fewbits_optim (const int *src, const int w, const int h, int *dst)
 Like c_intg_low_pass_9_y_fewbits() but uses optimized filter coefficients.
void c_intg_x_filter_clean_manybits (const int *src, const int w, const int h, const int *hf_flipped, const int hfs, const int shiftbits, int *dst)
 function for reasonably large images
void c_intg_x_filter_clean_fewbits (const int *src, const int w, const int h, const int *hf_flipped, const int hfs, const int shiftbits, int *dst)
 function for reasonably large images
void c_intg_x_filter_clean_small_manybits (const int *src, const int w, const int h, const int *hf_flipped, const int hfs, const int shiftbits, int *dst)
 special function for very small images
void c_intg_x_filter_clean_small_fewbits (const int *src, const int w, const int h, const int *hf_flipped, const int hfs, const int shiftbits, int *dst)
 special function for very small images
void c_intg_y_filter_clean_manybits (const int *src, const int w, const int h, const int *vf_flipped, const int vfs, const int shiftbits, int *dst)
 function for reasonably large images
void c_intg_y_filter_clean_fewbits (const int *src, const int w, const int h, const int *vf_flipped, const int vfs, const int shiftbits, int *dst)
 function for reasonably large images
void c_intg_y_filter_clean_small_manybits (const int *src, const int w, const int h, const int *vf_flipped, const int vfs, const int shiftbits, int *dst)
 special function for very small images
void c_intg_y_filter_clean_small_fewbits (const int *src, const int w, const int h, const int *vf_flipped, const int vfs, const int shiftbits, int *dst)
 special function for very small images

Detailed Description

Fixed-point integer math versions of some of our floating-point Image functions

Definition in file c_integer_math_ops.c.


Function Documentation

void c_intg_low_pass_9_x_fewbits ( const int *  src,
const int  w,
const int  h,
int *  dst 
)

Convolve in the x direction with a 9-point binomial kernel.

The kernel is {1, 8, 28, 56, 70, 56, 28, 8, 1}, summing to 256

Parameters:
src pointer to the source image, w*h row-major
w width of the source and destination images
h height of the source and destination images
dst pointer to the destination image, w*h row-major

Internally, this algorithm multiplies each input pixel by the corresponding filter coefficient, accumulates across the 9 filter points, and then divides by the sum of the filter coefficients. Thus it is appropriate when the input relatively few precision bits giving room for doing the multiply/accumulate prior to the divide, but not when the input has many precision bits and would require an early division to avoid overflow. For a 32-bit int, a reasonable cutoff point is 18 bits -- if the input has fewer than 18 bits, use this algorithm, otherwise use the manybits functions (see above).

Definition at line 777 of file c_integer_math_ops.c.

References ASSERT.

Referenced by IntegerMathEngine::paramChanged().

void c_intg_low_pass_9_x_fewbits_optim ( const int *  src,
const int  w,
const int  h,
int *  dst 
)

Like c_intg_low_pass_9_x_fewbits() but uses optimized filter coefficients.

Definition at line 1070 of file c_integer_math_ops.c.

References ASSERT.

Referenced by IntegerMathEngine::paramChanged().

void c_intg_low_pass_9_x_manybits ( const int *  src,
const int  w,
const int  h,
int *  dst 
)

Convolve in the x direction with a 9-point binomial kernel.

The kernel is {1, 8, 28, 56, 70, 56, 28, 8, 1}, summing to 256

Parameters:
src pointer to the source image, w*h row-major
w width of the source and destination images
h height of the source and destination images
dst pointer to the destination image, w*h row-major

Internally, this algorithm divides each of the source values by the sum of the filter coefficients, then multiplies by the coefficient and accumulates. Thus it is appropriate when the input has many precision bits and would overflow if multiplied by the fitler coefficient without dividing first, but is not appropriate when the input has few bits and would underflow as a result of the early division. For a 32-bit int, a reasonable cutoff point is 18 bits -- if the input has 18 bits or more, use this algorithm, otherwise use the fewbits functions (see below).

Definition at line 590 of file c_integer_math_ops.c.

References ASSERT.

Referenced by IntegerMathEngine::paramChanged().

void c_intg_low_pass_9_y_fewbits ( const int *  src,
const int  w,
const int  h,
int *  dst 
)

Convolve in the y direction with a 9-point binomial kernel.

Like c_intg_low_pass_9_y_fewbits(), but convolves in the y direction instead of the x direction.

Definition at line 866 of file c_integer_math_ops.c.

References ASSERT.

Referenced by IntegerMathEngine::paramChanged().

void c_intg_low_pass_9_y_fewbits_optim ( const int *  src,
const int  w,
const int  h,
int *  dst 
)

Like c_intg_low_pass_9_y_fewbits() but uses optimized filter coefficients.

Definition at line 1137 of file c_integer_math_ops.c.

References ASSERT.

Referenced by IntegerMathEngine::paramChanged().

void c_intg_low_pass_9_y_manybits ( const int *  src,
const int  w,
const int  h,
int *  dst 
)

Convolve in the y direction with a 9-point binomial kernel.

Like c_intg_low_pass_9_y_manybits(), but convolves in the y direction instead of the x direction.

Definition at line 670 of file c_integer_math_ops.c.

References ASSERT.

Referenced by IntegerMathEngine::paramChanged().

void c_intg_x_filter_clean_fewbits ( const int *  src,
const int  w,
const int  h,
const int *  hf_flipped,
const int  hfs,
const int  shiftbits,
int *  dst 
)

function for reasonably large images

Definition at line 1284 of file c_integer_math_ops.c.

References ASSERT, and sum().

void c_intg_x_filter_clean_manybits ( const int *  src,
const int  w,
const int  h,
const int *  hf_flipped,
const int  hfs,
const int  shiftbits,
int *  dst 
)

function for reasonably large images

Definition at line 1226 of file c_integer_math_ops.c.

References ASSERT, and sum().

void c_intg_x_filter_clean_small_fewbits ( const int *  src,
const int  w,
const int  h,
const int *  hf_flipped,
const int  hfs,
const int  shiftbits,
int *  dst 
)

special function for very small images

Definition at line 1373 of file c_integer_math_ops.c.

References ASSERT, and sum().

void c_intg_x_filter_clean_small_manybits ( const int *  src,
const int  w,
const int  h,
const int *  hf_flipped,
const int  hfs,
const int  shiftbits,
int *  dst 
)

special function for very small images

Definition at line 1342 of file c_integer_math_ops.c.

References ASSERT, and sum().

void c_intg_y_filter_clean_fewbits ( const int *  src,
const int  w,
const int  h,
const int *  vf_flipped,
const int  vfs,
const int  shiftbits,
int *  dst 
)

function for reasonably large images

Definition at line 1468 of file c_integer_math_ops.c.

References ASSERT, and sum().

void c_intg_y_filter_clean_manybits ( const int *  src,
const int  w,
const int  h,
const int *  vf_flipped,
const int  vfs,
const int  shiftbits,
int *  dst 
)

function for reasonably large images

Definition at line 1403 of file c_integer_math_ops.c.

References ASSERT, and sum().

void c_intg_y_filter_clean_small_fewbits ( const int *  src,
const int  w,
const int  h,
const int *  vf_flipped,
const int  vfs,
const int  shiftbits,
int *  dst 
)

special function for very small images

Definition at line 1564 of file c_integer_math_ops.c.

References ASSERT, and sum().

void c_intg_y_filter_clean_small_manybits ( const int *  src,
const int  w,
const int  h,
const int *  vf_flipped,
const int  vfs,
const int  shiftbits,
int *  dst 
)

special function for very small images

Definition at line 1533 of file c_integer_math_ops.c.

References ASSERT, and sum().

Generated on Sun May 8 08:42:40 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3