ImageFilter¶
- class ImageFilter¶
Bases:
pybind11_object
Various image filter, convolution, etc…
Methods
Overloaded function.
Overloaded function.
Overloaded function.
Overloaded function.
Apply a filter to an image using two separable kernels.
Cast a string into a ** vpImageFilter::vpCannyBackendTypeToString ** .
Get the list of available vpCannyBackendType.
Cast a string into a ** vpImageFilter::vpCannyFilteringAndGradientType ** .
Get the list of available vpCannyFilteringAndGradientType.
Inherited Methods
Operators
__doc__
__module__
Attributes
CANNY_COUNT_BACKEND
CANNY_COUNT_FILTERING
CANNY_GBLUR_SCHARR_FILTERING
CANNY_GBLUR_SOBEL_FILTERING
CANNY_OPENCV_BACKEND
CANNY_VISP_BACKEND
__annotations__
- class CannyBackendType(self, value: int)¶
Bases:
pybind11_object
Canny filter and gradient operators to apply on the image before the edge detection stage.
Values:
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
- class CannyFilteringAndGradientType(self, value: int)¶
Bases:
pybind11_object
Canny filter and gradient operators to apply on the image before the edge detection stage.
Values:
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
- __init__(*args, **kwargs)¶
- static canny(*args, **kwargs)¶
Overloaded function.
canny(I: visp._visp.core.ImageGray, Ic: visp._visp.core.ImageGray, gaussianFilterSize: int, thresholdCanny: float, apertureSobel: int) -> None
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 vpImage<unsigned char> Isrc; vpImage<unsigned char> Icanny; // 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:
- gaussianFilterSize
The size of the mask of the Gaussian filter to apply (an odd number).
- 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 .
- apertureSobel
Size of the mask for the Sobel operator (odd number).
canny(I: visp._visp.core.ImageGray, Ic: visp._visp.core.ImageGray, gaussianFilterSize: int, lowerThresholdCanny: float, higherThresholdCanny: float, apertureSobel: int) -> None
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 vpImage<unsigned char> Isrc; vpImage<unsigned char> Icanny; // 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); }
- Parameters:
- gaussianFilterSize
The size of the mask of the Gaussian filter to apply (an odd number).
- apertureSobel
Size of the mask for the Sobel operator (odd number).
- static computePartialDerivatives(cv_I: cv::Mat, cv_dIx: cv::Mat, cv_dIy: cv::Mat, computeDx: bool = true, computeDy: bool = true, normalize: bool = true, gaussianKernelSize: int = 5, gaussianStdev: float = 2.f, apertureGradient: int = 3, filteringType: visp._visp.core.ImageFilter.CannyFilteringAndGradientType = CANNY_GBLUR_SOBEL_FILTERING) None ¶
- static derivativeFilterX(*args, **kwargs)¶
Overloaded function.
derivativeFilterX(I: visp._visp.core.ImageGray, r: int, c: int) -> float
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
derivativeFilterX(I: visp._visp.core.ImageFloat, r: int, c: int) -> float
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
derivativeFilterX(I: visp._visp.core.ImageDouble, r: int, c: int) -> float
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
- static derivativeFilterY(*args, **kwargs)¶
Overloaded function.
derivativeFilterY(I: visp._visp.core.ImageGray, r: int, c: int) -> float
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
derivativeFilterY(I: visp._visp.core.ImageFloat, r: int, c: int) -> float
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
derivativeFilterY(I: visp._visp.core.ImageDouble, r: int, c: int) -> float
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
- static filterGaussXPyramidal(I: visp._visp.core.ImageGray, i: int, j: int) int ¶
- static filterGaussYPyramidal(I: visp._visp.core.ImageGray, i: int, j: int) int ¶
- static getGaussPyramidal(I: visp._visp.core.ImageGray, GI: visp._visp.core.ImageGray) None ¶
- static getGaussXPyramidal(I: visp._visp.core.ImageGray, GI: visp._visp.core.ImageGray) None ¶
- static getGaussYPyramidal(I: visp._visp.core.ImageGray, GI: visp._visp.core.ImageGray) None ¶
- static median(*args, **kwargs)¶
Overloaded function.
median(cv_I: cv::Mat) -> float
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 .
median(Isrc: visp._visp.core.ImageGray) -> float
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 .
Note
See vpImageFilter::median(const cv::Mat)
- Parameters:
- Isrc
Gray-level image in ViSP format.
- Returns:
Gray level image median value.
median(Isrc: visp._visp.core.ImageRGBa) -> list[float]
Calculates the median value of a vpRGBa image. The result is ordered in RGB format.
Note
See vpImageFilter::median(const cv::Mat)
- Parameters:
- 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.
- static sepFilter(I: visp._visp.core.ImageGray, If: visp._visp.core.ImageDouble, kernelH: visp._visp.core.ColVector, kernelV: visp._visp.core.ColVector) None ¶
Apply a filter to an image using two separable kernels. For instance, the Sobel kernel can be decomposed to:
\[\begin{split}\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 ] \end{split}\]Thus, the convolution operation can be performed as:
\[\begin{split}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 ) \end{split}\]Using two separable kernels reduce the number of operations and can be faster for large kernels.
Note
Only pixels in the input image fully covered by the kernel are considered.
- Parameters:
- I: visp._visp.core.ImageGray¶
Image to filter
- If: visp._visp.core.ImageDouble¶
Filtered image.
- kernelH: visp._visp.core.ColVector¶
Separable kernel (performed first).
- kernelV: visp._visp.core.ColVector¶
Separable kernel (performed last).
- static vpCannyBackendTypeFromString(name: str) visp._visp.core.ImageFilter.CannyBackendType ¶
Cast a string into a ** vpImageFilter::vpCannyBackendTypeToString ** .
- static vpCannyBackendTypeList(pref: str = <, sep: str =, suf: str = >) str ¶
Get the list of available vpCannyBackendType.
- Parameters:
- pref
The prefix of the list.
- sep
The separator between two elements of the list.
- suf
The suffix of the list.
- Returns:
std::string The list of available items.
- static vpCannyBackendTypeToString(type: visp._visp.core.ImageFilter.CannyBackendType) str ¶
- static vpCannyFiltAndGradTypeFromStr(name: str) visp._visp.core.ImageFilter.CannyFilteringAndGradientType ¶
Cast a string into a ** vpImageFilter::vpCannyFilteringAndGradientType ** .
- static vpCannyFiltAndGradTypeToStr(type: visp._visp.core.ImageFilter.CannyFilteringAndGradientType) str ¶
- static vpGetCannyFiltAndGradTypes(pref: str = <, sep: str =, suf: str = >) str ¶
Get the list of available vpCannyFilteringAndGradientType.
- Parameters:
- pref
The prefix of the list.
- sep
The separator between two elements of the list.
- suf
The suffix of the list.
- Returns:
std::string The list of available items.