40 #ifndef vpImageFilter_H
41 #define vpImageFilter_H
49 #include <visp3/core/vpImage.h>
50 #include <visp3/core/vpImageException.h>
51 #include <visp3/core/vpMatrix.h>
52 #include <visp3/core/vpMath.h>
70 #if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)
73 const unsigned int gaussianFilterSize,
74 const double thresholdCanny,
75 const unsigned int apertureSobel);
87 const unsigned int r,
const unsigned int c)
89 return (2047.0 *(I[r][c+1] - I[r][c-1])
90 +913.0 *(I[r][c+2] - I[r][c-2])
91 +112.0 *(I[r][c+3] - I[r][c-3]))/8418.0;
103 const unsigned int r,
const unsigned int c)
105 return (2047.0 *(I[r+1][c] - I[r-1][c])
106 +913.0 *(I[r+2][c] - I[r-2][c])
107 +112.0 *(I[r+3][c] - I[r-3][c]))/8418.0;
124 const unsigned int r,
const unsigned int c,
125 const double *filter,
const unsigned int size)
132 for(i=1; i<=(size-1)/2; i++)
134 result += filter[i]*(I[r][c+i] - I[r][c-i]) ;
154 const unsigned int r,
const unsigned int c,
155 const double *filter,
const unsigned int size)
162 for(i=1; i<=(size-1)/2; i++)
164 result += filter[i]*(I[r+i][c] - I[r-i][c]) ;
173 const bool convolve=
false);
178 const bool convolve=
false);
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];
410 const unsigned int r,
const unsigned int c)
415 + 12.0 * ( fr[r-1][c] + fr[r][c-1] + fr[r+1][c] + fr[r][c+1] )
416 + 9.0 * ( fr[r-1][c-1] + fr[r+1][c-1] + fr[r-1][c+1] + fr[r+1][c+1])
417 + 5.0 * ( fr[r-2][c] + fr[r][c-2] + fr[r+2][c] + fr[r][c+2] )
418 + 4.0 * ( fr[r-2][c+1] + fr[r-2][c-1] + fr[r-1][c-2] + fr[r+1][c-2] +
419 fr[r+2][c-1] + fr[r+2][c+1] + fr[r-1][c+2] + fr[r+1][c+2] )
420 + 2.0 * ( fr[r-2][c-2] + fr[r+2][c-2] + fr[r-2][c+2] + fr[r+2][c+2] )
429 static void getGaussianKernel(
double *filter,
unsigned int size,
double sigma=0.,
bool normalize=
true);
430 static void getGaussianDerivativeKernel(
double *filter,
unsigned int size,
double sigma=0.,
bool normalize=
true);
437 const double *gaussianDerivativeKernel,
unsigned int size);
444 const double *gaussianDerivativeKernel,
unsigned int size);
Implementation of a matrix and operations on matrices.
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)
Implementation of column vector and the associated operations.
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...