39 #ifndef vpImageFilter_H
40 #define vpImageFilter_H
48 #include <visp3/core/vpImage.h>
49 #include <visp3/core/vpImageException.h>
50 #include <visp3/core/vpMath.h>
51 #include <visp3/core/vpMatrix.h>
52 #include <visp3/core/vpRGBa.h>
70 #if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100)
72 double thresholdCanny,
unsigned int apertureSobel);
84 return (2047.0 * (I[r][c + 1] - I[r][c - 1]) + 913.0 * (I[r][c + 2] - I[r][c - 2]) +
85 112.0 * (I[r][c + 3] - I[r][c - 3])) /
98 return (2047.0 * (I[r + 1][c] - I[r - 1][c]) + 913.0 * (I[r + 2][c] - I[r - 2][c]) +
99 112.0 * (I[r + 3][c] - I[r - 3][c])) /
125 for (i = 1; i <= (size - 1) / 2; i++) {
126 result += filter[i] * (I[r][c + i] - I[r][c - i]);
152 for (i = 1; i <= (size - 1) / 2; i++) {
153 result += filter[i] * (I[r + i][c] - I[r - i][c]);
159 bool convolve =
false);
171 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]) /
176 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]) /
194 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
195 result += filter[i] * (I[r][c + i] + I[r][c - i]);
197 return result + filter[0] * I[r][c];
207 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
208 result += filter[i] * (I[r][c + i].R + I[r][c - i].R);
210 return result + filter[0] * I[r][c].R;
220 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
221 result += filter[i] * (I[r][c + i].G + I[r][c - i].G);
223 return result + filter[0] * I[r][c].G;
233 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
234 result += filter[i] * (I[r][c + i].B + I[r][c - i].B);
236 return result + filter[0] * I[r][c].B;
240 const double *filter,
unsigned int size)
246 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
248 result += filter[i] * (I[r][c + i] + I[r][c - i]);
250 result += filter[i] * (I[r][c + i] + I[r][i - c]);
252 return result + filter[0] * I[r][c];
256 const double *filter,
unsigned int size)
262 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
264 result += filter[i] * (I[r][c + i].R + I[r][c - i].R);
266 result += filter[i] * (I[r][c + i].R + I[r][i - c].R);
268 return result + filter[0] * I[r][c].R;
272 const double *filter,
unsigned int size)
278 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
280 result += filter[i] * (I[r][c + i].G + I[r][c - i].G);
282 result += filter[i] * (I[r][c + i].G + I[r][i - c].G);
284 return result + filter[0] * I[r][c].G;
288 const double *filter,
unsigned int size)
294 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
296 result += filter[i] * (I[r][c + i].B + I[r][c - i].B);
298 result += filter[i] * (I[r][c + i].B + I[r][i - c].B);
300 return result + filter[0] * I[r][c].B;
304 const double *filter,
unsigned int size)
310 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
312 result += filter[i] * (I[r][c + i] + I[r][c - i]);
314 result += filter[i] * (I[r][2 * I.
getWidth() - c - i - 1] + I[r][c - i]);
316 return result + filter[0] * I[r][c];
320 const double *filter,
unsigned int size)
326 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
328 result += filter[i] * (I[r][c + i].R + I[r][c - i].R);
330 result += filter[i] * (I[r][2 * I.
getWidth() - c - i - 1].R + I[r][c - i].R);
332 return result + filter[0] * I[r][c].R;
336 const double *filter,
unsigned int size)
342 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
344 result += filter[i] * (I[r][c + i].G + I[r][c - i].G);
346 result += filter[i] * (I[r][2 * I.
getWidth() - c - i - 1].G + I[r][c - i].G);
348 return result + filter[0] * I[r][c].G;
352 const double *filter,
unsigned int size)
358 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
360 result += filter[i] * (I[r][c + i].B + I[r][c - i].B);
362 result += filter[i] * (I[r][2 * I.
getWidth() - c - i - 1].B + I[r][c - i].B);
364 return result + filter[0] * I[r][c].B;
374 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
375 result += filter[i] * (I[r][c + i] + I[r][c - i]);
377 return result + filter[0] * I[r][c];
387 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
389 result += filter[i] * (I[r][c + i] + I[r][c - i]);
391 result += filter[i] * (I[r][c + i] + I[r][i - c]);
393 return result + filter[0] * I[r][c];
397 const double *filter,
unsigned int size)
403 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
405 result += filter[i] * (I[r][c + i] + I[r][c - i]);
407 result += filter[i] * (I[r][2 * I.
getWidth() - c - i - 1] + I[r][c - i]);
409 return result + filter[0] * I[r][c];
425 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
426 result += filter[i] * (I[r + i][c] + I[r - i][c]);
428 return result + filter[0] * I[r][c];
438 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
439 result += filter[i] * (I[r + i][c].R + I[r - i][c].R);
441 return result + filter[0] * I[r][c].R;
450 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
451 result += filter[i] * (I[r + i][c].G + I[r - i][c].G);
453 return result + filter[0] * I[r][c].G;
462 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
463 result += filter[i] * (I[r + i][c].B + I[r - i][c].B);
465 return result + filter[0] * I[r][c].B;
469 const double *filter,
unsigned int size)
475 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
477 result += filter[i] * (I[r + i][c] + I[r - i][c]);
479 result += filter[i] * (I[r + i][c] + I[i - r][c]);
481 return result + filter[0] * I[r][c];
491 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
493 result += filter[i] * (I[r + i][c].R + I[r - i][c].R);
495 result += filter[i] * (I[r + i][c].R + I[i - r][c].R);
497 return result + filter[0] * I[r][c].R;
507 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
509 result += filter[i] * (I[r + i][c].G + I[r - i][c].G);
511 result += filter[i] * (I[r + i][c].G + I[i - r][c].G);
513 return result + filter[0] * I[r][c].G;
523 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
525 result += filter[i] * (I[r + i][c].B + I[r - i][c].B);
527 result += filter[i] * (I[r + i][c].B + I[i - r][c].B);
529 return result + filter[0] * I[r][c].B;
533 const double *filter,
unsigned int size)
539 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
541 result += filter[i] * (I[r + i][c] + I[r - i][c]);
543 result += filter[i] * (I[2 * I.
getHeight() - r - i - 1][c] + I[r - i][c]);
545 return result + filter[0] * I[r][c];
549 const double *filter,
unsigned int size)
555 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
557 result += filter[i] * (I[r + i][c].R + I[r - i][c].R);
559 result += filter[i] * (I[2 * I.
getHeight() - r - i - 1][c].R + I[r - i][c].R);
561 return result + filter[0] * I[r][c].R;
565 const double *filter,
unsigned int size)
571 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
573 result += filter[i] * (I[r + i][c].G + I[r - i][c].G);
575 result += filter[i] * (I[2 * I.
getHeight() - r - i - 1][c].G + I[r - i][c].G);
577 return result + filter[0] * I[r][c].G;
581 const double *filter,
unsigned int size)
587 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
589 result += filter[i] * (I[r + i][c].B + I[r - i][c].B);
591 result += filter[i] * (I[2 * I.
getHeight() - r - i - 1][c].B + I[r - i][c].B);
593 return result + filter[0] * I[r][c].B;
603 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
605 result += filter[i] * (I[r + i][c] + I[r - i][c]);
607 result += filter[i] * (I[r + i][c] + I[i - r][c]);
609 return result + filter[0] * I[r][c];
613 const double *filter,
unsigned int size)
619 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
621 result += filter[i] * (I[r + i][c] + I[r - i][c]);
623 result += filter[i] * (I[2 * I.
getHeight() - r - i - 1][c] + I[r - i][c]);
625 return result + filter[0] * I[r][c];
635 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
636 result += filter[i] * (I[r + i][c] + I[r - i][c]);
638 return result + filter[0] * I[r][c];
642 double sigma = 0.,
bool normalize =
true);
644 bool normalize =
true);
646 bool normalize =
true);
657 return (15.0 * fr[r][c] + 12.0 * (fr[r - 1][c] + fr[r][c - 1] + fr[r + 1][c] + fr[r][c + 1]) +
658 9.0 * (fr[r - 1][c - 1] + fr[r + 1][c - 1] + fr[r - 1][c + 1] + fr[r + 1][c + 1]) +
659 5.0 * (fr[r - 2][c] + fr[r][c - 2] + fr[r + 2][c] + fr[r][c + 2]) +
660 4.0 * (fr[r - 2][c + 1] + fr[r - 2][c - 1] + fr[r - 1][c - 2] + fr[r + 1][c - 2] + fr[r + 2][c - 1] +
661 fr[r + 2][c + 1] + fr[r - 1][c + 2] + fr[r + 1][c + 2]) +
662 2.0 * (fr[r - 2][c - 2] + fr[r + 2][c - 2] + fr[r - 2][c + 2] + fr[r + 2][c + 2])) /
670 static void getGaussianKernel(
double *filter,
unsigned int size,
double sigma = 0.,
bool normalize =
true);
671 static void getGaussianDerivativeKernel(
double *filter,
unsigned int size,
double sigma = 0.,
bool normalize =
true);
679 const double *gaussianDerivativeKernel,
unsigned int size);
686 const double *gaussianDerivativeKernel,
unsigned int size);
688 static double getSobelKernelX(
double *filter,
unsigned int size);
689 static double getSobelKernelY(
double *filter,
unsigned int size);
Implementation of column vector and the associated operations.
Various image filter, convolution, etc...
static unsigned char filterGaussXPyramidal(const vpImage< unsigned char > &I, unsigned int i, unsigned int j)
static double filterXG(const vpImage< vpRGBa > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double derivativeFilterY(const vpImage< T > &I, unsigned int r, unsigned int c)
static double filterYTopBorderG(const vpImage< vpRGBa > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static void filterYB(const vpImage< vpRGBa > &I, vpImage< vpRGBa > &dIx, const double *filter, unsigned int size)
static double filterXRightBorder(const vpImage< double > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double filterXLeftBorder(const vpImage< unsigned char > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double filterYBottomBorderB(const vpImage< vpRGBa > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double derivativeFilterY(const vpImage< T > &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 filterXRightBorderB(const vpImage< vpRGBa > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double filterYBottomBorderR(const vpImage< vpRGBa > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double filterYTopBorderB(const vpImage< vpRGBa > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static void filterXB(const vpImage< vpRGBa > &I, vpImage< vpRGBa > &dIx, const double *filter, unsigned int size)
static double filterYR(const vpImage< vpRGBa > &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 filterXLeftBorderB(const vpImage< vpRGBa > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static void filterYR(const vpImage< vpRGBa > &I, vpImage< vpRGBa > &dIx, 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 filterXB(const vpImage< vpRGBa > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double filterXR(const vpImage< vpRGBa > &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 filterYBottomBorder(const vpImage< unsigned char > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double derivativeFilterX(const vpImage< T > &I, unsigned int r, unsigned int c)
static double filterXLeftBorderR(const vpImage< vpRGBa > &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 filterY(const vpImage< double > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double filterXLeftBorderG(const vpImage< vpRGBa > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double derivativeFilterX(const vpImage< T > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double filterXRightBorderR(const vpImage< vpRGBa > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double filterXLeftBorder(const vpImage< double > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static void filterXR(const vpImage< vpRGBa > &I, vpImage< vpRGBa > &dIx, const double *filter, unsigned int size)
static double filterYTopBorderR(const vpImage< vpRGBa > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static void filterYG(const vpImage< vpRGBa > &I, vpImage< vpRGBa > &dIx, const double *filter, unsigned int size)
static double filterXRightBorderG(const vpImage< vpRGBa > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static void filterXG(const vpImage< vpRGBa > &I, vpImage< vpRGBa > &dIx, 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< unsigned char > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double filterYG(const vpImage< vpRGBa > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double filterYBottomBorderG(const vpImage< vpRGBa > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static double filterYB(const vpImage< vpRGBa > &I, unsigned int r, unsigned int c, const double *filter, unsigned int size)
static unsigned char filterGaussYPyramidal(const vpImage< unsigned char > &I, unsigned int i, unsigned int j)
static double gaussianFilter(const vpImage< T > &fr, unsigned int r, unsigned int c)
unsigned int getWidth() const
unsigned int getHeight() const
Implementation of a matrix and operations on matrices.