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> 69 #if defined(VISP_HAVE_OPENCV) && (VISP_HAVE_OPENCV_VERSION >= 0x020100) 71 const double thresholdCanny,
const unsigned int apertureSobel);
83 return (2047.0 * (I[r][c + 1] - I[r][c - 1]) + 913.0 * (I[r][c + 2] - I[r][c - 2]) +
84 112.0 * (I[r][c + 3] - I[r][c - 3])) /
97 return (2047.0 * (I[r + 1][c] - I[r - 1][c]) + 913.0 * (I[r + 2][c] - I[r - 2][c]) +
98 112.0 * (I[r + 3][c] - I[r - 3][c])) /
117 const unsigned int size)
124 for (i = 1; i <= (size - 1) / 2; i++) {
125 result += filter[i] * (I[r][c + i] - I[r][c - i]);
144 const unsigned int size)
151 for (i = 1; i <= (size - 1) / 2; i++) {
152 result += filter[i] * (I[r + i][c] - I[r - i][c]);
158 const bool convolve =
false);
161 const 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]) /
190 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
191 result += filter[i] * (I[r][c + i] + I[r][c - i]);
193 return result + filter[0] * I[r][c];
197 const double *filter,
unsigned int size)
203 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
205 result += filter[i] * (I[r][c + i] + I[r][c - i]);
207 result += filter[i] * (I[r][c + i] + I[r][i - c]);
209 return result + filter[0] * I[r][c];
213 const double *filter,
unsigned int size)
219 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
221 result += filter[i] * (I[r][c + i] + I[r][c - i]);
223 result += filter[i] * (I[r][2 * I.
getWidth() - c - i - 1] + I[r][c - i]);
225 return result + filter[0] * I[r][c];
235 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
236 result += filter[i] * (I[r][c + i] + I[r][c - i]);
238 return result + filter[0] * I[r][c];
248 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
250 result += filter[i] * (I[r][c + i] + I[r][c - i]);
252 result += filter[i] * (I[r][c + i] + I[r][i - c]);
254 return result + filter[0] * I[r][c];
258 const double *filter,
unsigned int size)
264 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
266 result += filter[i] * (I[r][c + i] + I[r][c - i]);
268 result += filter[i] * (I[r][2 * I.
getWidth() - c - i - 1] + I[r][c - i]);
270 return result + filter[0] * I[r][c];
282 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
283 result += filter[i] * (I[r + i][c] + I[r - i][c]);
285 return result + filter[0] * I[r][c];
289 const double *filter,
unsigned int size)
295 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
297 result += filter[i] * (I[r + i][c] + I[r - i][c]);
299 result += filter[i] * (I[r + i][c] + I[i - r][c]);
301 return result + filter[0] * I[r][c];
305 const double *filter,
unsigned int size)
311 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
313 result += filter[i] * (I[r + i][c] + I[r - i][c]);
315 result += filter[i] * (I[2 * I.
getHeight() - r - i - 1][c] + I[r - i][c]);
317 return result + filter[0] * I[r][c];
327 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];
337 const double *filter,
unsigned int size)
343 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];
359 for (
unsigned int i = 1; i <= (size - 1) / 2; i++) {
360 result += filter[i] * (I[r + i][c] + I[r - i][c]);
362 return result + filter[0] * I[r][c];
366 double sigma = 0.,
bool normalize =
true);
368 bool normalize =
true);
379 return (15.0 * fr[r][c] + 12.0 * (fr[r - 1][c] + fr[r][c - 1] + fr[r + 1][c] + fr[r][c + 1]) +
380 9.0 * (fr[r - 1][c - 1] + fr[r + 1][c - 1] + fr[r - 1][c + 1] + fr[r + 1][c + 1]) +
381 5.0 * (fr[r - 2][c] + fr[r][c - 2] + fr[r + 2][c] + fr[r][c + 2]) +
382 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] +
383 fr[r + 2][c + 1] + fr[r - 1][c + 2] + fr[r + 1][c + 2]) +
384 2.0 * (fr[r - 2][c - 2] + fr[r + 2][c - 2] + fr[r - 2][c + 2] + fr[r + 2][c + 2])) /
392 static void getGaussianKernel(
double *filter,
unsigned int size,
double sigma = 0.,
bool normalize =
true);
393 static void getGaussianDerivativeKernel(
double *filter,
unsigned int size,
double sigma = 0.,
bool normalize =
true);
401 const double *gaussianDerivativeKernel,
unsigned int size);
408 const double *gaussianDerivativeKernel,
unsigned int size);
410 static double getSobelKernelX(
double *filter,
unsigned int size);
411 static double getSobelKernelY(
double *filter,
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...