44 #ifndef vpImageFilter_H
45 #define vpImageFilter_H
53 #include <visp/vpImage.h>
54 #include <visp/vpImageException.h>
55 #include <visp/vpMatrix.h>
56 #include <visp/vpMath.h>
75 #if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)
78 const unsigned int gaussianFilterSize,
79 const double thresholdCanny,
80 const unsigned int apertureSobel);
92 const unsigned int r,
const unsigned int c)
94 return (2047.0 *(I[r][c+1] - I[r][c-1])
95 +913.0 *(I[r][c+2] - I[r][c-2])
96 +112.0 *(I[r][c+3] - I[r][c-3]))/8418.0;
108 const unsigned int r,
const unsigned int c)
110 return (2047.0 *(I[r+1][c] - I[r-1][c])
111 +913.0 *(I[r+2][c] - I[r-2][c])
112 +112.0 *(I[r+3][c] - I[r-3][c]))/8418.0;
129 const unsigned int r,
const unsigned int c,
130 const double *filter,
const unsigned int size)
137 for(i=1; i<=(size-1)/2; i++)
139 result += filter[i]*(I[r][c+i] - I[r][c-i]) ;
159 const unsigned int r,
const unsigned int c,
160 const double *filter,
const unsigned int size)
167 for(i=1; i<=(size-1)/2; i++)
169 result += filter[i]*(I[r+i][c] - I[r-i][c]) ;
190 return (
unsigned char)((1.*I[i][j-2]+4.*I[i][j-1]+6.*I[i][j]+4.*I[i][j+1]+1.*I[i][j+2])/16.);
194 return (
unsigned char)((1.*I[i-2][j]+4.*I[i-1][j]+6.*I[i][j]+4.*I[i+1][j]+1.*I[i+2][j])/16.);
201 unsigned int r,
unsigned int c,
202 const double *filter,
unsigned int size)
208 for(
unsigned int i=1; i<=(size-1)/2; i++)
210 result += filter[i]*(I[r][c+i] + I[r][c-i]) ;
212 return result+filter[0]*I[r][c];
217 unsigned int r,
unsigned int c,
218 const double *filter,
unsigned int size)
224 for(
unsigned int i=1; i<=(size-1)/2; i++)
227 result += filter[i]*(I[r][c+i] + I[r][c-i]) ;
229 result += filter[i]*(I[r][c+i] + I[r][i-c]) ;
231 return result+filter[0]*I[r][c];
235 unsigned int r,
unsigned int c,
236 const double *filter,
unsigned int size)
242 for(
unsigned int i=1; i<=(size-1)/2; i++)
245 result += filter[i]*(I[r][c+i] + I[r][c-i]) ;
247 result += filter[i]*(I[r][2*I.
getWidth()-c-i-1] + I[r][c-i]) ;
249 return result+filter[0]*I[r][c];
253 unsigned int r,
unsigned int c,
254 const double *filter,
unsigned int size)
260 for(
unsigned int i=1; i<=(size-1)/2; i++)
262 result += filter[i]*(I[r][c+i] + I[r][c-i]) ;
264 return result+filter[0]*I[r][c];
268 unsigned int r,
unsigned int c,
269 const double *filter,
unsigned int size)
275 for(
unsigned int i=1; i<=(size-1)/2; i++)
278 result += filter[i]*(I[r][c+i] + I[r][c-i]) ;
280 result += filter[i]*(I[r][c+i] + I[r][i-c]) ;
282 return result+filter[0]*I[r][c];
286 unsigned int r,
unsigned int c,
287 const double *filter,
unsigned int size)
293 for(
unsigned int i=1; i<=(size-1)/2; i++)
296 result += filter[i]*(I[r][c+i] + I[r][c-i]) ;
298 result += filter[i]*(I[r][2*I.
getWidth()-c-i-1] + I[r][c-i]) ;
300 return result+filter[0]*I[r][c];
306 unsigned int r,
unsigned int c,
307 const double *filter,
unsigned int size)
313 for(
unsigned int i=1; i<=(size-1)/2; i++)
315 result += filter[i]*(I[r+i][c] + I[r-i][c]) ;
317 return result+filter[0]*I[r][c];
326 for(
unsigned int i=1; i<=(size-1)/2; i++)
329 result += filter[i]*(I[r+i][c] + I[r-i][c]) ;
331 result += filter[i]*(I[r+i][c] + I[i-r][c]) ;
333 return result+filter[0]*I[r][c];
342 for(
unsigned int i=1; i<=(size-1)/2; i++)
345 result += filter[i]*(I[r+i][c] + I[r-i][c]) ;
347 result += filter[i]*(I[2*I.
getHeight()-r-i-1][c] + I[r-i][c]) ;
349 return result+filter[0]*I[r][c];
358 for(
unsigned int i=1; i<=(size-1)/2; i++)
361 result += filter[i]*(I[r+i][c] + I[r-i][c]) ;
363 result += filter[i]*(I[r+i][c] + I[i-r][c]) ;
365 return result+filter[0]*I[r][c];
374 for(
unsigned int i=1; i<=(size-1)/2; i++)
377 result += filter[i]*(I[r+i][c] + I[r-i][c]) ;
379 result += filter[i]*(I[2*I.
getHeight()-r-i-1][c] + I[r-i][c]) ;
381 return result+filter[0]*I[r][c];
385 unsigned int r,
unsigned int c,
386 const double *filter,
unsigned int size)
392 for(
unsigned int i=1; i<=(size-1)/2; i++)
394 result += filter[i]*(I[r+i][c] + I[r-i][c]) ;
396 return result+filter[0]*I[r][c];
409 const unsigned int r,
const unsigned int c)
414 + 12.0 * ( fr[r-1][c] + fr[r][c-1] + fr[r+1][c] + fr[r][c+1] )
415 + 9.0 * ( fr[r-1][c-1] + fr[r+1][c-1] + fr[r-1][c+1] + fr[r+1][c+1])
416 + 5.0 * ( fr[r-2][c] + fr[r][c-2] + fr[r+2][c] + fr[r][c+2] )
417 + 4.0 * ( fr[r-2][c+1] + fr[r-2][c-1] + fr[r-1][c-2] + fr[r+1][c-2] +
418 fr[r+2][c-1] + fr[r+2][c+1] + fr[r-1][c+2] + fr[r+1][c+2] )
419 + 2.0 * ( fr[r-2][c-2] + fr[r+2][c-2] + fr[r-2][c+2] + fr[r+2][c+2] )
428 static void getGaussianKernel(
double *filter,
unsigned int size,
double sigma=0.,
bool normalize=
true);
429 static void getGaussianDerivativeKernel(
double *filter,
unsigned int size,
double sigma=0.,
bool normalize=
true);
436 const double *gaussianDerivativeKernel,
unsigned int size);
443 const double *gaussianDerivativeKernel,
unsigned int size);
Definition of the vpMatrix class.
static double filterXLeftBorder(const vpImage< unsigned char > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
unsigned int getWidth() const
static double filterXLeftBorder(const vpImage< double > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double filterX(const vpImage< unsigned char > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double derivativeFilterY(const vpImage< T > &I, const unsigned int r, const unsigned int c)
static unsigned char filterGaussYPyramidal(const vpImage< unsigned char > &I, unsigned int i, unsigned int j)
static double gaussianFilter(const vpImage< T > &fr, const unsigned int r, const unsigned int c)
static double filterXRightBorder(const vpImage< double > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double filterY(const vpImage< unsigned char > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double filterYBottomBorder(const vpImage< double > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double filterX(const vpImage< double > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double filterYTopBorder(const vpImage< unsigned char > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double filterXRightBorder(const vpImage< unsigned char > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double filterY(const vpImage< double > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double filterYTopBorder(const vpImage< double > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double derivativeFilterY(const vpImage< T > &I, const unsigned int r, const unsigned int c, const double *filter, const unsigned int size)
static double filterYBottomBorder(const vpImage< unsigned char > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static unsigned char filterGaussXPyramidal(const vpImage< unsigned char > &I, unsigned int i, unsigned int j)
unsigned int getHeight() const
static double derivativeFilterX(const vpImage< T > &I, const unsigned int r, const unsigned int c)
static double derivativeFilterX(const vpImage< T > &I, const unsigned int r, const unsigned int c, const double *filter, const unsigned int size)
Various image filter, convolution, etc...