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>
71 #if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)
74 const unsigned int gaussianFilterSize,
75 const double thresholdCanny,
76 const unsigned int apertureSobel);
88 const unsigned int r,
const unsigned int c)
90 return (2047.0 *(I[r][c+1] - I[r][c-1])
91 +913.0 *(I[r][c+2] - I[r][c-2])
92 +112.0 *(I[r][c+3] - I[r][c-3]))/8418.0;
104 const unsigned int r,
const unsigned int c)
106 return (2047.0 *(I[r+1][c] - I[r-1][c])
107 +913.0 *(I[r+2][c] - I[r-2][c])
108 +112.0 *(I[r+3][c] - I[r-3][c]))/8418.0;
125 const unsigned int r,
const unsigned int c,
126 const double *filter,
const unsigned int size)
133 for(i=1; i<=(size-1)/2; i++)
135 result += filter[i]*(I[r][c+i] - I[r][c-i]) ;
155 const unsigned int r,
const unsigned int c,
156 const double *filter,
const unsigned int size)
163 for(i=1; i<=(size-1)/2; i++)
165 result += filter[i]*(I[r+i][c] - I[r-i][c]) ;
186 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.);
190 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.);
197 unsigned int r,
unsigned int c,
198 const double *filter,
unsigned int size)
204 for(
unsigned int i=1; i<=(size-1)/2; i++)
206 result += filter[i]*(I[r][c+i] + I[r][c-i]) ;
208 return result+filter[0]*I[r][c];
213 unsigned int r,
unsigned int c,
214 const double *filter,
unsigned int size)
220 for(
unsigned int i=1; i<=(size-1)/2; i++)
223 result += filter[i]*(I[r][c+i] + I[r][c-i]) ;
225 result += filter[i]*(I[r][c+i] + I[r][i-c]) ;
227 return result+filter[0]*I[r][c];
231 unsigned int r,
unsigned int c,
232 const double *filter,
unsigned int size)
238 for(
unsigned int i=1; i<=(size-1)/2; i++)
241 result += filter[i]*(I[r][c+i] + I[r][c-i]) ;
243 result += filter[i]*(I[r][2*I.
getWidth()-c-i-1] + I[r][c-i]) ;
245 return result+filter[0]*I[r][c];
249 unsigned int r,
unsigned int c,
250 const double *filter,
unsigned int size)
256 for(
unsigned int i=1; i<=(size-1)/2; i++)
258 result += filter[i]*(I[r][c+i] + I[r][c-i]) ;
260 return result+filter[0]*I[r][c];
264 unsigned int r,
unsigned int c,
265 const double *filter,
unsigned int size)
271 for(
unsigned int i=1; i<=(size-1)/2; i++)
274 result += filter[i]*(I[r][c+i] + I[r][c-i]) ;
276 result += filter[i]*(I[r][c+i] + I[r][i-c]) ;
278 return result+filter[0]*I[r][c];
282 unsigned int r,
unsigned int c,
283 const double *filter,
unsigned int size)
289 for(
unsigned int i=1; i<=(size-1)/2; i++)
292 result += filter[i]*(I[r][c+i] + I[r][c-i]) ;
294 result += filter[i]*(I[r][2*I.
getWidth()-c-i-1] + I[r][c-i]) ;
296 return result+filter[0]*I[r][c];
302 unsigned int r,
unsigned int c,
303 const double *filter,
unsigned int size)
309 for(
unsigned int i=1; i<=(size-1)/2; i++)
311 result += filter[i]*(I[r+i][c] + I[r-i][c]) ;
313 return result+filter[0]*I[r][c];
322 for(
unsigned int i=1; i<=(size-1)/2; i++)
325 result += filter[i]*(I[r+i][c] + I[r-i][c]) ;
327 result += filter[i]*(I[r+i][c] + I[i-r][c]) ;
329 return result+filter[0]*I[r][c];
338 for(
unsigned int i=1; i<=(size-1)/2; i++)
341 result += filter[i]*(I[r+i][c] + I[r-i][c]) ;
343 result += filter[i]*(I[2*I.
getHeight()-r-i-1][c] + I[r-i][c]) ;
345 return result+filter[0]*I[r][c];
354 for(
unsigned int i=1; i<=(size-1)/2; i++)
357 result += filter[i]*(I[r+i][c] + I[r-i][c]) ;
359 result += filter[i]*(I[r+i][c] + I[i-r][c]) ;
361 return result+filter[0]*I[r][c];
370 for(
unsigned int i=1; i<=(size-1)/2; i++)
373 result += filter[i]*(I[r+i][c] + I[r-i][c]) ;
375 result += filter[i]*(I[2*I.
getHeight()-r-i-1][c] + I[r-i][c]) ;
377 return result+filter[0]*I[r][c];
381 unsigned int r,
unsigned int c,
382 const double *filter,
unsigned int size)
388 for(
unsigned int i=1; i<=(size-1)/2; i++)
390 result += filter[i]*(I[r+i][c] + I[r-i][c]) ;
392 return result+filter[0]*I[r][c];
406 const unsigned int r,
const unsigned int c)
411 + 12.0 * ( fr[r-1][c] + fr[r][c-1] + fr[r+1][c] + fr[r][c+1] )
412 + 9.0 * ( fr[r-1][c-1] + fr[r+1][c-1] + fr[r-1][c+1] + fr[r+1][c+1])
413 + 5.0 * ( fr[r-2][c] + fr[r][c-2] + fr[r+2][c] + fr[r][c+2] )
414 + 4.0 * ( fr[r-2][c+1] + fr[r-2][c-1] + fr[r-1][c-2] + fr[r+1][c-2] +
415 fr[r+2][c-1] + fr[r+2][c+1] + fr[r-1][c+2] + fr[r+1][c+2] )
416 + 2.0 * ( fr[r-2][c-2] + fr[r+2][c-2] + fr[r-2][c+2] + fr[r+2][c+2] )
425 static void getGaussianKernel(
double *filter,
unsigned int size,
double sigma=0.,
bool normalize=
true);
426 static void getGaussianDerivativeKernel(
double *filter,
unsigned int size,
double sigma=0.,
bool normalize=
true);
433 const double *gaussianDerivativeKernel,
unsigned int size);
440 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)
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...