29 typedef struct { uchar
r, g, b; }
rgb;
32 return ((a.
r == b.
r) && (a.
g == b.
g) && (a.
b == b.
b));
36 inline T
abs(
const T &x) {
return (x > 0 ? x : -x); };
39 inline int sign(
const T &x) {
return (x >= 0 ? 1 : -1); };
42 inline T
square(
const T &x) {
return x*x; };
45 inline T
bound(
const T &x,
const T &min,
const T &max) {
46 return (x < min ? min : (x > max ? max : x));
50 inline bool check_bound(
const T &x,
const T&min,
const T &max) {
51 return ((x < min) || (x > max));
54 inline int vlib_round(
float x) {
return (
int)(x + 0.5F); }
56 inline int vlib_round(
double x) {
return (
int)(x + 0.5); }
58 inline double gaussian(
double val,
double sigma) {
59 return exp(-
square(val/sigma)/2)/(sqrt(2*M_PI)*sigma);