Visual Servoing Platform  version 3.6.1 under development (2024-11-21)
vpImageFilter Class Reference

#include <visp3/core/vpImageFilter.h>

Public Types

enum  vpCannyBackendType { CANNY_OPENCV_BACKEND = 0 , CANNY_VISP_BACKEND = 1 , CANNY_COUNT_BACKEND = 2 }
 
enum  vpCannyFilteringAndGradientType { CANNY_GBLUR_SOBEL_FILTERING = 0 , CANNY_GBLUR_SCHARR_FILTERING = 1 , CANNY_COUNT_FILTERING = 2 }
 
typedef enum vpImageFilter::vpCannyBackendType vpCannyBackendType
 
typedef enum vpImageFilter::vpCannyFilteringAndGradientType vpCannyFilteringAndGradientType
 

Static Public Member Functions

static std::string vpCannyBackendTypeList (const std::string &pref="<", const std::string &sep=" , ", const std::string &suf=">")
 
static std::string vpCannyBackendTypeToString (const vpCannyBackendType &type)
 
static vpCannyBackendType vpCannyBackendTypeFromString (const std::string &name)
 
static std::string vpGetCannyFiltAndGradTypes (const std::string &pref="<", const std::string &sep=" , ", const std::string &suf=">")
 
static std::string vpCannyFiltAndGradTypeToStr (const vpCannyFilteringAndGradientType &type)
 
static vpCannyFilteringAndGradientType vpCannyFiltAndGradTypeFromStr (const std::string &name)
 
static void canny (const vpImage< unsigned char > &I, vpImage< unsigned char > &Ic, const unsigned int &gaussianFilterSize, const float &thresholdCanny, const unsigned int &apertureSobel)
 
static void canny (const vpImage< unsigned char > &I, vpImage< unsigned char > &Ic, const unsigned int &gaussianFilterSize, const float &lowerThresholdCanny, const float &higherThresholdCanny, const unsigned int &apertureSobel)
 
static void canny (const vpImage< unsigned char > &I, vpImage< unsigned char > &Ic, const unsigned int &gaussianFilterSize, const float &lowerThresholdCanny, const float &higherThresholdCanny, const unsigned int &apertureSobel, const float &gaussianStdev, const float &lowerThresholdRatio, const float &upperThresholdRatio, const bool &normalizeGradients, const vpCannyBackendType &cannyBackend, const vpCannyFilteringAndGradientType &cannyFilteringSteps, const vpImage< bool > *p_mask=nullptr)
 
static float computeCannyThreshold (const cv::Mat &cv_I, const cv::Mat *p_cv_dIx, const cv::Mat *p_cv_dIy, float &lowerThresh, const unsigned int &gaussianKernelSize=5, const float &gaussianStdev=2.f, const unsigned int &apertureGradient=3, const float &lowerThresholdRatio=0.6, const float &upperThresholdRatio=0.8, const vpCannyFilteringAndGradientType &filteringType=CANNY_GBLUR_SOBEL_FILTERING)
 
static void computePartialDerivatives (const cv::Mat &cv_I, cv::Mat &cv_dIx, cv::Mat &cv_dIy, const bool &computeDx=true, const bool &computeDy=true, const bool &normalize=true, const unsigned int &gaussianKernelSize=5, const float &gaussianStdev=2.f, const unsigned int &apertureGradient=3, const vpCannyFilteringAndGradientType &filteringType=CANNY_GBLUR_SOBEL_FILTERING)
 
template<typename ImageType , typename FilterType >
static void computePartialDerivatives (const vpImage< ImageType > &I, vpImage< FilterType > &dIx, vpImage< FilterType > &dIy, const bool &computeDx=true, const bool &computeDy=true, const bool &normalize=true, const unsigned int &gaussianKernelSize=5, const FilterType &gaussianStdev=2.f, const unsigned int &apertureGradient=3, const vpCannyFilteringAndGradientType &filteringType=CANNY_GBLUR_SOBEL_FILTERING, const vpCannyBackendType &backend=CANNY_VISP_BACKEND, const vpImage< bool > *p_mask=nullptr)
 
template<typename FilterType >
static void computePartialDerivatives (const vpImage< vpRGBa > &I, vpImage< FilterType > &dIx, vpImage< FilterType > &dIy, const bool &computeDx=true, const bool &computeDy=true, const bool &normalize=true, const unsigned int &gaussianKernelSize=5, const FilterType &gaussianStdev=2.f, const unsigned int &apertureGradient=3, const vpCannyFilteringAndGradientType &filteringType=CANNY_GBLUR_SOBEL_FILTERING, const vpCannyBackendType &backend=CANNY_VISP_BACKEND, const vpImage< bool > *p_mask=nullptr)
 
template<typename ImageType >
static void computePartialDerivatives (const vpImage< ImageType > &I, vpImage< unsigned char > &dIx, vpImage< unsigned char > &dIy, const bool &computeDx=true, const bool &computeDy=true, const bool &normalize=true, const unsigned int &gaussianKernelSize=5, const unsigned char &gaussianStdev=2.f, const unsigned int &apertureGradient=3, const vpCannyFilteringAndGradientType &filteringType=CANNY_GBLUR_SOBEL_FILTERING, const vpCannyBackendType &backend=CANNY_VISP_BACKEND, const vpImage< bool > *p_mask=nullptr)
 
template<typename ImageType >
static void computePartialDerivatives (const vpImage< ImageType > &I, vpImage< vpRGBa > &dIx, vpImage< vpRGBa > &dIy, const bool &computeDx=true, const bool &computeDy=true, const bool &normalize=true, const unsigned int gaussianKernelSize=5, const vpRGBa gaussianStdev=vpRGBa(), const unsigned int apertureGradient=3, const vpCannyFilteringAndGradientType &filteringType=CANNY_GBLUR_SOBEL_FILTERING, const vpCannyBackendType &backend=CANNY_VISP_BACKEND, const vpImage< bool > *p_mask=nullptr)
 
template<typename OutType >
static float computeCannyThreshold (const vpImage< unsigned char > &I, float &lowerThresh, const vpImage< OutType > *p_dIx=nullptr, const vpImage< OutType > *p_dIy=nullptr, const unsigned int &gaussianKernelSize=5, const OutType &gaussianStdev=2.f, const unsigned int &apertureGradient=3, const float &lowerThresholdRatio=0.6f, const float &upperThresholdRatio=0.8f, const vpCannyFilteringAndGradientType &filteringType=CANNY_GBLUR_SOBEL_FILTERING, const vpImage< bool > *p_mask=nullptr)
 
template<class ImageType >
static double derivativeFilterX (const vpImage< ImageType > &I, unsigned int r, unsigned int c)
 
template<class ImageType >
static double derivativeFilterY (const vpImage< ImageType > &I, unsigned int r, unsigned int c)
 
template<class ImageType , typename FilterType >
static FilterType derivativeFilterX (const vpImage< ImageType > &I, unsigned int r, unsigned int c, const FilterType *filter, unsigned int size)
 
template<class ImageType , typename FilterType >
static FilterType derivativeFilterY (const vpImage< ImageType > &I, unsigned int r, unsigned int c, const FilterType *filter, unsigned int size)
 
template<typename ImageType , typename FilterType >
static void filter (const vpImage< ImageType > &I, vpImage< FilterType > &If, const vpArray2D< FilterType > &M, bool convolve=false, const vpImage< bool > *p_mask=nullptr)
 
template<typename FilterType >
static FilterType filter (const vpImage< FilterType > &I, const vpArray2D< FilterType > &M, unsigned int row, unsigned int col)
 
template<typename FilterType >
static void filter (const vpImage< vpRGBa > &I, vpImage< FilterType > &If, const vpArray2D< FilterType > &M, bool convolve=false)
 
template<typename ImageType , typename FilterType >
static void filter (const vpImage< ImageType > &I, vpImage< FilterType > &Iu, vpImage< FilterType > &Iv, const vpArray2D< FilterType > &M, bool convolve=false, const vpImage< bool > *p_mask=nullptr)
 
template<typename FilterType >
static void filter (const vpImage< vpRGBa > &I, vpImage< FilterType > &Iu, vpImage< FilterType > &Iv, const vpArray2D< FilterType > &M, bool convolve)
 
template<typename ImageType >
static void filter (const vpImage< ImageType > &I, vpImage< ImageType > &Iu, vpImage< ImageType > &Iv, const vpArray2D< vpRGBa > &M, bool convolve)
 
static void sepFilter (const vpImage< unsigned char > &I, vpImage< double > &If, const vpColVector &kernelH, const vpColVector &kernelV)
 
template<typename ImageType , typename FilterType >
static void filter (const vpImage< ImageType > &I, vpImage< FilterType > &GI, const FilterType *filter, unsigned int size, const vpImage< bool > *p_mask=nullptr)
 
static unsigned char filterGaussXPyramidal (const vpImage< unsigned char > &I, unsigned int i, unsigned int j)
 
static unsigned char filterGaussYPyramidal (const vpImage< unsigned char > &I, unsigned int i, unsigned int j)
 
template<typename ImageType , typename FilterType >
static void filterX (const vpImage< ImageType > &I, vpImage< FilterType > &dIx, const FilterType *filter, unsigned int size, const vpImage< bool > *p_mask=nullptr)
 
static void filterX (const vpImage< vpRGBa > &I, vpImage< vpRGBa > &dIx, const double *filter, unsigned int size, const vpImage< bool > *p_mask=nullptr)
 
template<typename ImageType , typename FilterType >
static FilterType filterX (const vpImage< ImageType > &I, unsigned int r, unsigned int c, const FilterType *filter, unsigned int size)
 
static void filterY (const vpImage< vpRGBa > &I, vpImage< vpRGBa > &dIx, const double *filter, unsigned int size, const vpImage< bool > *p_mask=nullptr)
 
template<typename ImageType , typename FilterType >
static void filterY (const vpImage< ImageType > &I, vpImage< FilterType > &dIy, const FilterType *filter, unsigned int size, const vpImage< bool > *p_mask=nullptr)
 
template<typename ImageType , typename FilterType >
static FilterType filterY (const vpImage< ImageType > &I, unsigned int r, unsigned int c, const FilterType *filter, unsigned int size)
 
template<typename ImageType , typename FilterType >
static void gaussianBlur (const vpImage< ImageType > &I, vpImage< FilterType > &GI, unsigned int size=7, FilterType sigma=0., bool normalize=true, const vpImage< bool > *p_mask=nullptr)
 
static void gaussianBlur (const vpImage< vpRGBa > &I, vpImage< vpRGBa > &GI, unsigned int size=7, double sigma=0., bool normalize=true, const vpImage< bool > *p_mask=nullptr)
 
template<class T >
static double gaussianFilter (const vpImage< T > &fr, unsigned int r, unsigned int c)
 
static void getGaussPyramidal (const vpImage< unsigned char > &I, vpImage< unsigned char > &GI)
 
static void getGaussXPyramidal (const vpImage< unsigned char > &I, vpImage< unsigned char > &GI)
 
static void getGaussYPyramidal (const vpImage< unsigned char > &I, vpImage< unsigned char > &GI)
 
template<typename FilterType >
static void getGaussianKernel (FilterType *filter, unsigned int size, FilterType sigma=0., bool normalize=true)
 
template<typename FilterType >
static void getGaussianDerivativeKernel (FilterType *filter, unsigned int size, FilterType sigma=0., bool normalize=true)
 
template<typename FilterType >
static void getGradX (const vpImage< unsigned char > &I, vpImage< FilterType > &dIx, const vpImage< bool > *p_mask=nullptr)
 
template<typename ImageType , typename FilterType >
static void getGradX (const vpImage< ImageType > &I, vpImage< FilterType > &dIx, const FilterType *filter, unsigned int size, const vpImage< bool > *p_mask=nullptr)
 
template<typename ImageType , typename FilterType >
static void getGradXGauss2D (const vpImage< ImageType > &I, vpImage< FilterType > &dIx, const FilterType *gaussianKernel, const FilterType *gaussianDerivativeKernel, unsigned int size, const vpImage< bool > *p_mask=nullptr)
 
template<typename FilterType >
static void getGradY (const vpImage< unsigned char > &I, vpImage< FilterType > &dIy, const vpImage< bool > *p_mask=nullptr)
 
template<typename ImageType , typename FilterType >
static void getGradY (const vpImage< ImageType > &I, vpImage< FilterType > &dIy, const FilterType *filter, unsigned int size, const vpImage< bool > *p_mask=nullptr)
 
template<typename ImageType , typename FilterType >
static void getGradYGauss2D (const vpImage< ImageType > &I, vpImage< FilterType > &dIy, const FilterType *gaussianKernel, const FilterType *gaussianDerivativeKernel, unsigned int size, const vpImage< bool > *p_mask=nullptr)
 
template<typename FilterType >
static FilterType getScharrKernelX (FilterType *filter, unsigned int size)
 
template<typename FilterType >
static FilterType getScharrKernelY (FilterType *filter, unsigned int size)
 
template<typename FilterType >
static FilterType getSobelKernelX (FilterType *filter, unsigned int size)
 
template<typename FilterType >
static FilterType getSobelKernelY (FilterType *filter, unsigned int size)
 
static float median (const cv::Mat &cv_I)
 
static float median (const vpImage< unsigned char > &Isrc)
 
static std::vector< float > median (const vpImage< vpRGBa > &Isrc)
 

Detailed Description

Various image filter, convolution, etc...

Definition at line 70 of file vpImageFilter.h.

Member Typedef Documentation

◆ vpCannyBackendType

Canny filter backends for the edge detection operations.

◆ vpCannyFilteringAndGradientType

Canny filter and gradient operators to apply on the image before the edge detection stage.

Member Enumeration Documentation

◆ vpCannyBackendType

Canny filter backends for the edge detection operations.

Enumerator
CANNY_OPENCV_BACKEND 

Use OpenCV.

CANNY_VISP_BACKEND 

Use ViSP.

CANNY_COUNT_BACKEND 

Definition at line 74 of file vpImageFilter.h.

◆ vpCannyFilteringAndGradientType

Canny filter and gradient operators to apply on the image before the edge detection stage.

Enumerator
CANNY_GBLUR_SOBEL_FILTERING 

Apply Gaussian blur + Sobel operator on the input image.

CANNY_GBLUR_SCHARR_FILTERING 

Apply Gaussian blur + Scharr operator on the input image.

CANNY_COUNT_FILTERING 

Definition at line 89 of file vpImageFilter.h.

Member Function Documentation

◆ canny() [1/3]

void vpImageFilter::canny ( const vpImage< unsigned char > &  Isrc,
vpImage< unsigned char > &  Ires,
const unsigned int &  gaussianFilterSize,
const float &  lowerThreshold,
const float &  upperThreshold,
const unsigned int &  apertureSobel 
)
static

Apply the Canny edge operator on the image Isrc and return the resulting image Ires.

The following example shows how to use the method:

#include <visp3/core/vpImage.h>
#include <visp3/core/vpImageFilter.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
// Constants for the Canny operator.
const unsigned int gaussianFilterSize = 5;
const float upperThresholdCanny = 15;
const float lowerThresholdCanny = 5;
const unsigned int apertureSobel = 3;
// Image for the Canny edge operator
// First grab the source image Isrc.
// Apply the Canny edge operator and set the Icanny image.
vpImageFilter::canny(Isrc, Icanny, gaussianFilterSize, lowerThresholdCanny, upperThresholdCanny, apertureSobel);
return (0);
}
static void canny(const vpImage< unsigned char > &I, vpImage< unsigned char > &Ic, const unsigned int &gaussianFilterSize, const float &thresholdCanny, const unsigned int &apertureSobel)
Parameters
[in]Isrc: Image to apply the Canny edge detector to.
[out]Ires: Filtered image (255 means an edge, 0 otherwise).
[in]gaussianFilterSize: The size of the mask of the Gaussian filter to apply (an odd number).
[in]lowerThreshold: The lower threshold for the Canny operator. Values lower than this value are rejected. If negative, it will be set to one third of the thresholdCanny .
[in]upperThreshold: The upper threshold for the Canny operator. Only value greater than this value are marked as an edge. If negative, it will be automatically computed, along with the lower threshold. Otherwise, the lower threshold will be set to one third of the thresholdCanny .
[in]apertureSobel: Size of the mask for the Sobel operator (odd number).

Definition at line 376 of file vpImageFilter_canny.cpp.

References canny(), CANNY_GBLUR_SOBEL_FILTERING, CANNY_OPENCV_BACKEND, and CANNY_VISP_BACKEND.

◆ canny() [2/3]

void vpImageFilter::canny ( const vpImage< unsigned char > &  Isrc,
vpImage< unsigned char > &  Ires,
const unsigned int &  gaussianFilterSize,
const float &  lowerThreshold,
const float &  upperThreshold,
const unsigned int &  apertureGradient,
const float &  gaussianStdev,
const float &  lowerThresholdRatio,
const float &  upperThresholdRatio,
const bool &  normalizeGradients,
const vpCannyBackendType cannyBackend,
const vpCannyFilteringAndGradientType cannyFilteringSteps,
const vpImage< bool > *  p_mask = nullptr 
)
static

Apply the Canny edge operator on the image Isrc and return the resulting image Ires.

The following example shows how to use the method:

#include <visp3/core/vpImage.h>
#include <visp3/core/vpImageFilter.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
// Constants for the Canny operator.
const unsigned int gaussianFilterSize = 5;
const float gaussianStdev = 2.0f;
const float upperThresholdCanny = 15.f;
const float lowerThresholdCanny = 5.f;
const float upperThresholdRatio = 0.8f;
const float lowerThresholdRatio = 0.6f;
const unsigned int apertureSobel = 3;
const bool normalizeGradient = true;
const vpCannyBackendType cannyBackend = CANNY_OPENCV_BACKEND; // or CANNY_VISP_BACKEND;
const vpCannyFilteringAndGradientType filteringType = CANNY_GBLUR_SOBEL_FILTERING; // or CANNY_GBLUR_SCHARR_FILTERING
// Image for the Canny edge operator
// First grab the source image Isrc.
// Apply the Canny edge operator and set the Icanny image.
vpImageFilter::canny(Isrc, Icanny, gaussianFilterSize, lowerThresholdCanny, upperThresholdCanny, apertureSobel,
gaussianStdev, lowerThresholdRatio, upperThresholdRatio, normalizeGradient,
cannyBackend, filteringType);
return (0);
}
vpCannyFilteringAndGradientType
Canny filter and gradient operators to apply on the image before the edge detection stage.
Definition: vpImageFilter.h:90
@ CANNY_GBLUR_SOBEL_FILTERING
Apply Gaussian blur + Sobel operator on the input image.
Definition: vpImageFilter.h:91
vpCannyBackendType
Canny filter backends for the edge detection operations.
Definition: vpImageFilter.h:75
@ CANNY_OPENCV_BACKEND
Use OpenCV.
Definition: vpImageFilter.h:76
Parameters
[in]Isrc: Image to apply the Canny edge detector to.
[out]Ires: Filtered image (255 means an edge, 0 otherwise).
[in]gaussianFilterSize: The size of the mask of the Gaussian filter to apply (an odd number).
[in]lowerThreshold: The lower threshold for the Canny operator. Values lower than this value are rejected. If negative, it will be set to one third of the thresholdCanny.
[in]upperThreshold: The upper threshold for the Canny operator. Only value greater than this value are marked as an edge. If negative, it will be automatically computed, along with the lower threshold. Otherwise, the lower threshold will be set to one third of the upper threshold.
[in]apertureGradient: Size of the mask for the gradient (Sobel or Scharr) operator (odd number).
[in]gaussianStdev: The standard deviation of the Gaussian filter to apply. If it is non-positive, it is computed from kernel size (gaussianKernelSize parameter) as $\sigma = 0.3*((gaussianKernelSize-1)*0.5 - 1) + 0.8$.
[in]lowerThresholdRatio: The ratio of the upper threshold the lower threshold must be equal to. It is used only if the user asks to compute the Canny thresholds.
[in]upperThresholdRatio: The ratio of pixels whose absolute gradient is lower or equal to define the upper threshold. It is used only if the user asks to compute the Canny thresholds.
[in]normalizeGradients: Needs to be true if asking to compute the upperThreshold, otherwise it depends on the user application and user-defined thresholds.
[in]cannyBackend: The backend to use to perform the Canny edge filtering.
[in]cannyFilteringSteps: The filtering + gradient operators to apply to compute the gradient in the early stage of the Canny algorithm.
[in]p_mask: Optional image mask that indicates where Canny edge detection has to be computed.

Definition at line 462 of file vpImageFilter_canny.cpp.

References vpException::badValue, CANNY_OPENCV_BACKEND, CANNY_VISP_BACKEND, computeCannyThreshold(), computePartialDerivatives(), vpImageConvert::convert(), vpCannyEdgeDetection::detect(), vpCannyEdgeDetection::setGradients(), and vpCannyEdgeDetection::setMask().

◆ canny() [3/3]

void vpImageFilter::canny ( const vpImage< unsigned char > &  Isrc,
vpImage< unsigned char > &  Ires,
const unsigned int &  gaussianFilterSize,
const float &  thresholdCanny,
const unsigned int &  apertureSobel 
)
static

Apply the Canny edge operator on the image Isrc and return the resulting image Ires.

The following example shows how to use the method:

#include <visp3/core/vpImage.h>
#include <visp3/core/vpImageFilter.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main()
{
// Constants for the Canny operator.
const unsigned int gaussianFilterSize = 5;
const double thresholdCanny = 15;
const unsigned int apertureSobel = 3;
// Image for the Canny edge operator
// First grab the source image Isrc.
// Apply the Canny edge operator and set the Icanny image.
vpImageFilter::canny(Isrc, Icanny, gaussianFilterSize, thresholdCanny, apertureSobel);
return (0);
}
Parameters
[in]Isrc: Image to apply the Canny edge detector to.
[out]Ires: Filtered image (255 means an edge, 0 otherwise).
[in]gaussianFilterSize: The size of the mask of the Gaussian filter to apply (an odd number).
[in]thresholdCanny: The upper threshold for the Canny operator. Only value greater than this value are marked as an edge. If negative, it will be automatically computed, along with the lower threshold. Otherwise, the lower threshold will be set to one third of the thresholdCanny .
[in]apertureSobel: Size of the mask for the Sobel operator (odd number).
Examples
tutorial-canny.cpp, and tutorial-image-filter.cpp.

Definition at line 322 of file vpImageFilter_canny.cpp.

Referenced by canny(), vpCircleHoughTransform::edgeDetection(), and vpMeNurbs::seekExtremitiesCanny().

◆ computeCannyThreshold() [1/2]

float vpImageFilter::computeCannyThreshold ( const cv::Mat &  cv_I,
const cv::Mat *  p_cv_dIx,
const cv::Mat *  p_cv_dIy,
float &  lowerThresh,
const unsigned int &  gaussianKernelSize = 5,
const float &  gaussianStdev = 2.f,
const unsigned int &  apertureGradient = 3,
const float &  lowerThresholdRatio = 0.6,
const float &  upperThresholdRatio = 0.8,
const vpCannyFilteringAndGradientType filteringType = CANNY_GBLUR_SOBEL_FILTERING 
)
static

Compute the upper Canny edge filter threshold, using Gaussian blur + Sobel or + Scharr operators to compute the gradient of the image.

Parameters
[in]cv_I: The image, in cv format.
[in]p_cv_dIx: If different from nullptr, the gradient of cv_I with regard to the horizontal axis.
[in]p_cv_dIy: If different from nullptr, the gradient of cv_I with regard to the vertical axis.
[out]lowerThresh: The lower threshold for the Canny edge filter.
[in]gaussianKernelSize: The size of the mask of the Gaussian filter to apply (an odd number).
[in]gaussianStdev: The standard deviation of the Gaussian filter to apply.
[in]apertureGradient: Size of the mask for the Sobel operator (odd number).
[in]lowerThresholdRatio: The ratio of the upper threshold the lower threshold must be equal to.
[in]upperThresholdRatio: The ratio of pixels whose absolute gradient Gabs is lower or equal to to define
[in]filteringType: The gradient filter to apply to compute the gradient, if p_cv_dIx and p_cv_dIy are nullptr. the upper threshold.
Returns
The upper Canny edge filter threshold.

Definition at line 200 of file vpImageFilter_canny.cpp.

References computePartialDerivatives(), and vpException::fatalError.

Referenced by canny(), and vpCannyEdgeDetection::detect().

◆ computeCannyThreshold() [2/2]

template<typename OutType >
static float vpImageFilter::computeCannyThreshold ( const vpImage< unsigned char > &  I,
float &  lowerThresh,
const vpImage< OutType > *  p_dIx = nullptr,
const vpImage< OutType > *  p_dIy = nullptr,
const unsigned int &  gaussianKernelSize = 5,
const OutType &  gaussianStdev = 2.f,
const unsigned int &  apertureGradient = 3,
const float &  lowerThresholdRatio = 0.6f,
const float &  upperThresholdRatio = 0.8f,
const vpCannyFilteringAndGradientType filteringType = CANNY_GBLUR_SOBEL_FILTERING,
const vpImage< bool > *  p_mask = nullptr 
)
inlinestatic

Compute the upper Canny edge filter threshold, using Gaussian blur + Sobel or + Scharr operators to compute the gradient of the image.

Template Parameters
OutType: Either float, to accelerate the computation time, or double, to have greater precision.
Parameters
[in]I: The gray-scale image, in ViSP format.
[in]p_dIx: If different from nullptr, must contain the gradient of the image with regard to the horizontal axis.
[in]p_dIy: If different from nullptr, must contain the gradient of the image with regard to the vertical axis.
[in]lowerThresh: Canny lower threshold.
[in]gaussianKernelSize: The size of the mask of the Gaussian filter to apply (an odd number).
[in]gaussianStdev: The standard deviation of the Gaussian filter to apply.
[in]apertureGradient: Size of the mask for the Sobel operator (odd number).
[in]lowerThresholdRatio: The ratio of the upper threshold the lower threshold must be equal to.
[in]upperThresholdRatio: The ratio of pixels whose absolute gradient Gabs is lower or equal to define the upper threshold.
[in]filteringType: The gradient filter to apply to compute the gradient, if p_dIx and p_dIy are nullptr.
[in]p_mask: If different from nullptr , only the pixels for which p_mask is true will be considered.
Returns
The upper Canny edge filter threshold.

Definition at line 331 of file vpImageFilter.h.

References vpHistogram::calculate(), CANNY_VISP_BACKEND, vpException::fatalError, vpImage< Type >::getHeight(), vpHistogram::getTotal(), vpImage< Type >::getWidth(), and vpHistogram::setMask().

◆ computePartialDerivatives() [1/5]

void vpImageFilter::computePartialDerivatives ( const cv::Mat &  cv_I,
cv::Mat &  cv_dIx,
cv::Mat &  cv_dIy,
const bool &  computeDx = true,
const bool &  computeDy = true,
const bool &  normalize = true,
const unsigned int &  gaussianKernelSize = 5,
const float &  gaussianStdev = 2.f,
const unsigned int &  apertureGradient = 3,
const vpCannyFilteringAndGradientType filteringType = CANNY_GBLUR_SOBEL_FILTERING 
)
static

Compute the partial derivatives (i.e. horizontal and vertical gradients) of the input image.

Parameters
[in]cv_IThe input image we want the partial derivatives.
[out]cv_dIxThe horizontal partial derivative, i.e. horizontal gradient.
[out]cv_dIyThe vertical partial derivative, i.e. vertical gradient.
[in]computeDxIndicate if we must compute the horizontal gradient.
[in]computeDyIndicate if we must compute the vertical gradient.
[in]normalizeIndicate if we must normalize the gradient filters.
[in]gaussianKernelSizeThe size of the kernel of the Gaussian filter used to blur the image.
[in]gaussianStdevThe standard deviation of the Gaussian filter used to blur the image. If it is non-positive, it is computed from kernel size (gaussianKernelSize parameter) as $\sigma = 0.3*((gaussianKernelSize-1)*0.5 - 1) + 0.8$.
[in]apertureGradientThe size of the kernel of the gradient filter.
[in]filteringTypeThe type of filters to apply to compute the gradients.
Examples
tutorial-canny.cpp.

Definition at line 575 of file vpImageFilter.cpp.

References CANNY_GBLUR_SCHARR_FILTERING, and CANNY_GBLUR_SOBEL_FILTERING.

Referenced by canny(), and computeCannyThreshold().

◆ computePartialDerivatives() [2/5]

template<typename ImageType , typename FilterType >
static void vpImageFilter::computePartialDerivatives ( const vpImage< ImageType > &  I,
vpImage< FilterType > &  dIx,
vpImage< FilterType > &  dIy,
const bool &  computeDx = true,
const bool &  computeDy = true,
const bool &  normalize = true,
const unsigned int &  gaussianKernelSize = 5,
const FilterType &  gaussianStdev = 2.f,
const unsigned int &  apertureGradient = 3,
const vpCannyFilteringAndGradientType filteringType = CANNY_GBLUR_SOBEL_FILTERING,
const vpCannyBackendType backend = CANNY_VISP_BACKEND,
const vpImage< bool > *  p_mask = nullptr 
)
inlinestatic

Compute the partial derivatives (i.e. horizontal and vertical gradients) of the input image.

Template Parameters
ImageTypeEither unsigned char, float or double
FilterTypeEither float or double.
Parameters
[in]IThe input image we want the partial derivatives.
[out]dIxThe horizontal partial derivative, i.e. horizontal gradient.
[out]dIyThe vertical partial derivative, i.e. vertical gradient.
[in]computeDxIndicate if we must compute the horizontal gradient.
[in]computeDyIndicate if we must compute the vertical gradient.
[in]normalizeIndicate if we must normalize the gradient filters.
[in]gaussianKernelSizeThe size of the kernel of the Gaussian filter used to blur the image. If it is non-positive, it is computed from kernel size (gaussianKernelSize parameter) as $\sigma = 0.3*((gaussianKernelSize-1)*0.5 - 1) + 0.8$.
[in]gaussianStdevThe standard deviation of the Gaussian filter used to blur the image.
[in]apertureGradientThe size of the kernel of the gradient filter.
[in]filteringTypeThe type of filters to apply to compute the gradients.
[in]backendThe type of backend to use to compute the gradients.
[in]p_maskIf different from nullptr, mask indicating which points to consider (true) or to ignore(false).

Definition at line 153 of file vpImageFilter.h.

References vpException::badValue, vpImageConvert::convert(), vpArray2D< Type >::data, filter(), gaussianBlur(), vpArray2D< Type >::getCols(), vpImage< Type >::getHeight(), vpArray2D< Type >::getRows(), getScharrKernelX(), getScharrKernelY(), getSobelKernelX(), getSobelKernelY(), vpImage< Type >::getWidth(), vpException::notImplementedError, and vpImage< Type >::resize().

◆ computePartialDerivatives() [3/5]

template<typename ImageType >
static void vpImageFilter::computePartialDerivatives ( const vpImage< ImageType > &  I,
vpImage< unsigned char > &  dIx,
vpImage< unsigned char > &  dIy,
const bool &  computeDx = true,
const bool &  computeDy = true,
const bool &  normalize = true,
const unsigned int &  gaussianKernelSize = 5,
const unsigned char &  gaussianStdev = 2.f,
const unsigned int &  apertureGradient = 3,
const vpCannyFilteringAndGradientType filteringType = CANNY_GBLUR_SOBEL_FILTERING,
const vpCannyBackendType backend = CANNY_VISP_BACKEND,
const vpImage< bool > *  p_mask = nullptr 
)
inlinestatic

◆ computePartialDerivatives() [4/5]

template<typename ImageType >
static void vpImageFilter::computePartialDerivatives ( const vpImage< ImageType > &  I,
vpImage< vpRGBa > &  dIx,
vpImage< vpRGBa > &  dIy,
const bool &  computeDx = true,
const bool &  computeDy = true,
const bool &  normalize = true,
const unsigned int  gaussianKernelSize = 5,
const vpRGBa  gaussianStdev = vpRGBa(),
const unsigned int  apertureGradient = 3,
const vpCannyFilteringAndGradientType filteringType = CANNY_GBLUR_SOBEL_FILTERING,
const vpCannyBackendType backend = CANNY_VISP_BACKEND,
const vpImage< bool > *  p_mask = nullptr 
)
inlinestatic

◆ computePartialDerivatives() [5/5]

template<typename FilterType >
static void vpImageFilter::computePartialDerivatives ( const vpImage< vpRGBa > &  I,
vpImage< FilterType > &  dIx,
vpImage< FilterType > &  dIy,
const bool &  computeDx = true,
const bool &  computeDy = true,
const bool &  normalize = true,
const unsigned int &  gaussianKernelSize = 5,
const FilterType &  gaussianStdev = 2.f,
const unsigned int &  apertureGradient = 3,
const vpCannyFilteringAndGradientType filteringType = CANNY_GBLUR_SOBEL_FILTERING,
const vpCannyBackendType backend = CANNY_VISP_BACKEND,
const vpImage< bool > *  p_mask = nullptr 
)
inlinestatic

◆ derivativeFilterX() [1/2]

template<class ImageType >
static double vpImageFilter::derivativeFilterX ( const vpImage< ImageType > &  I,
unsigned int  r,
unsigned int  c 
)
inlinestatic

Apply a 1x3 derivative filter to an image pixel.

Parameters
I: Image to filter
r: coordinates (row) of the pixel
c: coordinates (column) of the pixel

Definition at line 426 of file vpImageFilter.h.

Referenced by vpFeatureLuminance::buildFrom(), and getGradX().

◆ derivativeFilterX() [2/2]

template<class ImageType , typename FilterType >
static FilterType vpImageFilter::derivativeFilterX ( const vpImage< ImageType > &  I,
unsigned int  r,
unsigned int  c,
const FilterType *  filter,
unsigned int  size 
)
inlinestatic

Apply a 1 x size Derivative Filter in X to an image pixel.

Template Parameters
FilterType: Either float, to accelerate the computation time, or double, to have greater precision.
Parameters
I: Image to filter
r: Coordinates(row) of the pixel
c: Coordinates(column) of the pixel
filter: Coefficients of the filter to be initialized using vpImageFilter::getGaussianDerivativeKernel().
size: Size of the filter.
See also
vpImageFilter::getGaussianDerivativeKernel()

Definition at line 461 of file vpImageFilter.h.

◆ derivativeFilterY() [1/2]

template<class ImageType >
static double vpImageFilter::derivativeFilterY ( const vpImage< ImageType > &  I,
unsigned int  r,
unsigned int  c 
)
inlinestatic

Apply a 3x1 derivative filter to an image pixel.

Parameters
I: Image to filter
r: coordinates (row) of the pixel
c: coordinates (column) of the pixel

Definition at line 440 of file vpImageFilter.h.

Referenced by vpFeatureLuminance::buildFrom(), and getGradY().

◆ derivativeFilterY() [2/2]

template<class ImageType , typename FilterType >
static FilterType vpImageFilter::derivativeFilterY ( const vpImage< ImageType > &  I,
unsigned int  r,
unsigned int  c,
const FilterType *  filter,
unsigned int  size 
)
inlinestatic

Apply a size x 1 Derivative Filter in Y to an image pixel.

Template Parameters
FilterType: Either float, to accelerate the computation time, or double, to have greater precision.
Parameters
I: Image to filter.
r: Coordinates (row) of the pixel.
c: Coordinates (column) of the pixel.
filter: Coefficients of the filter to be initialized using vpImageFilter::getGaussianDerivativeKernel().
size: Size of the filter.
See also
vpImageFilter::getGaussianDerivativeKernel()

Definition at line 489 of file vpImageFilter.h.

◆ filter() [1/7]

template<typename FilterType >
static FilterType vpImageFilter::filter ( const vpImage< FilterType > &  I,
const vpArray2D< FilterType > &  M,
unsigned int  row,
unsigned int  col 
)
inlinestatic

Apply a filter at a given image location.

Template Parameters
FilterTypeImage and filter types: double or float
Parameters
IThe input image
rowThe row coordinate where the filter should be applied
colThe column coordinate where the filter should be applied
Mthe filter

Definition at line 598 of file vpImageFilter.h.

References vpArray2D< Type >::getCols(), and vpArray2D< Type >::getRows().

◆ filter() [2/7]

template<typename ImageType , typename FilterType >
static void vpImageFilter::filter ( const vpImage< ImageType > &  I,
vpImage< FilterType > &  GI,
const FilterType *  filter,
unsigned int  size,
const vpImage< bool > *  p_mask = nullptr 
)
inlinestatic

Apply a separable filter.

Template Parameters
FilterType: Either float, to accelerate the computation time, or double, to have greater precision.
Parameters
IThe original image.
GIThe filtered image.
filterThe separable filter.
sizeThe size of the filter.
p_maskIf different from nullptr, mask indicating which points to consider (true) or to ignore(false).

Definition at line 722 of file vpImageFilter.h.

References vpImage< Type >::destroy().

◆ filter() [3/7]

template<typename ImageType , typename FilterType >
static void vpImageFilter::filter ( const vpImage< ImageType > &  I,
vpImage< FilterType > &  If,
const vpArray2D< FilterType > &  M,
bool  convolve = false,
const vpImage< bool > *  p_mask = nullptr 
)
inlinestatic

Apply a filter to an image.

Template Parameters
FilterType: Either float, to accelerate the computation time, or double, to have greater precision.
Parameters
I: Image to filter
If: Filtered image.
M: Filter kernel.
convolve: If true, perform a convolution otherwise a correlation.
p_mask: If different from nullptr, mask indicating which points to consider (true) or to ignore(false).
Note
By default it performs a correlation:

\[ \textbf{I\_filtered} \left( u,v \right) = \sum_{y=0}^{\textbf{kernel\_h}} \sum_{x=0}^{\textbf{kernel\_w}} \textbf{M} \left( x,y \right ) \times \textbf{I} \left( u-\frac{\textbf{kernel\_w}}{2}+x,v-\frac{\textbf{kernel\_h}}{2}+y \right) \]

The convolution is almost the same operation:

\[ \textbf{I\_filtered} \left( u,v \right) = \sum_{y=0}^{\textbf{kernel\_h}} \sum_{x=0}^{\textbf{kernel\_w}} \textbf{M} \left( x,y \right ) \times \textbf{I} \left( u+\frac{\textbf{kernel\_w}}{2}-x,v+\frac{\textbf{kernel\_h}}{2}-y \right) \]

Only pixels in the input image fully covered by the kernel are considered.
Examples
testImageFilter.cpp, and tutorial-image-filter.cpp.

Definition at line 533 of file vpImageFilter.h.

References vpArray2D< Type >::getCols(), vpImage< Type >::getHeight(), vpArray2D< Type >::getRows(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().

Referenced by vpCircleHoughTransform::computeGradients(), computePartialDerivatives(), filterX(), filterY(), vpTemplateTracker::getGaussianBluredImage(), vpTemplateTrackerMI::getMI(), vpTemplateTrackerMI::getMI256(), vpTemplateTrackerZNCCForwardAdditional::initHessienDesired(), vpTemplateTrackerZNCCInverseCompositional::initHessienDesired(), vpTemplateTrackerMIESM::initHessienDesired(), vpTemplateTrackerMIForwardAdditional::initHessienDesired(), vpTemplateTrackerMIForwardCompositional::initHessienDesired(), vpTemplateTrackerMIInverseCompositional::initHessienDesired(), vpTemplateTracker::initTracking(), vpTemplateTrackerSSDESM::trackNoPyr(), vpTemplateTrackerSSDForwardAdditional::trackNoPyr(), vpTemplateTrackerSSDForwardCompositional::trackNoPyr(), vpTemplateTrackerSSDInverseCompositional::trackNoPyr(), vpTemplateTrackerZNCCForwardAdditional::trackNoPyr(), vpTemplateTrackerZNCCInverseCompositional::trackNoPyr(), vpTemplateTrackerMIESM::trackNoPyr(), vpTemplateTrackerMIForwardAdditional::trackNoPyr(), vpTemplateTrackerMIForwardCompositional::trackNoPyr(), and vpTemplateTrackerMIInverseCompositional::trackNoPyr().

◆ filter() [4/7]

template<typename ImageType , typename FilterType >
static void vpImageFilter::filter ( const vpImage< ImageType > &  I,
vpImage< FilterType > &  Iu,
vpImage< FilterType > &  Iv,
const vpArray2D< FilterType > &  M,
bool  convolve = false,
const vpImage< bool > *  p_mask = nullptr 
)
inlinestatic

Apply a filter to an image:

\[ \textbf{I}_u = \textbf{M} \ast \textbf{I} \textbf{ and } \textbf{I}_v = \textbf{M}^t \ast \textbf{I} \]

Template Parameters
FilterType: Either float, to accelerate the computation time, or double, to have greater precision.
Parameters
I: Image to filter
Iu: Filtered image along the horizontal axis (u = columns).
Iv: Filtered image along the vertical axis (v = rows).
M: Filter kernel.
convolve: If true, perform a convolution otherwise a correlation.
p_mask: If different from nullptr, mask indicating which points to consider (true) or to ignore(false).

Definition at line 635 of file vpImageFilter.h.

References vpImage< Type >::getHeight(), vpArray2D< Type >::getRows(), vpImage< Type >::getWidth(), and vpImage< Type >::resize().

◆ filter() [5/7]

template<typename ImageType >
static void vpImageFilter::filter ( const vpImage< ImageType > &  I,
vpImage< ImageType > &  Iu,
vpImage< ImageType > &  Iv,
const vpArray2D< vpRGBa > &  M,
bool  convolve 
)
static

◆ filter() [6/7]

template<typename FilterType >
static void vpImageFilter::filter ( const vpImage< vpRGBa > &  I,
vpImage< FilterType > &  If,
const vpArray2D< FilterType > &  M,
bool  convolve = false 
)
static

◆ filter() [7/7]

template<typename FilterType >
static void vpImageFilter::filter ( const vpImage< vpRGBa > &  I,
vpImage< FilterType > &  Iu,
vpImage< FilterType > &  Iv,
const vpArray2D< FilterType > &  M,
bool  convolve 
)
static

◆ filterGaussXPyramidal()

static unsigned char vpImageFilter::filterGaussXPyramidal ( const vpImage< unsigned char > &  I,
unsigned int  i,
unsigned int  j 
)
inlinestatic

Definition at line 730 of file vpImageFilter.h.

Referenced by getGaussXPyramidal().

◆ filterGaussYPyramidal()

static unsigned char vpImageFilter::filterGaussYPyramidal ( const vpImage< unsigned char > &  I,
unsigned int  i,
unsigned int  j 
)
inlinestatic

Definition at line 735 of file vpImageFilter.h.

Referenced by getGaussYPyramidal().

◆ filterX() [1/3]

template<typename ImageType , typename FilterType >
static FilterType vpImageFilter::filterX ( const vpImage< ImageType > &  I,
unsigned int  r,
unsigned int  c,
const FilterType *  filter,
unsigned int  size 
)
inlinestatic

Definition at line 782 of file vpImageFilter.h.

◆ filterX() [2/3]

template<typename ImageType , typename FilterType >
static void vpImageFilter::filterX ( const vpImage< ImageType > &  I,
vpImage< FilterType > &  dIx,
const FilterType *  filter,
unsigned int  size,
const vpImage< bool > *  p_mask = nullptr 
)
inlinestatic

◆ filterX() [3/3]

void vpImageFilter::filterX ( const vpImage< vpRGBa > &  I,
vpImage< vpRGBa > &  dIx,
const double *  filter,
unsigned int  size,
const vpImage< bool > *  p_mask = nullptr 
)
static

◆ filterY() [1/3]

template<typename ImageType , typename FilterType >
static FilterType vpImageFilter::filterY ( const vpImage< ImageType > &  I,
unsigned int  r,
unsigned int  c,
const FilterType *  filter,
unsigned int  size 
)
inlinestatic

Definition at line 892 of file vpImageFilter.h.

◆ filterY() [2/3]

template<typename ImageType , typename FilterType >
static void vpImageFilter::filterY ( const vpImage< ImageType > &  I,
vpImage< FilterType > &  dIy,
const FilterType *  filter,
unsigned int  size,
const vpImage< bool > *  p_mask = nullptr 
)
inlinestatic

Definition at line 851 of file vpImageFilter.h.

References vpImage< Type >::getHeight(), and vpImage< Type >::getWidth().

◆ filterY() [3/3]

void vpImageFilter::filterY ( const vpImage< vpRGBa > &  I,
vpImage< vpRGBa > &  dIx,
const double *  filter,
unsigned int  size,
const vpImage< bool > *  p_mask = nullptr 
)
static

◆ gaussianBlur() [1/2]

template<typename ImageType , typename FilterType >
static void vpImageFilter::gaussianBlur ( const vpImage< ImageType > &  I,
vpImage< FilterType > &  GI,
unsigned int  size = 7,
FilterType  sigma = 0.,
bool  normalize = true,
const vpImage< bool > *  p_mask = nullptr 
)
inlinestatic

Apply a Gaussian blur to an image.

Template Parameters
FilterType: Either float, to accelerate the computation time, or double, to have greater precision.
Parameters
I: Input image.
GI: Filtered image.
size: Filter size. This value should be odd.
sigma: Gaussian standard deviation. If it is equal to zero or negative, it is computed from filter size as sigma = (size-1)/6.
normalize: Flag indicating whether to normalize the filter coefficients or not.
p_mask: If different from nullptr, mask indicating which points to consider (true) or to ignore(false).
See also
getGaussianKernel() to know which kernel is used.
Examples
grabV4l2MultiCpp11Thread.cpp, perfGaussianFilter.cpp, testImageFilter.cpp, and tutorial-image-filter.cpp.

Definition at line 971 of file vpImageFilter.h.

References vpImage< Type >::destroy().

Referenced by computePartialDerivatives(), VISP_NAMESPACE_NAME::gammaCorrectionSpatialBased(), VISP_NAMESPACE_NAME::MSRCR(), and VISP_NAMESPACE_NAME::unsharpMask().

◆ gaussianBlur() [2/2]

void vpImageFilter::gaussianBlur ( const vpImage< vpRGBa > &  I,
vpImage< vpRGBa > &  GI,
unsigned int  size = 7,
double  sigma = 0.,
bool  normalize = true,
const vpImage< bool > *  p_mask = nullptr 
)
static

Apply a Gaussian blur to RGB color image.

Parameters
[in]I: Input image.
[out]GI: Filtered image.
[in]size: Filter size. This value should be odd.
[in]sigma: Gaussian standard deviation. If it is equal to zero or negative, it is computed from filter size as sigma = (size-1)/6.
[in]normalize: Flag indicating whether to normalize the filter coefficients or not.
[in]p_mask: If different from nullptr, mask indicating which points to consider (true) or to ignore(false).
See also
getGaussianKernel() to know which kernel is used.

Definition at line 320 of file vpImageFilter.cpp.

References vpImage< Type >::destroy(), filterX(), filterY(), and getGaussianKernel().

◆ gaussianFilter()

template<class T >
static double vpImageFilter::gaussianFilter ( const vpImage< T > &  fr,
unsigned int  r,
unsigned int  c 
)
inlinestatic

Apply a 5x5 Gaussian filter to an image pixel.

Parameters
fr: Image to filter
r: coordinates (row) of the pixel
c: coordinates (column) of the pixel

Definition at line 993 of file vpImageFilter.h.

◆ getGaussianDerivativeKernel()

template<typename FilterType >
static void vpImageFilter::getGaussianDerivativeKernel ( FilterType *  filter,
unsigned int  size,
FilterType  sigma = 0.,
bool  normalize = true 
)
inlinestatic

Return the coefficients of a Gaussian derivative filter that may be used to compute spatial image derivatives after applying a Gaussian blur.

Template Parameters
FilterType: Either float, to accelerate the computation time, or double, to have greater precision.
Parameters
filter: Pointer to the filter kernel that should refer to a (size+1)/2 array. The first value refers to the central coefficient, the next one to the right coefficients. Left coefficients could be deduced by symmetry.
size: Filter size. This value should be odd.
sigma: Gaussian standard deviation. If it is equal to zero or negative, it is computed from filter size as sigma = (size-1)/6.
normalize: Flag indicating whether to normalize the filter coefficients or not.

Definition at line 1074 of file vpImageFilter.h.

References vpImageException::incorrectInitializationError, and vpMath::sqr().

Referenced by vpTemplateTracker::setGaussianFilterSize(), and vpTemplateTracker::vpTemplateTracker().

◆ getGaussianKernel()

template<typename FilterType >
static void vpImageFilter::getGaussianKernel ( FilterType *  filter,
unsigned int  size,
FilterType  sigma = 0.,
bool  normalize = true 
)
inlinestatic

Return the coefficients $G_i$ of a Gaussian filter.

Template Parameters
FilterType: Either float, to accelerate the computation time, or double, to have greater precision.
Parameters
[out]filter: Pointer to the half size filter kernel that should refer to a (size+1)/2 array. The first value refers to the central coefficient, the next one to the right coefficients. Left coefficients could be deduced by symmetry.
[in]size: Filter size. This value should be odd and positive.
[in]sigma: Gaussian standard deviation $ \sigma $. If it is equal to zero or negative, it is computed from filter size as sigma = (size-1)/6.
[in]normalize: Flag indicating whether to normalize the filter coefficients or not. In that case $\Sigma G_i = 1 $.

The function computes the (size+1)/2 values of the Gaussian filter coefficients $ G_i $ as:

\[ G_i = \frac{1}{\sigma \sqrt{2 \pi}} \exp{(-i^2 / (2. * \sigma^2))}\]

Definition at line 1026 of file vpImageFilter.h.

References vpImageException::incorrectInitializationError, and vpMath::sqr().

Referenced by gaussianBlur(), vpCircleHoughTransform::initGaussianFilters(), vpTemplateTracker::setGaussianFilterSize(), and vpTemplateTracker::vpTemplateTracker().

◆ getGaussPyramidal()

void vpImageFilter::getGaussPyramidal ( const vpImage< unsigned char > &  I,
vpImage< unsigned char > &  GI 
)
static

◆ getGaussXPyramidal()

void vpImageFilter::getGaussXPyramidal ( const vpImage< unsigned char > &  I,
vpImage< unsigned char > &  GI 
)
static

◆ getGaussYPyramidal()

void vpImageFilter::getGaussYPyramidal ( const vpImage< unsigned char > &  I,
vpImage< unsigned char > &  GI 
)
static

◆ getGradX() [1/2]

template<typename ImageType , typename FilterType >
static void vpImageFilter::getGradX ( const vpImage< ImageType > &  I,
vpImage< FilterType > &  dIx,
const FilterType *  filter,
unsigned int  size,
const vpImage< bool > *  p_mask = nullptr 
)
inlinestatic

Definition at line 1146 of file vpImageFilter.h.

References vpImage< Type >::getHeight(), and vpImage< Type >::getWidth().

◆ getGradX() [2/2]

template<typename FilterType >
static void vpImageFilter::getGradX ( const vpImage< unsigned char > &  I,
vpImage< FilterType > &  dIx,
const vpImage< bool > *  p_mask = nullptr 
)
inlinestatic

◆ getGradXGauss2D()

template<typename ImageType , typename FilterType >
static void vpImageFilter::getGradXGauss2D ( const vpImage< ImageType > &  I,
vpImage< FilterType > &  dIx,
const FilterType *  gaussianKernel,
const FilterType *  gaussianDerivativeKernel,
unsigned int  size,
const vpImage< bool > *  p_mask = nullptr 
)
inlinestatic

Compute the gradient along X after applying a gaussian filter along Y.

Template Parameters
FilterType: Either float, to accelerate the computation time, or double, to have greater precision.
Parameters
I: Input image
dIx: Gradient along X.
gaussianKernel: Gaussian kernel which values should be computed using vpImageFilter::getGaussianKernel().
gaussianDerivativeKernel: Gaussian derivative kernel which values should be computed using vpImageFilter::getGaussianDerivativeKernel().
size: Size of the Gaussian and Gaussian derivative kernels.
p_mask: If different from nullptr, mask indicating which points to consider (true) or to ignore(false).

Definition at line 1191 of file vpImageFilter.h.

Referenced by vpTemplateTrackerZNCCInverseCompositional::initCompInverse(), vpTemplateTrackerMIInverseCompositional::initCompInverse(), vpTemplateTrackerZNCCForwardAdditional::initHessienDesired(), vpTemplateTrackerZNCCInverseCompositional::initHessienDesired(), vpTemplateTrackerMIESM::initHessienDesired(), vpTemplateTrackerMIForwardAdditional::initHessienDesired(), vpTemplateTrackerMIForwardCompositional::initHessienDesired(), vpTemplateTracker::initTracking(), vpTemplateTrackerSSDESM::trackNoPyr(), vpTemplateTrackerSSDForwardAdditional::trackNoPyr(), vpTemplateTrackerSSDForwardCompositional::trackNoPyr(), vpTemplateTrackerZNCCForwardAdditional::trackNoPyr(), vpTemplateTrackerMIESM::trackNoPyr(), vpTemplateTrackerMIForwardAdditional::trackNoPyr(), and vpTemplateTrackerMIForwardCompositional::trackNoPyr().

◆ getGradY() [1/2]

template<typename ImageType , typename FilterType >
static void vpImageFilter::getGradY ( const vpImage< ImageType > &  I,
vpImage< FilterType > &  dIy,
const FilterType *  filter,
unsigned int  size,
const vpImage< bool > *  p_mask = nullptr 
)
inlinestatic

Definition at line 1240 of file vpImageFilter.h.

References vpImage< Type >::getHeight(), and vpImage< Type >::getWidth().

◆ getGradY() [2/2]

template<typename FilterType >
static void vpImageFilter::getGradY ( const vpImage< unsigned char > &  I,
vpImage< FilterType > &  dIy,
const vpImage< bool > *  p_mask = nullptr 
)
inlinestatic

◆ getGradYGauss2D()

template<typename ImageType , typename FilterType >
static void vpImageFilter::getGradYGauss2D ( const vpImage< ImageType > &  I,
vpImage< FilterType > &  dIy,
const FilterType *  gaussianKernel,
const FilterType *  gaussianDerivativeKernel,
unsigned int  size,
const vpImage< bool > *  p_mask = nullptr 
)
inlinestatic

Compute the gradient along Y after applying a gaussian filter along X.

Template Parameters
FilterType: Either float, to accelerate the computation time, or double, to have greater precision.
Parameters
I: Input image
dIy: Gradient along Y.
gaussianKernel: Gaussian kernel which values should be computed using vpImageFilter::getGaussianKernel().
gaussianDerivativeKernel: Gaussian derivative kernel which values should be computed using vpImageFilter::getGaussianDerivativeKernel().
size: Size of the Gaussian and Gaussian derivative kernels.
p_mask: If different from nullptr, mask indicating which points to consider (true) or to ignore(false).

Definition at line 1291 of file vpImageFilter.h.

Referenced by vpTemplateTrackerZNCCInverseCompositional::initCompInverse(), vpTemplateTrackerMIInverseCompositional::initCompInverse(), vpTemplateTrackerZNCCForwardAdditional::initHessienDesired(), vpTemplateTrackerZNCCInverseCompositional::initHessienDesired(), vpTemplateTrackerMIESM::initHessienDesired(), vpTemplateTrackerMIForwardAdditional::initHessienDesired(), vpTemplateTrackerMIForwardCompositional::initHessienDesired(), vpTemplateTracker::initTracking(), vpTemplateTrackerSSDESM::trackNoPyr(), vpTemplateTrackerSSDForwardAdditional::trackNoPyr(), vpTemplateTrackerSSDForwardCompositional::trackNoPyr(), vpTemplateTrackerZNCCForwardAdditional::trackNoPyr(), vpTemplateTrackerMIESM::trackNoPyr(), vpTemplateTrackerMIForwardAdditional::trackNoPyr(), and vpTemplateTrackerMIForwardCompositional::trackNoPyr().

◆ getScharrKernelX()

template<typename FilterType >
static FilterType vpImageFilter::getScharrKernelX ( FilterType *  filter,
unsigned int  size 
)
inlinestatic

Get Scharr kernel for X-direction.

Template Parameters
FilterTypeEither float, to accelerate the computation time, or double, to have greater precision.
Parameters
filter: Pointer to a double array already allocated.
size: Kernel size computed as: kernel_size = size*2 + 1 (max size is 20).
Returns
Scaling factor to normalize the Scharr kernel.

Definition at line 1307 of file vpImageFilter.h.

References vpArray2D< Type >::data, vpException::dimensionError, vpArray2D< Type >::getCols(), vpArray2D< Type >::getRows(), and vpArray2D< Type >::t().

Referenced by computePartialDerivatives(), and vpCircleHoughTransform::initGradientFilters().

◆ getScharrKernelY()

template<typename FilterType >
static FilterType vpImageFilter::getScharrKernelY ( FilterType *  filter,
unsigned int  size 
)
inlinestatic

Get Scharr kernel for Y-direction.

Template Parameters
FilterType: Either float, to accelerate the computation time, or double, to have greater precision.
Parameters
filter: Pointer to a double array already allocated.
size: Kernel size computed as: kernel_size = size*2 + 1 (max size is 20).
Returns
Scaling factor to normalize the Scharr kernel.

Definition at line 1331 of file vpImageFilter.h.

References vpException::dimensionError.

Referenced by computePartialDerivatives(), and vpCircleHoughTransform::initGradientFilters().

◆ getSobelKernelX()

template<typename FilterType >
static FilterType vpImageFilter::getSobelKernelX ( FilterType *  filter,
unsigned int  size 
)
inlinestatic

Get Sobel kernel for X-direction.

Template Parameters
FilterTypeEither float, to accelerate the computation time, or double, to have greater precision.
Parameters
filter: Pointer to a double array already allocated.
size: Kernel size computed as: kernel_size = size*2 + 1 (max size is 20).
Returns
Scaling factor to normalize the Sobel kernel.
Examples
testImageFilter.cpp.

Definition at line 1361 of file vpImageFilter.h.

References vpArray2D< Type >::data, vpException::dimensionError, vpArray2D< Type >::getCols(), vpArray2D< Type >::getRows(), and vpArray2D< Type >::t().

Referenced by computePartialDerivatives(), vpCircleHoughTransform::initGradientFilters(), vpMbTracker::setProjectionErrorKernelSize(), and vpMbTracker::vpMbTracker().

◆ getSobelKernelY()

template<typename FilterType >
static FilterType vpImageFilter::getSobelKernelY ( FilterType *  filter,
unsigned int  size 
)
inlinestatic

Get Sobel kernel for Y-direction.

Template Parameters
FilterType: Either float, to accelerate the computation time, or double, to have greater precision.
Parameters
filter: Pointer to a double array already allocated.
size: Kernel size computed as: kernel_size = size*2 + 1 (max size is 20).
Returns
Scaling factor to normalize the Sobel kernel.

Definition at line 1386 of file vpImageFilter.h.

References vpArray2D< Type >::conv2(), vpArray2D< Type >::data, vpException::dimensionError, vpArray2D< Type >::getCols(), and vpArray2D< Type >::getRows().

Referenced by computePartialDerivatives(), vpCircleHoughTransform::initGradientFilters(), vpMbTracker::setProjectionErrorKernelSize(), and vpMbTracker::vpMbTracker().

◆ median() [1/3]

float vpImageFilter::median ( const cv::Mat &  channel)
static

Calculates the median value of a single channel. The algorithm is based on based on https://github.com/arnaudgelas/OpenCVExamples/blob/master/cvMat/Statistics/Median/Median.cpp.

Parameters
[in]channel: Single channel image in OpenCV format.
Examples
testImageFilter.cpp.

Definition at line 494 of file vpImageFilter.cpp.

Referenced by median().

◆ median() [2/3]

float vpImageFilter::median ( const vpImage< unsigned char > &  Isrc)
static

Calculates the median value of a single channel. The algorithm is based on based on https://github.com/arnaudgelas/OpenCVExamples/blob/master/cvMat/Statistics/Median/Median.cpp.

Parameters
[in]Isrc: Gray-level image in ViSP format.
Returns
Gray level image median value.
See also
vpImageFilter::median(const cv::Mat)

Definition at line 527 of file vpImageFilter.cpp.

References vpImageConvert::convert(), and median().

◆ median() [3/3]

std::vector< float > vpImageFilter::median ( const vpImage< vpRGBa > &  Isrc)
static

Calculates the median value of a vpRGBa image. The result is ordered in RGB format.

Parameters
[in]Isrc: RGB image in ViSP format. Alpha channel is ignored.
Returns
std::vector<float> meds such as meds[0] = red-channel-median, meds[1] = green-channel-median and meds[2] = blue-channel-median.
See also
vpImageFilter::median(const cv::Mat)

Definition at line 542 of file vpImageFilter.cpp.

References vpImageConvert::convert(), and median().

◆ sepFilter()

BEGIN_VISP_NAMESPACE void vpImageFilter::sepFilter ( const vpImage< unsigned char > &  I,
vpImage< double > &  If,
const vpColVector kernelH,
const vpColVector kernelV 
)
static

Apply a filter to an image using two separable kernels. For instance, the Sobel kernel can be decomposed to:

\[ \left [ \begin{matrix} 1 & 0 & -1 \\ 2 & 0 & -2 \\ 1 & 0 & -1 \end{matrix} \right ] = \left [ \begin{matrix} 1 \\ 2 \\ 1 \end{matrix} \right ] \ast \left [ \begin{matrix} 1 & 0 & -1 \end{matrix} \right ] \]

Thus, the convolution operation can be performed as:

\[ G_x = \left [ \begin{matrix} 1 \\ 2 \\ 1 \end{matrix} \right ] \ast \left ( \left [ \begin{matrix} 1 & 0 & -1 \end{matrix} \right ] \ast I \right ) \]

Using two separable kernels reduce the number of operations and can be faster for large kernels.

Parameters
[in]I: Image to filter
[out]If: Filtered image.
[in]kernelH: Separable kernel (performed first).
[in]kernelV: Separable kernel (performed last).
Note
Only pixels in the input image fully covered by the kernel are considered.
Examples
testImageFilter.cpp.

Definition at line 129 of file vpImageFilter.cpp.

References vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpImage< Type >::resize(), and vpArray2D< Type >::size().

◆ vpCannyBackendTypeFromString()

vpImageFilter::vpCannyBackendType vpImageFilter::vpCannyBackendTypeFromString ( const std::string &  name)
static

Cast a string into a vpImageFilter::vpCannyBackendTypeToString.

Parameters
[in]nameThe name of the backend.
Returns
vpImageFilter::vpCannyBackendTypeToString The corresponding enumeration value.
Examples
tutorial-canny.cpp, and tutorial-circle-hough.cpp.

Definition at line 93 of file vpImageFilter_canny.cpp.

References CANNY_COUNT_BACKEND, vpIoTools::toLowerCase(), and vpCannyBackendTypeToString().

◆ vpCannyBackendTypeList()

BEGIN_VISP_NAMESPACE std::string vpImageFilter::vpCannyBackendTypeList ( const std::string &  pref = "<",
const std::string &  sep = " , ",
const std::string &  suf = ">" 
)
static

Get the list of available vpCannyBackendType.

Parameters
[in]prefThe prefix of the list.
[in]sepThe separator between two elements of the list.
[in]sufThe suffix of the list.
Returns
std::string The list of available items.
Examples
tutorial-canny.cpp, and tutorial-circle-hough.cpp.

Definition at line 49 of file vpImageFilter_canny.cpp.

References CANNY_COUNT_BACKEND, and vpCannyBackendTypeToString().

◆ vpCannyBackendTypeToString()

std::string vpImageFilter::vpCannyBackendTypeToString ( const vpCannyBackendType type)
static

Cast a vpImageFilter::vpCannyBackendTypeToString into a string, to know its name.

Parameters
[in]typeThe type that must be casted into a string.
Returns
std::string The corresponding name.
Examples
tutorial-canny.cpp, and tutorial-circle-hough.cpp.

Definition at line 70 of file vpImageFilter_canny.cpp.

References CANNY_COUNT_BACKEND, CANNY_OPENCV_BACKEND, and CANNY_VISP_BACKEND.

Referenced by vpCircleHoughTransform::vpCircleHoughTransformParams::toString(), vpCannyBackendTypeFromString(), and vpCannyBackendTypeList().

◆ vpCannyFiltAndGradTypeFromStr()

vpImageFilter::vpCannyFilteringAndGradientType vpImageFilter::vpCannyFiltAndGradTypeFromStr ( const std::string &  name)
static

Cast a string into a vpImageFilter::vpCannyFilteringAndGradientType.

Parameters
[in]nameThe name of the backend.
Returns
vpImageFilter::vpCannyFilteringAndGradientType The corresponding enumeration value.
Examples
tutorial-canny.cpp, and tutorial-circle-hough.cpp.

Definition at line 163 of file vpImageFilter_canny.cpp.

References CANNY_COUNT_FILTERING, vpIoTools::toLowerCase(), and vpCannyFiltAndGradTypeToStr().

◆ vpCannyFiltAndGradTypeToStr()

std::string vpImageFilter::vpCannyFiltAndGradTypeToStr ( const vpCannyFilteringAndGradientType type)
static

◆ vpGetCannyFiltAndGradTypes()

std::string vpImageFilter::vpGetCannyFiltAndGradTypes ( const std::string &  pref = "<",
const std::string &  sep = " , ",
const std::string &  suf = ">" 
)
static

Get the list of available vpCannyFilteringAndGradientType.

Parameters
[in]prefThe prefix of the list.
[in]sepThe separator between two elements of the list.
[in]sufThe suffix of the list.
Returns
std::string The list of available items.
Examples
tutorial-canny.cpp, and tutorial-circle-hough.cpp.

Definition at line 119 of file vpImageFilter_canny.cpp.

References CANNY_COUNT_FILTERING, and vpCannyFiltAndGradTypeToStr().