Class Imgproc

java.lang.Object
org.opencv.imgproc.Imgproc

public class Imgproc
extends Object
  • Field Details

  • Constructor Details

  • Method Details

    • createLineSegmentDetector

      public static LineSegmentDetector createLineSegmentDetector​(int refine, double scale, double sigma_scale, double quant, double ang_th, double log_eps, double density_th, int n_bins)
      Creates a smart pointer to a LineSegmentDetector object and initializes it. The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want to edit those, as to tailor it for their own application.
      Parameters:
      refine - The way found lines will be refined, see #LineSegmentDetectorModes
      scale - The scale of the image that will be used to find the lines. Range (0..1].
      sigma_scale - Sigma for Gaussian filter. It is computed as sigma = sigma_scale/scale.
      quant - Bound to the quantization error on the gradient norm.
      ang_th - Gradient angle tolerance in degrees.
      log_eps - Detection threshold: -log10(NFA) > log_eps. Used only when advance refinement is chosen.
      density_th - Minimal density of aligned region points in the enclosing rectangle.
      n_bins - Number of bins in pseudo-ordering of gradient modulus.
      Returns:
      automatically generated
    • createLineSegmentDetector

      public static LineSegmentDetector createLineSegmentDetector​(int refine, double scale, double sigma_scale, double quant, double ang_th, double log_eps, double density_th)
      Creates a smart pointer to a LineSegmentDetector object and initializes it. The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want to edit those, as to tailor it for their own application.
      Parameters:
      refine - The way found lines will be refined, see #LineSegmentDetectorModes
      scale - The scale of the image that will be used to find the lines. Range (0..1].
      sigma_scale - Sigma for Gaussian filter. It is computed as sigma = sigma_scale/scale.
      quant - Bound to the quantization error on the gradient norm.
      ang_th - Gradient angle tolerance in degrees.
      log_eps - Detection threshold: -log10(NFA) > log_eps. Used only when advance refinement is chosen.
      density_th - Minimal density of aligned region points in the enclosing rectangle.
      Returns:
      automatically generated
    • createLineSegmentDetector

      public static LineSegmentDetector createLineSegmentDetector​(int refine, double scale, double sigma_scale, double quant, double ang_th, double log_eps)
      Creates a smart pointer to a LineSegmentDetector object and initializes it. The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want to edit those, as to tailor it for their own application.
      Parameters:
      refine - The way found lines will be refined, see #LineSegmentDetectorModes
      scale - The scale of the image that will be used to find the lines. Range (0..1].
      sigma_scale - Sigma for Gaussian filter. It is computed as sigma = sigma_scale/scale.
      quant - Bound to the quantization error on the gradient norm.
      ang_th - Gradient angle tolerance in degrees.
      log_eps - Detection threshold: -log10(NFA) > log_eps. Used only when advance refinement is chosen.
      Returns:
      automatically generated
    • createLineSegmentDetector

      public static LineSegmentDetector createLineSegmentDetector​(int refine, double scale, double sigma_scale, double quant, double ang_th)
      Creates a smart pointer to a LineSegmentDetector object and initializes it. The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want to edit those, as to tailor it for their own application.
      Parameters:
      refine - The way found lines will be refined, see #LineSegmentDetectorModes
      scale - The scale of the image that will be used to find the lines. Range (0..1].
      sigma_scale - Sigma for Gaussian filter. It is computed as sigma = sigma_scale/scale.
      quant - Bound to the quantization error on the gradient norm.
      ang_th - Gradient angle tolerance in degrees.
      Returns:
      automatically generated
    • createLineSegmentDetector

      public static LineSegmentDetector createLineSegmentDetector​(int refine, double scale, double sigma_scale, double quant)
      Creates a smart pointer to a LineSegmentDetector object and initializes it. The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want to edit those, as to tailor it for their own application.
      Parameters:
      refine - The way found lines will be refined, see #LineSegmentDetectorModes
      scale - The scale of the image that will be used to find the lines. Range (0..1].
      sigma_scale - Sigma for Gaussian filter. It is computed as sigma = sigma_scale/scale.
      quant - Bound to the quantization error on the gradient norm.
      Returns:
      automatically generated
    • createLineSegmentDetector

      public static LineSegmentDetector createLineSegmentDetector​(int refine, double scale, double sigma_scale)
      Creates a smart pointer to a LineSegmentDetector object and initializes it. The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want to edit those, as to tailor it for their own application.
      Parameters:
      refine - The way found lines will be refined, see #LineSegmentDetectorModes
      scale - The scale of the image that will be used to find the lines. Range (0..1].
      sigma_scale - Sigma for Gaussian filter. It is computed as sigma = sigma_scale/scale.
      Returns:
      automatically generated
    • createLineSegmentDetector

      public static LineSegmentDetector createLineSegmentDetector​(int refine, double scale)
      Creates a smart pointer to a LineSegmentDetector object and initializes it. The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want to edit those, as to tailor it for their own application.
      Parameters:
      refine - The way found lines will be refined, see #LineSegmentDetectorModes
      scale - The scale of the image that will be used to find the lines. Range (0..1].
      Returns:
      automatically generated
    • createLineSegmentDetector

      public static LineSegmentDetector createLineSegmentDetector​(int refine)
      Creates a smart pointer to a LineSegmentDetector object and initializes it. The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want to edit those, as to tailor it for their own application.
      Parameters:
      refine - The way found lines will be refined, see #LineSegmentDetectorModes
      Returns:
      automatically generated
    • createLineSegmentDetector

      Creates a smart pointer to a LineSegmentDetector object and initializes it. The LineSegmentDetector algorithm is defined using the standard values. Only advanced users may want to edit those, as to tailor it for their own application.
      Returns:
      automatically generated
    • getGaussianKernel

      public static Mat getGaussianKernel​(int ksize, double sigma, int ktype)
      Returns Gaussian filter coefficients. The function computes and returns the \(\texttt{ksize} \times 1\) matrix of Gaussian filter coefficients: \(G_i= \alpha *e^{-(i-( \texttt{ksize} -1)/2)^2/(2* \texttt{sigma}^2)},\) where \(i=0..\texttt{ksize}-1\) and \(\alpha\) is the scale factor chosen so that \(\sum_i G_i=1\). Two of such generated kernels can be passed to sepFilter2D. Those functions automatically recognize smoothing kernels (a symmetrical kernel with sum of weights equal to 1) and handle them accordingly. You may also use the higher-level GaussianBlur.
      Parameters:
      ksize - Aperture size. It should be odd ( \(\texttt{ksize} \mod 2 = 1\) ) and positive.
      sigma - Gaussian standard deviation. If it is non-positive, it is computed from ksize as sigma = 0.3*((ksize-1)*0.5 - 1) + 0.8.
      ktype - Type of filter coefficients. It can be CV_32F or CV_64F . SEE: sepFilter2D, getDerivKernels, getStructuringElement, GaussianBlur
      Returns:
      automatically generated
    • getGaussianKernel

      public static Mat getGaussianKernel​(int ksize, double sigma)
      Returns Gaussian filter coefficients. The function computes and returns the \(\texttt{ksize} \times 1\) matrix of Gaussian filter coefficients: \(G_i= \alpha *e^{-(i-( \texttt{ksize} -1)/2)^2/(2* \texttt{sigma}^2)},\) where \(i=0..\texttt{ksize}-1\) and \(\alpha\) is the scale factor chosen so that \(\sum_i G_i=1\). Two of such generated kernels can be passed to sepFilter2D. Those functions automatically recognize smoothing kernels (a symmetrical kernel with sum of weights equal to 1) and handle them accordingly. You may also use the higher-level GaussianBlur.
      Parameters:
      ksize - Aperture size. It should be odd ( \(\texttt{ksize} \mod 2 = 1\) ) and positive.
      sigma - Gaussian standard deviation. If it is non-positive, it is computed from ksize as sigma = 0.3*((ksize-1)*0.5 - 1) + 0.8. SEE: sepFilter2D, getDerivKernels, getStructuringElement, GaussianBlur
      Returns:
      automatically generated
    • getDerivKernels

      public static void getDerivKernels​(Mat kx, Mat ky, int dx, int dy, int ksize, boolean normalize, int ktype)
      Returns filter coefficients for computing spatial image derivatives. The function computes and returns the filter coefficients for spatial image derivatives. When ksize=FILTER_SCHARR, the Scharr \(3 \times 3\) kernels are generated (see #Scharr). Otherwise, Sobel kernels are generated (see #Sobel). The filters are normally passed to #sepFilter2D or to
      Parameters:
      kx - Output matrix of row filter coefficients. It has the type ktype .
      ky - Output matrix of column filter coefficients. It has the type ktype .
      dx - Derivative order in respect of x.
      dy - Derivative order in respect of y.
      ksize - Aperture size. It can be FILTER_SCHARR, 1, 3, 5, or 7.
      normalize - Flag indicating whether to normalize (scale down) the filter coefficients or not. Theoretically, the coefficients should have the denominator \(=2^{ksize*2-dx-dy-2}\). If you are going to filter floating-point images, you are likely to use the normalized kernels. But if you compute derivatives of an 8-bit image, store the results in a 16-bit image, and wish to preserve all the fractional bits, you may want to set normalize=false .
      ktype - Type of filter coefficients. It can be CV_32f or CV_64F .
    • getDerivKernels

      public static void getDerivKernels​(Mat kx, Mat ky, int dx, int dy, int ksize, boolean normalize)
      Returns filter coefficients for computing spatial image derivatives. The function computes and returns the filter coefficients for spatial image derivatives. When ksize=FILTER_SCHARR, the Scharr \(3 \times 3\) kernels are generated (see #Scharr). Otherwise, Sobel kernels are generated (see #Sobel). The filters are normally passed to #sepFilter2D or to
      Parameters:
      kx - Output matrix of row filter coefficients. It has the type ktype .
      ky - Output matrix of column filter coefficients. It has the type ktype .
      dx - Derivative order in respect of x.
      dy - Derivative order in respect of y.
      ksize - Aperture size. It can be FILTER_SCHARR, 1, 3, 5, or 7.
      normalize - Flag indicating whether to normalize (scale down) the filter coefficients or not. Theoretically, the coefficients should have the denominator \(=2^{ksize*2-dx-dy-2}\). If you are going to filter floating-point images, you are likely to use the normalized kernels. But if you compute derivatives of an 8-bit image, store the results in a 16-bit image, and wish to preserve all the fractional bits, you may want to set normalize=false .
    • getDerivKernels

      public static void getDerivKernels​(Mat kx, Mat ky, int dx, int dy, int ksize)
      Returns filter coefficients for computing spatial image derivatives. The function computes and returns the filter coefficients for spatial image derivatives. When ksize=FILTER_SCHARR, the Scharr \(3 \times 3\) kernels are generated (see #Scharr). Otherwise, Sobel kernels are generated (see #Sobel). The filters are normally passed to #sepFilter2D or to
      Parameters:
      kx - Output matrix of row filter coefficients. It has the type ktype .
      ky - Output matrix of column filter coefficients. It has the type ktype .
      dx - Derivative order in respect of x.
      dy - Derivative order in respect of y.
      ksize - Aperture size. It can be FILTER_SCHARR, 1, 3, 5, or 7. Theoretically, the coefficients should have the denominator \(=2^{ksize*2-dx-dy-2}\). If you are going to filter floating-point images, you are likely to use the normalized kernels. But if you compute derivatives of an 8-bit image, store the results in a 16-bit image, and wish to preserve all the fractional bits, you may want to set normalize=false .
    • getGaborKernel

      public static Mat getGaborKernel​(Size ksize, double sigma, double theta, double lambd, double gamma, double psi, int ktype)
      Returns Gabor filter coefficients. For more details about gabor filter equations and parameters, see: [Gabor Filter](http://en.wikipedia.org/wiki/Gabor_filter).
      Parameters:
      ksize - Size of the filter returned.
      sigma - Standard deviation of the gaussian envelope.
      theta - Orientation of the normal to the parallel stripes of a Gabor function.
      lambd - Wavelength of the sinusoidal factor.
      gamma - Spatial aspect ratio.
      psi - Phase offset.
      ktype - Type of filter coefficients. It can be CV_32F or CV_64F .
      Returns:
      automatically generated
    • getGaborKernel

      public static Mat getGaborKernel​(Size ksize, double sigma, double theta, double lambd, double gamma, double psi)
      Returns Gabor filter coefficients. For more details about gabor filter equations and parameters, see: [Gabor Filter](http://en.wikipedia.org/wiki/Gabor_filter).
      Parameters:
      ksize - Size of the filter returned.
      sigma - Standard deviation of the gaussian envelope.
      theta - Orientation of the normal to the parallel stripes of a Gabor function.
      lambd - Wavelength of the sinusoidal factor.
      gamma - Spatial aspect ratio.
      psi - Phase offset.
      Returns:
      automatically generated
    • getGaborKernel

      public static Mat getGaborKernel​(Size ksize, double sigma, double theta, double lambd, double gamma)
      Returns Gabor filter coefficients. For more details about gabor filter equations and parameters, see: [Gabor Filter](http://en.wikipedia.org/wiki/Gabor_filter).
      Parameters:
      ksize - Size of the filter returned.
      sigma - Standard deviation of the gaussian envelope.
      theta - Orientation of the normal to the parallel stripes of a Gabor function.
      lambd - Wavelength of the sinusoidal factor.
      gamma - Spatial aspect ratio.
      Returns:
      automatically generated
    • getStructuringElement

      public static Mat getStructuringElement​(int shape, Size ksize, Point anchor)
      Returns a structuring element of the specified size and shape for morphological operations. The function constructs and returns the structuring element that can be further passed to #erode, #dilate or #morphologyEx. But you can also construct an arbitrary binary mask yourself and use it as the structuring element.
      Parameters:
      shape - Element shape that could be one of #MorphShapes
      ksize - Size of the structuring element.
      anchor - Anchor position within the element. The default value \((-1, -1)\) means that the anchor is at the center. Note that only the shape of a cross-shaped element depends on the anchor position. In other cases the anchor just regulates how much the result of the morphological operation is shifted.
      Returns:
      automatically generated
    • getStructuringElement

      public static Mat getStructuringElement​(int shape, Size ksize)
      Returns a structuring element of the specified size and shape for morphological operations. The function constructs and returns the structuring element that can be further passed to #erode, #dilate or #morphologyEx. But you can also construct an arbitrary binary mask yourself and use it as the structuring element.
      Parameters:
      shape - Element shape that could be one of #MorphShapes
      ksize - Size of the structuring element. anchor is at the center. Note that only the shape of a cross-shaped element depends on the anchor position. In other cases the anchor just regulates how much the result of the morphological operation is shifted.
      Returns:
      automatically generated
    • medianBlur

      public static void medianBlur​(Mat src, Mat dst, int ksize)
      Blurs an image using the median filter. The function smoothes an image using the median filter with the \(\texttt{ksize} \times \texttt{ksize}\) aperture. Each channel of a multi-channel image is processed independently. In-place operation is supported. Note: The median filter uses #BORDER_REPLICATE internally to cope with border pixels, see #BorderTypes
      Parameters:
      src - input 1-, 3-, or 4-channel image; when ksize is 3 or 5, the image depth should be CV_8U, CV_16U, or CV_32F, for larger aperture sizes, it can only be CV_8U.
      dst - destination array of the same size and type as src.
      ksize - aperture linear size; it must be odd and greater than 1, for example: 3, 5, 7 ... SEE: bilateralFilter, blur, boxFilter, GaussianBlur
    • GaussianBlur

      public static void GaussianBlur​(Mat src, Mat dst, Size ksize, double sigmaX, double sigmaY, int borderType)
      Blurs an image using a Gaussian filter. The function convolves the source image with the specified Gaussian kernel. In-place filtering is supported.
      Parameters:
      src - input image; the image can have any number of channels, which are processed independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - output image of the same size and type as src.
      ksize - Gaussian kernel size. ksize.width and ksize.height can differ but they both must be positive and odd. Or, they can be zero's and then they are computed from sigma.
      sigmaX - Gaussian kernel standard deviation in X direction.
      sigmaY - Gaussian kernel standard deviation in Y direction; if sigmaY is zero, it is set to be equal to sigmaX, if both sigmas are zeros, they are computed from ksize.width and ksize.height, respectively (see #getGaussianKernel for details); to fully control the result regardless of possible future modifications of all this semantics, it is recommended to specify all of ksize, sigmaX, and sigmaY.
      borderType - pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. SEE: sepFilter2D, filter2D, blur, boxFilter, bilateralFilter, medianBlur
    • GaussianBlur

      public static void GaussianBlur​(Mat src, Mat dst, Size ksize, double sigmaX, double sigmaY)
      Blurs an image using a Gaussian filter. The function convolves the source image with the specified Gaussian kernel. In-place filtering is supported.
      Parameters:
      src - input image; the image can have any number of channels, which are processed independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - output image of the same size and type as src.
      ksize - Gaussian kernel size. ksize.width and ksize.height can differ but they both must be positive and odd. Or, they can be zero's and then they are computed from sigma.
      sigmaX - Gaussian kernel standard deviation in X direction.
      sigmaY - Gaussian kernel standard deviation in Y direction; if sigmaY is zero, it is set to be equal to sigmaX, if both sigmas are zeros, they are computed from ksize.width and ksize.height, respectively (see #getGaussianKernel for details); to fully control the result regardless of possible future modifications of all this semantics, it is recommended to specify all of ksize, sigmaX, and sigmaY. SEE: sepFilter2D, filter2D, blur, boxFilter, bilateralFilter, medianBlur
    • GaussianBlur

      public static void GaussianBlur​(Mat src, Mat dst, Size ksize, double sigmaX)
      Blurs an image using a Gaussian filter. The function convolves the source image with the specified Gaussian kernel. In-place filtering is supported.
      Parameters:
      src - input image; the image can have any number of channels, which are processed independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - output image of the same size and type as src.
      ksize - Gaussian kernel size. ksize.width and ksize.height can differ but they both must be positive and odd. Or, they can be zero's and then they are computed from sigma.
      sigmaX - Gaussian kernel standard deviation in X direction. equal to sigmaX, if both sigmas are zeros, they are computed from ksize.width and ksize.height, respectively (see #getGaussianKernel for details); to fully control the result regardless of possible future modifications of all this semantics, it is recommended to specify all of ksize, sigmaX, and sigmaY. SEE: sepFilter2D, filter2D, blur, boxFilter, bilateralFilter, medianBlur
    • bilateralFilter

      public static void bilateralFilter​(Mat src, Mat dst, int d, double sigmaColor, double sigmaSpace, int borderType)
      Applies the bilateral filter to an image. The function applies bilateral filtering to the input image, as described in http://www.dai.ed.ac.uk/CVonline/LOCAL_COPIES/MANDUCHI1/Bilateral_Filtering.html bilateralFilter can reduce unwanted noise very well while keeping edges fairly sharp. However, it is very slow compared to most filters. _Sigma values_: For simplicity, you can set the 2 sigma values to be the same. If they are small (< 10), the filter will not have much effect, whereas if they are large (> 150), they will have a very strong effect, making the image look "cartoonish". _Filter size_: Large filters (d > 5) are very slow, so it is recommended to use d=5 for real-time applications, and perhaps d=9 for offline applications that need heavy noise filtering. This filter does not work inplace.
      Parameters:
      src - Source 8-bit or floating-point, 1-channel or 3-channel image.
      dst - Destination image of the same size and type as src .
      d - Diameter of each pixel neighborhood that is used during filtering. If it is non-positive, it is computed from sigmaSpace.
      sigmaColor - Filter sigma in the color space. A larger value of the parameter means that farther colors within the pixel neighborhood (see sigmaSpace) will be mixed together, resulting in larger areas of semi-equal color.
      sigmaSpace - Filter sigma in the coordinate space. A larger value of the parameter means that farther pixels will influence each other as long as their colors are close enough (see sigmaColor ). When d>0, it specifies the neighborhood size regardless of sigmaSpace. Otherwise, d is proportional to sigmaSpace.
      borderType - border mode used to extrapolate pixels outside of the image, see #BorderTypes
    • bilateralFilter

      public static void bilateralFilter​(Mat src, Mat dst, int d, double sigmaColor, double sigmaSpace)
      Applies the bilateral filter to an image. The function applies bilateral filtering to the input image, as described in http://www.dai.ed.ac.uk/CVonline/LOCAL_COPIES/MANDUCHI1/Bilateral_Filtering.html bilateralFilter can reduce unwanted noise very well while keeping edges fairly sharp. However, it is very slow compared to most filters. _Sigma values_: For simplicity, you can set the 2 sigma values to be the same. If they are small (< 10), the filter will not have much effect, whereas if they are large (> 150), they will have a very strong effect, making the image look "cartoonish". _Filter size_: Large filters (d > 5) are very slow, so it is recommended to use d=5 for real-time applications, and perhaps d=9 for offline applications that need heavy noise filtering. This filter does not work inplace.
      Parameters:
      src - Source 8-bit or floating-point, 1-channel or 3-channel image.
      dst - Destination image of the same size and type as src .
      d - Diameter of each pixel neighborhood that is used during filtering. If it is non-positive, it is computed from sigmaSpace.
      sigmaColor - Filter sigma in the color space. A larger value of the parameter means that farther colors within the pixel neighborhood (see sigmaSpace) will be mixed together, resulting in larger areas of semi-equal color.
      sigmaSpace - Filter sigma in the coordinate space. A larger value of the parameter means that farther pixels will influence each other as long as their colors are close enough (see sigmaColor ). When d>0, it specifies the neighborhood size regardless of sigmaSpace. Otherwise, d is proportional to sigmaSpace.
    • boxFilter

      public static void boxFilter​(Mat src, Mat dst, int ddepth, Size ksize, Point anchor, boolean normalize, int borderType)
      Blurs an image using the box filter. The function smooths an image using the kernel: \(\texttt{K} = \alpha \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \end{bmatrix}\) where \(\alpha = \begin{cases} \frac{1}{\texttt{ksize.width*ksize.height}} & \texttt{when } \texttt{normalize=true} \\1 & \texttt{otherwise}\end{cases}\) Unnormalized box filter is useful for computing various integral characteristics over each pixel neighborhood, such as covariance matrices of image derivatives (used in dense optical flow algorithms, and so on). If you need to compute pixel sums over variable-size windows, use #integral.
      Parameters:
      src - input image.
      dst - output image of the same size and type as src.
      ddepth - the output image depth (-1 to use src.depth()).
      ksize - blurring kernel size.
      anchor - anchor point; default value Point(-1,-1) means that the anchor is at the kernel center.
      normalize - flag, specifying whether the kernel is normalized by its area or not.
      borderType - border mode used to extrapolate pixels outside of the image, see #BorderTypes. #BORDER_WRAP is not supported. SEE: blur, bilateralFilter, GaussianBlur, medianBlur, integral
    • boxFilter

      public static void boxFilter​(Mat src, Mat dst, int ddepth, Size ksize, Point anchor, boolean normalize)
      Blurs an image using the box filter. The function smooths an image using the kernel: \(\texttt{K} = \alpha \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \end{bmatrix}\) where \(\alpha = \begin{cases} \frac{1}{\texttt{ksize.width*ksize.height}} & \texttt{when } \texttt{normalize=true} \\1 & \texttt{otherwise}\end{cases}\) Unnormalized box filter is useful for computing various integral characteristics over each pixel neighborhood, such as covariance matrices of image derivatives (used in dense optical flow algorithms, and so on). If you need to compute pixel sums over variable-size windows, use #integral.
      Parameters:
      src - input image.
      dst - output image of the same size and type as src.
      ddepth - the output image depth (-1 to use src.depth()).
      ksize - blurring kernel size.
      anchor - anchor point; default value Point(-1,-1) means that the anchor is at the kernel center.
      normalize - flag, specifying whether the kernel is normalized by its area or not. SEE: blur, bilateralFilter, GaussianBlur, medianBlur, integral
    • boxFilter

      public static void boxFilter​(Mat src, Mat dst, int ddepth, Size ksize, Point anchor)
      Blurs an image using the box filter. The function smooths an image using the kernel: \(\texttt{K} = \alpha \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \end{bmatrix}\) where \(\alpha = \begin{cases} \frac{1}{\texttt{ksize.width*ksize.height}} & \texttt{when } \texttt{normalize=true} \\1 & \texttt{otherwise}\end{cases}\) Unnormalized box filter is useful for computing various integral characteristics over each pixel neighborhood, such as covariance matrices of image derivatives (used in dense optical flow algorithms, and so on). If you need to compute pixel sums over variable-size windows, use #integral.
      Parameters:
      src - input image.
      dst - output image of the same size and type as src.
      ddepth - the output image depth (-1 to use src.depth()).
      ksize - blurring kernel size.
      anchor - anchor point; default value Point(-1,-1) means that the anchor is at the kernel center. SEE: blur, bilateralFilter, GaussianBlur, medianBlur, integral
    • boxFilter

      public static void boxFilter​(Mat src, Mat dst, int ddepth, Size ksize)
      Blurs an image using the box filter. The function smooths an image using the kernel: \(\texttt{K} = \alpha \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \end{bmatrix}\) where \(\alpha = \begin{cases} \frac{1}{\texttt{ksize.width*ksize.height}} & \texttt{when } \texttt{normalize=true} \\1 & \texttt{otherwise}\end{cases}\) Unnormalized box filter is useful for computing various integral characteristics over each pixel neighborhood, such as covariance matrices of image derivatives (used in dense optical flow algorithms, and so on). If you need to compute pixel sums over variable-size windows, use #integral.
      Parameters:
      src - input image.
      dst - output image of the same size and type as src.
      ddepth - the output image depth (-1 to use src.depth()).
      ksize - blurring kernel size. center. SEE: blur, bilateralFilter, GaussianBlur, medianBlur, integral
    • sqrBoxFilter

      public static void sqrBoxFilter​(Mat src, Mat dst, int ddepth, Size ksize, Point anchor, boolean normalize, int borderType)
      Calculates the normalized sum of squares of the pixel values overlapping the filter. For every pixel \( (x, y) \) in the source image, the function calculates the sum of squares of those neighboring pixel values which overlap the filter placed over the pixel \( (x, y) \). The unnormalized square box filter can be useful in computing local image statistics such as the local variance and standard deviation around the neighborhood of a pixel.
      Parameters:
      src - input image
      dst - output image of the same size and type as src
      ddepth - the output image depth (-1 to use src.depth())
      ksize - kernel size
      anchor - kernel anchor point. The default value of Point(-1, -1) denotes that the anchor is at the kernel center.
      normalize - flag, specifying whether the kernel is to be normalized by it's area or not.
      borderType - border mode used to extrapolate pixels outside of the image, see #BorderTypes. #BORDER_WRAP is not supported. SEE: boxFilter
    • sqrBoxFilter

      public static void sqrBoxFilter​(Mat src, Mat dst, int ddepth, Size ksize, Point anchor, boolean normalize)
      Calculates the normalized sum of squares of the pixel values overlapping the filter. For every pixel \( (x, y) \) in the source image, the function calculates the sum of squares of those neighboring pixel values which overlap the filter placed over the pixel \( (x, y) \). The unnormalized square box filter can be useful in computing local image statistics such as the local variance and standard deviation around the neighborhood of a pixel.
      Parameters:
      src - input image
      dst - output image of the same size and type as src
      ddepth - the output image depth (-1 to use src.depth())
      ksize - kernel size
      anchor - kernel anchor point. The default value of Point(-1, -1) denotes that the anchor is at the kernel center.
      normalize - flag, specifying whether the kernel is to be normalized by it's area or not. SEE: boxFilter
    • sqrBoxFilter

      public static void sqrBoxFilter​(Mat src, Mat dst, int ddepth, Size ksize, Point anchor)
      Calculates the normalized sum of squares of the pixel values overlapping the filter. For every pixel \( (x, y) \) in the source image, the function calculates the sum of squares of those neighboring pixel values which overlap the filter placed over the pixel \( (x, y) \). The unnormalized square box filter can be useful in computing local image statistics such as the local variance and standard deviation around the neighborhood of a pixel.
      Parameters:
      src - input image
      dst - output image of the same size and type as src
      ddepth - the output image depth (-1 to use src.depth())
      ksize - kernel size
      anchor - kernel anchor point. The default value of Point(-1, -1) denotes that the anchor is at the kernel center. SEE: boxFilter
    • sqrBoxFilter

      public static void sqrBoxFilter​(Mat src, Mat dst, int ddepth, Size ksize)
      Calculates the normalized sum of squares of the pixel values overlapping the filter. For every pixel \( (x, y) \) in the source image, the function calculates the sum of squares of those neighboring pixel values which overlap the filter placed over the pixel \( (x, y) \). The unnormalized square box filter can be useful in computing local image statistics such as the local variance and standard deviation around the neighborhood of a pixel.
      Parameters:
      src - input image
      dst - output image of the same size and type as src
      ddepth - the output image depth (-1 to use src.depth())
      ksize - kernel size center. SEE: boxFilter
    • blur

      public static void blur​(Mat src, Mat dst, Size ksize, Point anchor, int borderType)
      Blurs an image using the normalized box filter. The function smooths an image using the kernel: \(\texttt{K} = \frac{1}{\texttt{ksize.width*ksize.height}} \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \end{bmatrix}\) The call blur(src, dst, ksize, anchor, borderType) is equivalent to `boxFilter(src, dst, src.type(), ksize, anchor, true, borderType)`.
      Parameters:
      src - input image; it can have any number of channels, which are processed independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - output image of the same size and type as src.
      ksize - blurring kernel size.
      anchor - anchor point; default value Point(-1,-1) means that the anchor is at the kernel center.
      borderType - border mode used to extrapolate pixels outside of the image, see #BorderTypes. #BORDER_WRAP is not supported. SEE: boxFilter, bilateralFilter, GaussianBlur, medianBlur
    • blur

      public static void blur​(Mat src, Mat dst, Size ksize, Point anchor)
      Blurs an image using the normalized box filter. The function smooths an image using the kernel: \(\texttt{K} = \frac{1}{\texttt{ksize.width*ksize.height}} \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \end{bmatrix}\) The call blur(src, dst, ksize, anchor, borderType) is equivalent to `boxFilter(src, dst, src.type(), ksize, anchor, true, borderType)`.
      Parameters:
      src - input image; it can have any number of channels, which are processed independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - output image of the same size and type as src.
      ksize - blurring kernel size.
      anchor - anchor point; default value Point(-1,-1) means that the anchor is at the kernel center. SEE: boxFilter, bilateralFilter, GaussianBlur, medianBlur
    • blur

      public static void blur​(Mat src, Mat dst, Size ksize)
      Blurs an image using the normalized box filter. The function smooths an image using the kernel: \(\texttt{K} = \frac{1}{\texttt{ksize.width*ksize.height}} \begin{bmatrix} 1 & 1 & 1 & \cdots & 1 & 1 \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \hdotsfor{6} \\ 1 & 1 & 1 & \cdots & 1 & 1 \\ \end{bmatrix}\) The call blur(src, dst, ksize, anchor, borderType) is equivalent to `boxFilter(src, dst, src.type(), ksize, anchor, true, borderType)`.
      Parameters:
      src - input image; it can have any number of channels, which are processed independently, but the depth should be CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - output image of the same size and type as src.
      ksize - blurring kernel size. center. SEE: boxFilter, bilateralFilter, GaussianBlur, medianBlur
    • filter2D

      public static void filter2D​(Mat src, Mat dst, int ddepth, Mat kernel, Point anchor, double delta, int borderType)
      Convolves an image with the kernel. The function applies an arbitrary linear filter to an image. In-place operation is supported. When the aperture is partially outside the image, the function interpolates outlier pixel values according to the specified border mode. The function does actually compute correlation, not the convolution: \(\texttt{dst} (x,y) = \sum _{ \substack{0\leq x' < \texttt{kernel.cols}\\{0\leq y' < \texttt{kernel.rows}}}} \texttt{kernel} (x',y')* \texttt{src} (x+x'- \texttt{anchor.x} ,y+y'- \texttt{anchor.y} )\) That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip the kernel using #flip and set the new anchor to `(kernel.cols - anchor.x - 1, kernel.rows - anchor.y - 1)`. The function uses the DFT-based algorithm in case of sufficiently large kernels (~11 x 11 or larger) and the direct algorithm for small kernels.
      Parameters:
      src - input image.
      dst - output image of the same size and the same number of channels as src.
      ddepth - desired depth of the destination image, see REF: filter_depths "combinations"
      kernel - convolution kernel (or rather a correlation kernel), a single-channel floating point matrix; if you want to apply different kernels to different channels, split the image into separate color planes using split and process them individually.
      anchor - anchor of the kernel that indicates the relative position of a filtered point within the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor is at the kernel center.
      delta - optional value added to the filtered pixels before storing them in dst.
      borderType - pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. SEE: sepFilter2D, dft, matchTemplate
    • filter2D

      public static void filter2D​(Mat src, Mat dst, int ddepth, Mat kernel, Point anchor, double delta)
      Convolves an image with the kernel. The function applies an arbitrary linear filter to an image. In-place operation is supported. When the aperture is partially outside the image, the function interpolates outlier pixel values according to the specified border mode. The function does actually compute correlation, not the convolution: \(\texttt{dst} (x,y) = \sum _{ \substack{0\leq x' < \texttt{kernel.cols}\\{0\leq y' < \texttt{kernel.rows}}}} \texttt{kernel} (x',y')* \texttt{src} (x+x'- \texttt{anchor.x} ,y+y'- \texttt{anchor.y} )\) That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip the kernel using #flip and set the new anchor to `(kernel.cols - anchor.x - 1, kernel.rows - anchor.y - 1)`. The function uses the DFT-based algorithm in case of sufficiently large kernels (~11 x 11 or larger) and the direct algorithm for small kernels.
      Parameters:
      src - input image.
      dst - output image of the same size and the same number of channels as src.
      ddepth - desired depth of the destination image, see REF: filter_depths "combinations"
      kernel - convolution kernel (or rather a correlation kernel), a single-channel floating point matrix; if you want to apply different kernels to different channels, split the image into separate color planes using split and process them individually.
      anchor - anchor of the kernel that indicates the relative position of a filtered point within the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor is at the kernel center.
      delta - optional value added to the filtered pixels before storing them in dst. SEE: sepFilter2D, dft, matchTemplate
    • filter2D

      public static void filter2D​(Mat src, Mat dst, int ddepth, Mat kernel, Point anchor)
      Convolves an image with the kernel. The function applies an arbitrary linear filter to an image. In-place operation is supported. When the aperture is partially outside the image, the function interpolates outlier pixel values according to the specified border mode. The function does actually compute correlation, not the convolution: \(\texttt{dst} (x,y) = \sum _{ \substack{0\leq x' < \texttt{kernel.cols}\\{0\leq y' < \texttt{kernel.rows}}}} \texttt{kernel} (x',y')* \texttt{src} (x+x'- \texttt{anchor.x} ,y+y'- \texttt{anchor.y} )\) That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip the kernel using #flip and set the new anchor to `(kernel.cols - anchor.x - 1, kernel.rows - anchor.y - 1)`. The function uses the DFT-based algorithm in case of sufficiently large kernels (~11 x 11 or larger) and the direct algorithm for small kernels.
      Parameters:
      src - input image.
      dst - output image of the same size and the same number of channels as src.
      ddepth - desired depth of the destination image, see REF: filter_depths "combinations"
      kernel - convolution kernel (or rather a correlation kernel), a single-channel floating point matrix; if you want to apply different kernels to different channels, split the image into separate color planes using split and process them individually.
      anchor - anchor of the kernel that indicates the relative position of a filtered point within the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor is at the kernel center. SEE: sepFilter2D, dft, matchTemplate
    • filter2D

      public static void filter2D​(Mat src, Mat dst, int ddepth, Mat kernel)
      Convolves an image with the kernel. The function applies an arbitrary linear filter to an image. In-place operation is supported. When the aperture is partially outside the image, the function interpolates outlier pixel values according to the specified border mode. The function does actually compute correlation, not the convolution: \(\texttt{dst} (x,y) = \sum _{ \substack{0\leq x' < \texttt{kernel.cols}\\{0\leq y' < \texttt{kernel.rows}}}} \texttt{kernel} (x',y')* \texttt{src} (x+x'- \texttt{anchor.x} ,y+y'- \texttt{anchor.y} )\) That is, the kernel is not mirrored around the anchor point. If you need a real convolution, flip the kernel using #flip and set the new anchor to `(kernel.cols - anchor.x - 1, kernel.rows - anchor.y - 1)`. The function uses the DFT-based algorithm in case of sufficiently large kernels (~11 x 11 or larger) and the direct algorithm for small kernels.
      Parameters:
      src - input image.
      dst - output image of the same size and the same number of channels as src.
      ddepth - desired depth of the destination image, see REF: filter_depths "combinations"
      kernel - convolution kernel (or rather a correlation kernel), a single-channel floating point matrix; if you want to apply different kernels to different channels, split the image into separate color planes using split and process them individually. the kernel; the anchor should lie within the kernel; default value (-1,-1) means that the anchor is at the kernel center. SEE: sepFilter2D, dft, matchTemplate
    • sepFilter2D

      public static void sepFilter2D​(Mat src, Mat dst, int ddepth, Mat kernelX, Mat kernelY, Point anchor, double delta, int borderType)
      Applies a separable linear filter to an image. The function applies a separable linear filter to the image. That is, first, every row of src is filtered with the 1D kernel kernelX. Then, every column of the result is filtered with the 1D kernel kernelY. The final result shifted by delta is stored in dst .
      Parameters:
      src - Source image.
      dst - Destination image of the same size and the same number of channels as src .
      ddepth - Destination image depth, see REF: filter_depths "combinations"
      kernelX - Coefficients for filtering each row.
      kernelY - Coefficients for filtering each column.
      anchor - Anchor position within the kernel. The default value \((-1,-1)\) means that the anchor is at the kernel center.
      delta - Value added to the filtered results before storing them.
      borderType - Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. SEE: filter2D, Sobel, GaussianBlur, boxFilter, blur
    • sepFilter2D

      public static void sepFilter2D​(Mat src, Mat dst, int ddepth, Mat kernelX, Mat kernelY, Point anchor, double delta)
      Applies a separable linear filter to an image. The function applies a separable linear filter to the image. That is, first, every row of src is filtered with the 1D kernel kernelX. Then, every column of the result is filtered with the 1D kernel kernelY. The final result shifted by delta is stored in dst .
      Parameters:
      src - Source image.
      dst - Destination image of the same size and the same number of channels as src .
      ddepth - Destination image depth, see REF: filter_depths "combinations"
      kernelX - Coefficients for filtering each row.
      kernelY - Coefficients for filtering each column.
      anchor - Anchor position within the kernel. The default value \((-1,-1)\) means that the anchor is at the kernel center.
      delta - Value added to the filtered results before storing them. SEE: filter2D, Sobel, GaussianBlur, boxFilter, blur
    • sepFilter2D

      public static void sepFilter2D​(Mat src, Mat dst, int ddepth, Mat kernelX, Mat kernelY, Point anchor)
      Applies a separable linear filter to an image. The function applies a separable linear filter to the image. That is, first, every row of src is filtered with the 1D kernel kernelX. Then, every column of the result is filtered with the 1D kernel kernelY. The final result shifted by delta is stored in dst .
      Parameters:
      src - Source image.
      dst - Destination image of the same size and the same number of channels as src .
      ddepth - Destination image depth, see REF: filter_depths "combinations"
      kernelX - Coefficients for filtering each row.
      kernelY - Coefficients for filtering each column.
      anchor - Anchor position within the kernel. The default value \((-1,-1)\) means that the anchor is at the kernel center. SEE: filter2D, Sobel, GaussianBlur, boxFilter, blur
    • sepFilter2D

      public static void sepFilter2D​(Mat src, Mat dst, int ddepth, Mat kernelX, Mat kernelY)
      Applies a separable linear filter to an image. The function applies a separable linear filter to the image. That is, first, every row of src is filtered with the 1D kernel kernelX. Then, every column of the result is filtered with the 1D kernel kernelY. The final result shifted by delta is stored in dst .
      Parameters:
      src - Source image.
      dst - Destination image of the same size and the same number of channels as src .
      ddepth - Destination image depth, see REF: filter_depths "combinations"
      kernelX - Coefficients for filtering each row.
      kernelY - Coefficients for filtering each column. is at the kernel center. SEE: filter2D, Sobel, GaussianBlur, boxFilter, blur
    • Sobel

      public static void Sobel​(Mat src, Mat dst, int ddepth, int dx, int dy, int ksize, double scale, double delta, int borderType)
      Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator. In all cases except one, the \(\texttt{ksize} \times \texttt{ksize}\) separable kernel is used to calculate the derivative. When \(\texttt{ksize = 1}\), the \(3 \times 1\) or \(1 \times 3\) kernel is used (that is, no Gaussian smoothing is done). ksize = 1 can only be used for the first or the second x- or y- derivatives. There is also the special value ksize = #FILTER_SCHARR (-1) that corresponds to the \(3\times3\) Scharr filter that may give more accurate results than the \(3\times3\) Sobel. The Scharr aperture is \(\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\) for the x-derivative, or transposed for the y-derivative. The function calculates an image derivative by convolving the image with the appropriate kernel: \(\texttt{dst} = \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\) The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less resistant to the noise. Most often, the function is called with ( xorder = 1, yorder = 0, ksize = 3) or ( xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first case corresponds to a kernel of: \(\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\) The second case corresponds to a kernel of: \(\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\)
      Parameters:
      src - input image.
      dst - output image of the same size and the same number of channels as src .
      ddepth - output image depth, see REF: filter_depths "combinations"; in the case of 8-bit input images it will result in truncated derivatives.
      dx - order of the derivative x.
      dy - order of the derivative y.
      ksize - size of the extended Sobel kernel; it must be 1, 3, 5, or 7.
      scale - optional scale factor for the computed derivative values; by default, no scaling is applied (see #getDerivKernels for details).
      delta - optional delta value that is added to the results prior to storing them in dst.
      borderType - pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. SEE: Scharr, Laplacian, sepFilter2D, filter2D, GaussianBlur, cartToPolar
    • Sobel

      public static void Sobel​(Mat src, Mat dst, int ddepth, int dx, int dy, int ksize, double scale, double delta)
      Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator. In all cases except one, the \(\texttt{ksize} \times \texttt{ksize}\) separable kernel is used to calculate the derivative. When \(\texttt{ksize = 1}\), the \(3 \times 1\) or \(1 \times 3\) kernel is used (that is, no Gaussian smoothing is done). ksize = 1 can only be used for the first or the second x- or y- derivatives. There is also the special value ksize = #FILTER_SCHARR (-1) that corresponds to the \(3\times3\) Scharr filter that may give more accurate results than the \(3\times3\) Sobel. The Scharr aperture is \(\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\) for the x-derivative, or transposed for the y-derivative. The function calculates an image derivative by convolving the image with the appropriate kernel: \(\texttt{dst} = \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\) The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less resistant to the noise. Most often, the function is called with ( xorder = 1, yorder = 0, ksize = 3) or ( xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first case corresponds to a kernel of: \(\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\) The second case corresponds to a kernel of: \(\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\)
      Parameters:
      src - input image.
      dst - output image of the same size and the same number of channels as src .
      ddepth - output image depth, see REF: filter_depths "combinations"; in the case of 8-bit input images it will result in truncated derivatives.
      dx - order of the derivative x.
      dy - order of the derivative y.
      ksize - size of the extended Sobel kernel; it must be 1, 3, 5, or 7.
      scale - optional scale factor for the computed derivative values; by default, no scaling is applied (see #getDerivKernels for details).
      delta - optional delta value that is added to the results prior to storing them in dst. SEE: Scharr, Laplacian, sepFilter2D, filter2D, GaussianBlur, cartToPolar
    • Sobel

      public static void Sobel​(Mat src, Mat dst, int ddepth, int dx, int dy, int ksize, double scale)
      Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator. In all cases except one, the \(\texttt{ksize} \times \texttt{ksize}\) separable kernel is used to calculate the derivative. When \(\texttt{ksize = 1}\), the \(3 \times 1\) or \(1 \times 3\) kernel is used (that is, no Gaussian smoothing is done). ksize = 1 can only be used for the first or the second x- or y- derivatives. There is also the special value ksize = #FILTER_SCHARR (-1) that corresponds to the \(3\times3\) Scharr filter that may give more accurate results than the \(3\times3\) Sobel. The Scharr aperture is \(\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\) for the x-derivative, or transposed for the y-derivative. The function calculates an image derivative by convolving the image with the appropriate kernel: \(\texttt{dst} = \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\) The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less resistant to the noise. Most often, the function is called with ( xorder = 1, yorder = 0, ksize = 3) or ( xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first case corresponds to a kernel of: \(\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\) The second case corresponds to a kernel of: \(\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\)
      Parameters:
      src - input image.
      dst - output image of the same size and the same number of channels as src .
      ddepth - output image depth, see REF: filter_depths "combinations"; in the case of 8-bit input images it will result in truncated derivatives.
      dx - order of the derivative x.
      dy - order of the derivative y.
      ksize - size of the extended Sobel kernel; it must be 1, 3, 5, or 7.
      scale - optional scale factor for the computed derivative values; by default, no scaling is applied (see #getDerivKernels for details). SEE: Scharr, Laplacian, sepFilter2D, filter2D, GaussianBlur, cartToPolar
    • Sobel

      public static void Sobel​(Mat src, Mat dst, int ddepth, int dx, int dy, int ksize)
      Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator. In all cases except one, the \(\texttt{ksize} \times \texttt{ksize}\) separable kernel is used to calculate the derivative. When \(\texttt{ksize = 1}\), the \(3 \times 1\) or \(1 \times 3\) kernel is used (that is, no Gaussian smoothing is done). ksize = 1 can only be used for the first or the second x- or y- derivatives. There is also the special value ksize = #FILTER_SCHARR (-1) that corresponds to the \(3\times3\) Scharr filter that may give more accurate results than the \(3\times3\) Sobel. The Scharr aperture is \(\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\) for the x-derivative, or transposed for the y-derivative. The function calculates an image derivative by convolving the image with the appropriate kernel: \(\texttt{dst} = \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\) The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less resistant to the noise. Most often, the function is called with ( xorder = 1, yorder = 0, ksize = 3) or ( xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first case corresponds to a kernel of: \(\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\) The second case corresponds to a kernel of: \(\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\)
      Parameters:
      src - input image.
      dst - output image of the same size and the same number of channels as src .
      ddepth - output image depth, see REF: filter_depths "combinations"; in the case of 8-bit input images it will result in truncated derivatives.
      dx - order of the derivative x.
      dy - order of the derivative y.
      ksize - size of the extended Sobel kernel; it must be 1, 3, 5, or 7. applied (see #getDerivKernels for details). SEE: Scharr, Laplacian, sepFilter2D, filter2D, GaussianBlur, cartToPolar
    • Sobel

      public static void Sobel​(Mat src, Mat dst, int ddepth, int dx, int dy)
      Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator. In all cases except one, the \(\texttt{ksize} \times \texttt{ksize}\) separable kernel is used to calculate the derivative. When \(\texttt{ksize = 1}\), the \(3 \times 1\) or \(1 \times 3\) kernel is used (that is, no Gaussian smoothing is done). ksize = 1 can only be used for the first or the second x- or y- derivatives. There is also the special value ksize = #FILTER_SCHARR (-1) that corresponds to the \(3\times3\) Scharr filter that may give more accurate results than the \(3\times3\) Sobel. The Scharr aperture is \(\vecthreethree{-3}{0}{3}{-10}{0}{10}{-3}{0}{3}\) for the x-derivative, or transposed for the y-derivative. The function calculates an image derivative by convolving the image with the appropriate kernel: \(\texttt{dst} = \frac{\partial^{xorder+yorder} \texttt{src}}{\partial x^{xorder} \partial y^{yorder}}\) The Sobel operators combine Gaussian smoothing and differentiation, so the result is more or less resistant to the noise. Most often, the function is called with ( xorder = 1, yorder = 0, ksize = 3) or ( xorder = 0, yorder = 1, ksize = 3) to calculate the first x- or y- image derivative. The first case corresponds to a kernel of: \(\vecthreethree{-1}{0}{1}{-2}{0}{2}{-1}{0}{1}\) The second case corresponds to a kernel of: \(\vecthreethree{-1}{-2}{-1}{0}{0}{0}{1}{2}{1}\)
      Parameters:
      src - input image.
      dst - output image of the same size and the same number of channels as src .
      ddepth - output image depth, see REF: filter_depths "combinations"; in the case of 8-bit input images it will result in truncated derivatives.
      dx - order of the derivative x.
      dy - order of the derivative y. applied (see #getDerivKernels for details). SEE: Scharr, Laplacian, sepFilter2D, filter2D, GaussianBlur, cartToPolar
    • spatialGradient

      public static void spatialGradient​(Mat src, Mat dx, Mat dy, int ksize, int borderType)
      Calculates the first order image derivative in both x and y using a Sobel operator Equivalent to calling: Sobel( src, dx, CV_16SC1, 1, 0, 3 ); Sobel( src, dy, CV_16SC1, 0, 1, 3 );
      Parameters:
      src - input image.
      dx - output image with first-order derivative in x.
      dy - output image with first-order derivative in y.
      ksize - size of Sobel kernel. It must be 3.
      borderType - pixel extrapolation method, see #BorderTypes. Only #BORDER_DEFAULT=#BORDER_REFLECT_101 and #BORDER_REPLICATE are supported. SEE: Sobel
    • spatialGradient

      public static void spatialGradient​(Mat src, Mat dx, Mat dy, int ksize)
      Calculates the first order image derivative in both x and y using a Sobel operator Equivalent to calling: Sobel( src, dx, CV_16SC1, 1, 0, 3 ); Sobel( src, dy, CV_16SC1, 0, 1, 3 );
      Parameters:
      src - input image.
      dx - output image with first-order derivative in x.
      dy - output image with first-order derivative in y.
      ksize - size of Sobel kernel. It must be 3. Only #BORDER_DEFAULT=#BORDER_REFLECT_101 and #BORDER_REPLICATE are supported. SEE: Sobel
    • spatialGradient

      public static void spatialGradient​(Mat src, Mat dx, Mat dy)
      Calculates the first order image derivative in both x and y using a Sobel operator Equivalent to calling: Sobel( src, dx, CV_16SC1, 1, 0, 3 ); Sobel( src, dy, CV_16SC1, 0, 1, 3 );
      Parameters:
      src - input image.
      dx - output image with first-order derivative in x.
      dy - output image with first-order derivative in y. Only #BORDER_DEFAULT=#BORDER_REFLECT_101 and #BORDER_REPLICATE are supported. SEE: Sobel
    • Scharr

      public static void Scharr​(Mat src, Mat dst, int ddepth, int dx, int dy, double scale, double delta, int borderType)
      Calculates the first x- or y- image derivative using Scharr operator. The function computes the first x- or y- spatial image derivative using the Scharr operator. The call \(\texttt{Scharr(src, dst, ddepth, dx, dy, scale, delta, borderType)}\) is equivalent to \(\texttt{Sobel(src, dst, ddepth, dx, dy, FILTER_SCHARR, scale, delta, borderType)} .\)
      Parameters:
      src - input image.
      dst - output image of the same size and the same number of channels as src.
      ddepth - output image depth, see REF: filter_depths "combinations"
      dx - order of the derivative x.
      dy - order of the derivative y.
      scale - optional scale factor for the computed derivative values; by default, no scaling is applied (see #getDerivKernels for details).
      delta - optional delta value that is added to the results prior to storing them in dst.
      borderType - pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. SEE: cartToPolar
    • Scharr

      public static void Scharr​(Mat src, Mat dst, int ddepth, int dx, int dy, double scale, double delta)
      Calculates the first x- or y- image derivative using Scharr operator. The function computes the first x- or y- spatial image derivative using the Scharr operator. The call \(\texttt{Scharr(src, dst, ddepth, dx, dy, scale, delta, borderType)}\) is equivalent to \(\texttt{Sobel(src, dst, ddepth, dx, dy, FILTER_SCHARR, scale, delta, borderType)} .\)
      Parameters:
      src - input image.
      dst - output image of the same size and the same number of channels as src.
      ddepth - output image depth, see REF: filter_depths "combinations"
      dx - order of the derivative x.
      dy - order of the derivative y.
      scale - optional scale factor for the computed derivative values; by default, no scaling is applied (see #getDerivKernels for details).
      delta - optional delta value that is added to the results prior to storing them in dst. SEE: cartToPolar
    • Scharr

      public static void Scharr​(Mat src, Mat dst, int ddepth, int dx, int dy, double scale)
      Calculates the first x- or y- image derivative using Scharr operator. The function computes the first x- or y- spatial image derivative using the Scharr operator. The call \(\texttt{Scharr(src, dst, ddepth, dx, dy, scale, delta, borderType)}\) is equivalent to \(\texttt{Sobel(src, dst, ddepth, dx, dy, FILTER_SCHARR, scale, delta, borderType)} .\)
      Parameters:
      src - input image.
      dst - output image of the same size and the same number of channels as src.
      ddepth - output image depth, see REF: filter_depths "combinations"
      dx - order of the derivative x.
      dy - order of the derivative y.
      scale - optional scale factor for the computed derivative values; by default, no scaling is applied (see #getDerivKernels for details). SEE: cartToPolar
    • Scharr

      public static void Scharr​(Mat src, Mat dst, int ddepth, int dx, int dy)
      Calculates the first x- or y- image derivative using Scharr operator. The function computes the first x- or y- spatial image derivative using the Scharr operator. The call \(\texttt{Scharr(src, dst, ddepth, dx, dy, scale, delta, borderType)}\) is equivalent to \(\texttt{Sobel(src, dst, ddepth, dx, dy, FILTER_SCHARR, scale, delta, borderType)} .\)
      Parameters:
      src - input image.
      dst - output image of the same size and the same number of channels as src.
      ddepth - output image depth, see REF: filter_depths "combinations"
      dx - order of the derivative x.
      dy - order of the derivative y. applied (see #getDerivKernels for details). SEE: cartToPolar
    • Laplacian

      public static void Laplacian​(Mat src, Mat dst, int ddepth, int ksize, double scale, double delta, int borderType)
      Calculates the Laplacian of an image. The function calculates the Laplacian of the source image by adding up the second x and y derivatives calculated using the Sobel operator: \(\texttt{dst} = \Delta \texttt{src} = \frac{\partial^2 \texttt{src}}{\partial x^2} + \frac{\partial^2 \texttt{src}}{\partial y^2}\) This is done when ksize &gt; 1. When ksize == 1, the Laplacian is computed by filtering the image with the following \(3 \times 3\) aperture: \(\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}\)
      Parameters:
      src - Source image.
      dst - Destination image of the same size and the same number of channels as src .
      ddepth - Desired depth of the destination image.
      ksize - Aperture size used to compute the second-derivative filters. See #getDerivKernels for details. The size must be positive and odd.
      scale - Optional scale factor for the computed Laplacian values. By default, no scaling is applied. See #getDerivKernels for details.
      delta - Optional delta value that is added to the results prior to storing them in dst .
      borderType - Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. SEE: Sobel, Scharr
    • Laplacian

      public static void Laplacian​(Mat src, Mat dst, int ddepth, int ksize, double scale, double delta)
      Calculates the Laplacian of an image. The function calculates the Laplacian of the source image by adding up the second x and y derivatives calculated using the Sobel operator: \(\texttt{dst} = \Delta \texttt{src} = \frac{\partial^2 \texttt{src}}{\partial x^2} + \frac{\partial^2 \texttt{src}}{\partial y^2}\) This is done when ksize &gt; 1. When ksize == 1, the Laplacian is computed by filtering the image with the following \(3 \times 3\) aperture: \(\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}\)
      Parameters:
      src - Source image.
      dst - Destination image of the same size and the same number of channels as src .
      ddepth - Desired depth of the destination image.
      ksize - Aperture size used to compute the second-derivative filters. See #getDerivKernels for details. The size must be positive and odd.
      scale - Optional scale factor for the computed Laplacian values. By default, no scaling is applied. See #getDerivKernels for details.
      delta - Optional delta value that is added to the results prior to storing them in dst . SEE: Sobel, Scharr
    • Laplacian

      public static void Laplacian​(Mat src, Mat dst, int ddepth, int ksize, double scale)
      Calculates the Laplacian of an image. The function calculates the Laplacian of the source image by adding up the second x and y derivatives calculated using the Sobel operator: \(\texttt{dst} = \Delta \texttt{src} = \frac{\partial^2 \texttt{src}}{\partial x^2} + \frac{\partial^2 \texttt{src}}{\partial y^2}\) This is done when ksize &gt; 1. When ksize == 1, the Laplacian is computed by filtering the image with the following \(3 \times 3\) aperture: \(\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}\)
      Parameters:
      src - Source image.
      dst - Destination image of the same size and the same number of channels as src .
      ddepth - Desired depth of the destination image.
      ksize - Aperture size used to compute the second-derivative filters. See #getDerivKernels for details. The size must be positive and odd.
      scale - Optional scale factor for the computed Laplacian values. By default, no scaling is applied. See #getDerivKernels for details. SEE: Sobel, Scharr
    • Laplacian

      public static void Laplacian​(Mat src, Mat dst, int ddepth, int ksize)
      Calculates the Laplacian of an image. The function calculates the Laplacian of the source image by adding up the second x and y derivatives calculated using the Sobel operator: \(\texttt{dst} = \Delta \texttt{src} = \frac{\partial^2 \texttt{src}}{\partial x^2} + \frac{\partial^2 \texttt{src}}{\partial y^2}\) This is done when ksize &gt; 1. When ksize == 1, the Laplacian is computed by filtering the image with the following \(3 \times 3\) aperture: \(\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}\)
      Parameters:
      src - Source image.
      dst - Destination image of the same size and the same number of channels as src .
      ddepth - Desired depth of the destination image.
      ksize - Aperture size used to compute the second-derivative filters. See #getDerivKernels for details. The size must be positive and odd. applied. See #getDerivKernels for details. SEE: Sobel, Scharr
    • Laplacian

      public static void Laplacian​(Mat src, Mat dst, int ddepth)
      Calculates the Laplacian of an image. The function calculates the Laplacian of the source image by adding up the second x and y derivatives calculated using the Sobel operator: \(\texttt{dst} = \Delta \texttt{src} = \frac{\partial^2 \texttt{src}}{\partial x^2} + \frac{\partial^2 \texttt{src}}{\partial y^2}\) This is done when ksize &gt; 1. When ksize == 1, the Laplacian is computed by filtering the image with the following \(3 \times 3\) aperture: \(\vecthreethree {0}{1}{0}{1}{-4}{1}{0}{1}{0}\)
      Parameters:
      src - Source image.
      dst - Destination image of the same size and the same number of channels as src .
      ddepth - Desired depth of the destination image. details. The size must be positive and odd. applied. See #getDerivKernels for details. SEE: Sobel, Scharr
    • Canny

      public static void Canny​(Mat image, Mat edges, double threshold1, double threshold2, int apertureSize, boolean L2gradient)
      Finds edges in an image using the Canny algorithm CITE: Canny86 . The function finds edges in the input image and marks them in the output map edges using the Canny algorithm. The smallest value between threshold1 and threshold2 is used for edge linking. The largest value is used to find initial segments of strong edges. See <http://en.wikipedia.org/wiki/Canny_edge_detector>
      Parameters:
      image - 8-bit input image.
      edges - output edge map; single channels 8-bit image, which has the same size as image .
      threshold1 - first threshold for the hysteresis procedure.
      threshold2 - second threshold for the hysteresis procedure.
      apertureSize - aperture size for the Sobel operator.
      L2gradient - a flag, indicating whether a more accurate \(L_2\) norm \(=\sqrt{(dI/dx)^2 + (dI/dy)^2}\) should be used to calculate the image gradient magnitude ( L2gradient=true ), or whether the default \(L_1\) norm \(=|dI/dx|+|dI/dy|\) is enough ( L2gradient=false ).
    • Canny

      public static void Canny​(Mat image, Mat edges, double threshold1, double threshold2, int apertureSize)
      Finds edges in an image using the Canny algorithm CITE: Canny86 . The function finds edges in the input image and marks them in the output map edges using the Canny algorithm. The smallest value between threshold1 and threshold2 is used for edge linking. The largest value is used to find initial segments of strong edges. See <http://en.wikipedia.org/wiki/Canny_edge_detector>
      Parameters:
      image - 8-bit input image.
      edges - output edge map; single channels 8-bit image, which has the same size as image .
      threshold1 - first threshold for the hysteresis procedure.
      threshold2 - second threshold for the hysteresis procedure.
      apertureSize - aperture size for the Sobel operator. \(=\sqrt{(dI/dx)^2 + (dI/dy)^2}\) should be used to calculate the image gradient magnitude ( L2gradient=true ), or whether the default \(L_1\) norm \(=|dI/dx|+|dI/dy|\) is enough ( L2gradient=false ).
    • Canny

      public static void Canny​(Mat image, Mat edges, double threshold1, double threshold2)
      Finds edges in an image using the Canny algorithm CITE: Canny86 . The function finds edges in the input image and marks them in the output map edges using the Canny algorithm. The smallest value between threshold1 and threshold2 is used for edge linking. The largest value is used to find initial segments of strong edges. See <http://en.wikipedia.org/wiki/Canny_edge_detector>
      Parameters:
      image - 8-bit input image.
      edges - output edge map; single channels 8-bit image, which has the same size as image .
      threshold1 - first threshold for the hysteresis procedure.
      threshold2 - second threshold for the hysteresis procedure. \(=\sqrt{(dI/dx)^2 + (dI/dy)^2}\) should be used to calculate the image gradient magnitude ( L2gradient=true ), or whether the default \(L_1\) norm \(=|dI/dx|+|dI/dy|\) is enough ( L2gradient=false ).
    • Canny

      public static void Canny​(Mat dx, Mat dy, Mat edges, double threshold1, double threshold2, boolean L2gradient)
      \overload Finds edges in an image using the Canny algorithm with custom image gradient.
      Parameters:
      dx - 16-bit x derivative of input image (CV_16SC1 or CV_16SC3).
      dy - 16-bit y derivative of input image (same type as dx).
      edges - output edge map; single channels 8-bit image, which has the same size as image .
      threshold1 - first threshold for the hysteresis procedure.
      threshold2 - second threshold for the hysteresis procedure.
      L2gradient - a flag, indicating whether a more accurate \(L_2\) norm \(=\sqrt{(dI/dx)^2 + (dI/dy)^2}\) should be used to calculate the image gradient magnitude ( L2gradient=true ), or whether the default \(L_1\) norm \(=|dI/dx|+|dI/dy|\) is enough ( L2gradient=false ).
    • Canny

      public static void Canny​(Mat dx, Mat dy, Mat edges, double threshold1, double threshold2)
      \overload Finds edges in an image using the Canny algorithm with custom image gradient.
      Parameters:
      dx - 16-bit x derivative of input image (CV_16SC1 or CV_16SC3).
      dy - 16-bit y derivative of input image (same type as dx).
      edges - output edge map; single channels 8-bit image, which has the same size as image .
      threshold1 - first threshold for the hysteresis procedure.
      threshold2 - second threshold for the hysteresis procedure. \(=\sqrt{(dI/dx)^2 + (dI/dy)^2}\) should be used to calculate the image gradient magnitude ( L2gradient=true ), or whether the default \(L_1\) norm \(=|dI/dx|+|dI/dy|\) is enough ( L2gradient=false ).
    • cornerMinEigenVal

      public static void cornerMinEigenVal​(Mat src, Mat dst, int blockSize, int ksize, int borderType)
      Calculates the minimal eigenvalue of gradient matrices for corner detection. The function is similar to cornerEigenValsAndVecs but it calculates and stores only the minimal eigenvalue of the covariance matrix of derivatives, that is, \(\min(\lambda_1, \lambda_2)\) in terms of the formulae in the cornerEigenValsAndVecs description.
      Parameters:
      src - Input single-channel 8-bit or floating-point image.
      dst - Image to store the minimal eigenvalues. It has the type CV_32FC1 and the same size as src .
      blockSize - Neighborhood size (see the details on #cornerEigenValsAndVecs ).
      ksize - Aperture parameter for the Sobel operator.
      borderType - Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported.
    • cornerMinEigenVal

      public static void cornerMinEigenVal​(Mat src, Mat dst, int blockSize, int ksize)
      Calculates the minimal eigenvalue of gradient matrices for corner detection. The function is similar to cornerEigenValsAndVecs but it calculates and stores only the minimal eigenvalue of the covariance matrix of derivatives, that is, \(\min(\lambda_1, \lambda_2)\) in terms of the formulae in the cornerEigenValsAndVecs description.
      Parameters:
      src - Input single-channel 8-bit or floating-point image.
      dst - Image to store the minimal eigenvalues. It has the type CV_32FC1 and the same size as src .
      blockSize - Neighborhood size (see the details on #cornerEigenValsAndVecs ).
      ksize - Aperture parameter for the Sobel operator.
    • cornerMinEigenVal

      public static void cornerMinEigenVal​(Mat src, Mat dst, int blockSize)
      Calculates the minimal eigenvalue of gradient matrices for corner detection. The function is similar to cornerEigenValsAndVecs but it calculates and stores only the minimal eigenvalue of the covariance matrix of derivatives, that is, \(\min(\lambda_1, \lambda_2)\) in terms of the formulae in the cornerEigenValsAndVecs description.
      Parameters:
      src - Input single-channel 8-bit or floating-point image.
      dst - Image to store the minimal eigenvalues. It has the type CV_32FC1 and the same size as src .
      blockSize - Neighborhood size (see the details on #cornerEigenValsAndVecs ).
    • cornerHarris

      public static void cornerHarris​(Mat src, Mat dst, int blockSize, int ksize, double k, int borderType)
      Harris corner detector. The function runs the Harris corner detector on the image. Similarly to cornerMinEigenVal and cornerEigenValsAndVecs , for each pixel \((x, y)\) it calculates a \(2\times2\) gradient covariance matrix \(M^{(x,y)}\) over a \(\texttt{blockSize} \times \texttt{blockSize}\) neighborhood. Then, it computes the following characteristic: \(\texttt{dst} (x,y) = \mathrm{det} M^{(x,y)} - k \cdot \left ( \mathrm{tr} M^{(x,y)} \right )^2\) Corners in the image can be found as the local maxima of this response map.
      Parameters:
      src - Input single-channel 8-bit or floating-point image.
      dst - Image to store the Harris detector responses. It has the type CV_32FC1 and the same size as src .
      blockSize - Neighborhood size (see the details on #cornerEigenValsAndVecs ).
      ksize - Aperture parameter for the Sobel operator.
      k - Harris detector free parameter. See the formula above.
      borderType - Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported.
    • cornerHarris

      public static void cornerHarris​(Mat src, Mat dst, int blockSize, int ksize, double k)
      Harris corner detector. The function runs the Harris corner detector on the image. Similarly to cornerMinEigenVal and cornerEigenValsAndVecs , for each pixel \((x, y)\) it calculates a \(2\times2\) gradient covariance matrix \(M^{(x,y)}\) over a \(\texttt{blockSize} \times \texttt{blockSize}\) neighborhood. Then, it computes the following characteristic: \(\texttt{dst} (x,y) = \mathrm{det} M^{(x,y)} - k \cdot \left ( \mathrm{tr} M^{(x,y)} \right )^2\) Corners in the image can be found as the local maxima of this response map.
      Parameters:
      src - Input single-channel 8-bit or floating-point image.
      dst - Image to store the Harris detector responses. It has the type CV_32FC1 and the same size as src .
      blockSize - Neighborhood size (see the details on #cornerEigenValsAndVecs ).
      ksize - Aperture parameter for the Sobel operator.
      k - Harris detector free parameter. See the formula above.
    • cornerEigenValsAndVecs

      public static void cornerEigenValsAndVecs​(Mat src, Mat dst, int blockSize, int ksize, int borderType)
      Calculates eigenvalues and eigenvectors of image blocks for corner detection. For every pixel \(p\) , the function cornerEigenValsAndVecs considers a blockSize \(\times\) blockSize neighborhood \(S(p)\) . It calculates the covariation matrix of derivatives over the neighborhood as: \(M = \begin{bmatrix} \sum _{S(p)}(dI/dx)^2 & \sum _{S(p)}dI/dx dI/dy \\ \sum _{S(p)}dI/dx dI/dy & \sum _{S(p)}(dI/dy)^2 \end{bmatrix}\) where the derivatives are computed using the Sobel operator. After that, it finds eigenvectors and eigenvalues of \(M\) and stores them in the destination image as \((\lambda_1, \lambda_2, x_1, y_1, x_2, y_2)\) where
      • \(\lambda_1, \lambda_2\) are the non-sorted eigenvalues of \(M\)
      • \(x_1, y_1\) are the eigenvectors corresponding to \(\lambda_1\)
      • \(x_2, y_2\) are the eigenvectors corresponding to \(\lambda_2\)
      The output of the function can be used for robust edge or corner detection.
      Parameters:
      src - Input single-channel 8-bit or floating-point image.
      dst - Image to store the results. It has the same size as src and the type CV_32FC(6) .
      blockSize - Neighborhood size (see details below).
      ksize - Aperture parameter for the Sobel operator.
      borderType - Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported. SEE: cornerMinEigenVal, cornerHarris, preCornerDetect
    • cornerEigenValsAndVecs

      public static void cornerEigenValsAndVecs​(Mat src, Mat dst, int blockSize, int ksize)
      Calculates eigenvalues and eigenvectors of image blocks for corner detection. For every pixel \(p\) , the function cornerEigenValsAndVecs considers a blockSize \(\times\) blockSize neighborhood \(S(p)\) . It calculates the covariation matrix of derivatives over the neighborhood as: \(M = \begin{bmatrix} \sum _{S(p)}(dI/dx)^2 & \sum _{S(p)}dI/dx dI/dy \\ \sum _{S(p)}dI/dx dI/dy & \sum _{S(p)}(dI/dy)^2 \end{bmatrix}\) where the derivatives are computed using the Sobel operator. After that, it finds eigenvectors and eigenvalues of \(M\) and stores them in the destination image as \((\lambda_1, \lambda_2, x_1, y_1, x_2, y_2)\) where
      • \(\lambda_1, \lambda_2\) are the non-sorted eigenvalues of \(M\)
      • \(x_1, y_1\) are the eigenvectors corresponding to \(\lambda_1\)
      • \(x_2, y_2\) are the eigenvectors corresponding to \(\lambda_2\)
      The output of the function can be used for robust edge or corner detection.
      Parameters:
      src - Input single-channel 8-bit or floating-point image.
      dst - Image to store the results. It has the same size as src and the type CV_32FC(6) .
      blockSize - Neighborhood size (see details below).
      ksize - Aperture parameter for the Sobel operator. SEE: cornerMinEigenVal, cornerHarris, preCornerDetect
    • preCornerDetect

      public static void preCornerDetect​(Mat src, Mat dst, int ksize, int borderType)
      Calculates a feature map for corner detection. The function calculates the complex spatial derivative-based function of the source image \(\texttt{dst} = (D_x \texttt{src} )^2 \cdot D_{yy} \texttt{src} + (D_y \texttt{src} )^2 \cdot D_{xx} \texttt{src} - 2 D_x \texttt{src} \cdot D_y \texttt{src} \cdot D_{xy} \texttt{src}\) where \(D_x\),\(D_y\) are the first image derivatives, \(D_{xx}\),\(D_{yy}\) are the second image derivatives, and \(D_{xy}\) is the mixed derivative. The corners can be found as local maximums of the functions, as shown below: Mat corners, dilated_corners; preCornerDetect(image, corners, 3); // dilation with 3x3 rectangular structuring element dilate(corners, dilated_corners, Mat(), 1); Mat corner_mask = corners == dilated_corners;
      Parameters:
      src - Source single-channel 8-bit of floating-point image.
      dst - Output image that has the type CV_32F and the same size as src .
      ksize - %Aperture size of the Sobel .
      borderType - Pixel extrapolation method. See #BorderTypes. #BORDER_WRAP is not supported.
    • preCornerDetect

      public static void preCornerDetect​(Mat src, Mat dst, int ksize)
      Calculates a feature map for corner detection. The function calculates the complex spatial derivative-based function of the source image \(\texttt{dst} = (D_x \texttt{src} )^2 \cdot D_{yy} \texttt{src} + (D_y \texttt{src} )^2 \cdot D_{xx} \texttt{src} - 2 D_x \texttt{src} \cdot D_y \texttt{src} \cdot D_{xy} \texttt{src}\) where \(D_x\),\(D_y\) are the first image derivatives, \(D_{xx}\),\(D_{yy}\) are the second image derivatives, and \(D_{xy}\) is the mixed derivative. The corners can be found as local maximums of the functions, as shown below: Mat corners, dilated_corners; preCornerDetect(image, corners, 3); // dilation with 3x3 rectangular structuring element dilate(corners, dilated_corners, Mat(), 1); Mat corner_mask = corners == dilated_corners;
      Parameters:
      src - Source single-channel 8-bit of floating-point image.
      dst - Output image that has the type CV_32F and the same size as src .
      ksize - %Aperture size of the Sobel .
    • cornerSubPix

      public static void cornerSubPix​(Mat image, Mat corners, Size winSize, Size zeroZone, TermCriteria criteria)
      Refines the corner locations. The function iterates to find the sub-pixel accurate location of corners or radial saddle points as described in CITE: forstner1987fast, and as shown on the figure below. ![image](pics/cornersubpix.png) Sub-pixel accurate corner locator is based on the observation that every vector from the center \(q\) to a point \(p\) located within a neighborhood of \(q\) is orthogonal to the image gradient at \(p\) subject to image and measurement noise. Consider the expression: \(\epsilon _i = {DI_{p_i}}^T \cdot (q - p_i)\) where \({DI_{p_i}}\) is an image gradient at one of the points \(p_i\) in a neighborhood of \(q\) . The value of \(q\) is to be found so that \(\epsilon_i\) is minimized. A system of equations may be set up with \(\epsilon_i\) set to zero: \(\sum _i(DI_{p_i} \cdot {DI_{p_i}}^T) \cdot q - \sum _i(DI_{p_i} \cdot {DI_{p_i}}^T \cdot p_i)\) where the gradients are summed within a neighborhood ("search window") of \(q\) . Calling the first gradient term \(G\) and the second gradient term \(b\) gives: \(q = G^{-1} \cdot b\) The algorithm sets the center of the neighborhood window at this new center \(q\) and then iterates until the center stays within a set threshold.
      Parameters:
      image - Input single-channel, 8-bit or float image.
      corners - Initial coordinates of the input corners and refined coordinates provided for output.
      winSize - Half of the side length of the search window. For example, if winSize=Size(5,5) , then a \((5*2+1) \times (5*2+1) = 11 \times 11\) search window is used.
      zeroZone - Half of the size of the dead region in the middle of the search zone over which the summation in the formula below is not done. It is used sometimes to avoid possible singularities of the autocorrelation matrix. The value of (-1,-1) indicates that there is no such a size.
      criteria - Criteria for termination of the iterative process of corner refinement. That is, the process of corner position refinement stops either after criteria.maxCount iterations or when the corner position moves by less than criteria.epsilon on some iteration.
    • goodFeaturesToTrack

      public static void goodFeaturesToTrack​(Mat image, MatOfPoint corners, int maxCorners, double qualityLevel, double minDistance, Mat mask, int blockSize, boolean useHarrisDetector, double k)
      Determines strong corners on an image. The function finds the most prominent corners in the image or in the specified image region, as described in CITE: Shi94
      • Function calculates the corner quality measure at every source image pixel using the #cornerMinEigenVal or #cornerHarris .
      • Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are retained).
      • The corners with the minimal eigenvalue less than \(\texttt{qualityLevel} \cdot \max_{x,y} qualityMeasureMap(x,y)\) are rejected.
      • The remaining corners are sorted by the quality measure in the descending order.
      • Function throws away each corner for which there is a stronger corner at a distance less than maxDistance.
      The function can be used to initialize a point-based tracker of an object. Note: If the function is called with different values A and B of the parameter qualityLevel , and A > B, the vector of returned corners with qualityLevel=A will be the prefix of the output vector with qualityLevel=B .
      Parameters:
      image - Input 8-bit or floating-point 32-bit, single-channel image.
      corners - Output vector of detected corners.
      maxCorners - Maximum number of corners to return. If there are more corners than are found, the strongest of them is returned. maxCorners &lt;= 0 implies that no limit on the maximum is set and all detected corners are returned.
      qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure less than 15 are rejected.
      minDistance - Minimum possible Euclidean distance between the returned corners.
      mask - Optional region of interest. If the image is not empty (it needs to have the type CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
      blockSize - Size of an average block for computing a derivative covariation matrix over each pixel neighborhood. See cornerEigenValsAndVecs .
      useHarrisDetector - Parameter indicating whether to use a Harris detector (see #cornerHarris) or #cornerMinEigenVal.
      k - Free parameter of the Harris detector. SEE: cornerMinEigenVal, cornerHarris, calcOpticalFlowPyrLK, estimateRigidTransform,
    • goodFeaturesToTrack

      public static void goodFeaturesToTrack​(Mat image, MatOfPoint corners, int maxCorners, double qualityLevel, double minDistance, Mat mask, int blockSize, boolean useHarrisDetector)
      Determines strong corners on an image. The function finds the most prominent corners in the image or in the specified image region, as described in CITE: Shi94
      • Function calculates the corner quality measure at every source image pixel using the #cornerMinEigenVal or #cornerHarris .
      • Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are retained).
      • The corners with the minimal eigenvalue less than \(\texttt{qualityLevel} \cdot \max_{x,y} qualityMeasureMap(x,y)\) are rejected.
      • The remaining corners are sorted by the quality measure in the descending order.
      • Function throws away each corner for which there is a stronger corner at a distance less than maxDistance.
      The function can be used to initialize a point-based tracker of an object. Note: If the function is called with different values A and B of the parameter qualityLevel , and A > B, the vector of returned corners with qualityLevel=A will be the prefix of the output vector with qualityLevel=B .
      Parameters:
      image - Input 8-bit or floating-point 32-bit, single-channel image.
      corners - Output vector of detected corners.
      maxCorners - Maximum number of corners to return. If there are more corners than are found, the strongest of them is returned. maxCorners &lt;= 0 implies that no limit on the maximum is set and all detected corners are returned.
      qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure less than 15 are rejected.
      minDistance - Minimum possible Euclidean distance between the returned corners.
      mask - Optional region of interest. If the image is not empty (it needs to have the type CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
      blockSize - Size of an average block for computing a derivative covariation matrix over each pixel neighborhood. See cornerEigenValsAndVecs .
      useHarrisDetector - Parameter indicating whether to use a Harris detector (see #cornerHarris) or #cornerMinEigenVal. SEE: cornerMinEigenVal, cornerHarris, calcOpticalFlowPyrLK, estimateRigidTransform,
    • goodFeaturesToTrack

      public static void goodFeaturesToTrack​(Mat image, MatOfPoint corners, int maxCorners, double qualityLevel, double minDistance, Mat mask, int blockSize)
      Determines strong corners on an image. The function finds the most prominent corners in the image or in the specified image region, as described in CITE: Shi94
      • Function calculates the corner quality measure at every source image pixel using the #cornerMinEigenVal or #cornerHarris .
      • Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are retained).
      • The corners with the minimal eigenvalue less than \(\texttt{qualityLevel} \cdot \max_{x,y} qualityMeasureMap(x,y)\) are rejected.
      • The remaining corners are sorted by the quality measure in the descending order.
      • Function throws away each corner for which there is a stronger corner at a distance less than maxDistance.
      The function can be used to initialize a point-based tracker of an object. Note: If the function is called with different values A and B of the parameter qualityLevel , and A > B, the vector of returned corners with qualityLevel=A will be the prefix of the output vector with qualityLevel=B .
      Parameters:
      image - Input 8-bit or floating-point 32-bit, single-channel image.
      corners - Output vector of detected corners.
      maxCorners - Maximum number of corners to return. If there are more corners than are found, the strongest of them is returned. maxCorners &lt;= 0 implies that no limit on the maximum is set and all detected corners are returned.
      qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure less than 15 are rejected.
      minDistance - Minimum possible Euclidean distance between the returned corners.
      mask - Optional region of interest. If the image is not empty (it needs to have the type CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
      blockSize - Size of an average block for computing a derivative covariation matrix over each pixel neighborhood. See cornerEigenValsAndVecs . or #cornerMinEigenVal. SEE: cornerMinEigenVal, cornerHarris, calcOpticalFlowPyrLK, estimateRigidTransform,
    • goodFeaturesToTrack

      public static void goodFeaturesToTrack​(Mat image, MatOfPoint corners, int maxCorners, double qualityLevel, double minDistance, Mat mask)
      Determines strong corners on an image. The function finds the most prominent corners in the image or in the specified image region, as described in CITE: Shi94
      • Function calculates the corner quality measure at every source image pixel using the #cornerMinEigenVal or #cornerHarris .
      • Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are retained).
      • The corners with the minimal eigenvalue less than \(\texttt{qualityLevel} \cdot \max_{x,y} qualityMeasureMap(x,y)\) are rejected.
      • The remaining corners are sorted by the quality measure in the descending order.
      • Function throws away each corner for which there is a stronger corner at a distance less than maxDistance.
      The function can be used to initialize a point-based tracker of an object. Note: If the function is called with different values A and B of the parameter qualityLevel , and A > B, the vector of returned corners with qualityLevel=A will be the prefix of the output vector with qualityLevel=B .
      Parameters:
      image - Input 8-bit or floating-point 32-bit, single-channel image.
      corners - Output vector of detected corners.
      maxCorners - Maximum number of corners to return. If there are more corners than are found, the strongest of them is returned. maxCorners &lt;= 0 implies that no limit on the maximum is set and all detected corners are returned.
      qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure less than 15 are rejected.
      minDistance - Minimum possible Euclidean distance between the returned corners.
      mask - Optional region of interest. If the image is not empty (it needs to have the type CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected. pixel neighborhood. See cornerEigenValsAndVecs . or #cornerMinEigenVal. SEE: cornerMinEigenVal, cornerHarris, calcOpticalFlowPyrLK, estimateRigidTransform,
    • goodFeaturesToTrack

      public static void goodFeaturesToTrack​(Mat image, MatOfPoint corners, int maxCorners, double qualityLevel, double minDistance)
      Determines strong corners on an image. The function finds the most prominent corners in the image or in the specified image region, as described in CITE: Shi94
      • Function calculates the corner quality measure at every source image pixel using the #cornerMinEigenVal or #cornerHarris .
      • Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are retained).
      • The corners with the minimal eigenvalue less than \(\texttt{qualityLevel} \cdot \max_{x,y} qualityMeasureMap(x,y)\) are rejected.
      • The remaining corners are sorted by the quality measure in the descending order.
      • Function throws away each corner for which there is a stronger corner at a distance less than maxDistance.
      The function can be used to initialize a point-based tracker of an object. Note: If the function is called with different values A and B of the parameter qualityLevel , and A > B, the vector of returned corners with qualityLevel=A will be the prefix of the output vector with qualityLevel=B .
      Parameters:
      image - Input 8-bit or floating-point 32-bit, single-channel image.
      corners - Output vector of detected corners.
      maxCorners - Maximum number of corners to return. If there are more corners than are found, the strongest of them is returned. maxCorners &lt;= 0 implies that no limit on the maximum is set and all detected corners are returned.
      qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure less than 15 are rejected.
      minDistance - Minimum possible Euclidean distance between the returned corners. CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected. pixel neighborhood. See cornerEigenValsAndVecs . or #cornerMinEigenVal. SEE: cornerMinEigenVal, cornerHarris, calcOpticalFlowPyrLK, estimateRigidTransform,
    • goodFeaturesToTrack

      public static void goodFeaturesToTrack​(Mat image, MatOfPoint corners, int maxCorners, double qualityLevel, double minDistance, Mat mask, int blockSize, int gradientSize, boolean useHarrisDetector, double k)
    • goodFeaturesToTrack

      public static void goodFeaturesToTrack​(Mat image, MatOfPoint corners, int maxCorners, double qualityLevel, double minDistance, Mat mask, int blockSize, int gradientSize, boolean useHarrisDetector)
    • goodFeaturesToTrack

      public static void goodFeaturesToTrack​(Mat image, MatOfPoint corners, int maxCorners, double qualityLevel, double minDistance, Mat mask, int blockSize, int gradientSize)
    • goodFeaturesToTrackWithQuality

      public static void goodFeaturesToTrackWithQuality​(Mat image, Mat corners, int maxCorners, double qualityLevel, double minDistance, Mat mask, Mat cornersQuality, int blockSize, int gradientSize, boolean useHarrisDetector, double k)
      Same as above, but returns also quality measure of the detected corners.
      Parameters:
      image - Input 8-bit or floating-point 32-bit, single-channel image.
      corners - Output vector of detected corners.
      maxCorners - Maximum number of corners to return. If there are more corners than are found, the strongest of them is returned. maxCorners &lt;= 0 implies that no limit on the maximum is set and all detected corners are returned.
      qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure less than 15 are rejected.
      minDistance - Minimum possible Euclidean distance between the returned corners.
      mask - Region of interest. If the image is not empty (it needs to have the type CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
      cornersQuality - Output vector of quality measure of the detected corners.
      blockSize - Size of an average block for computing a derivative covariation matrix over each pixel neighborhood. See cornerEigenValsAndVecs .
      gradientSize - Aperture parameter for the Sobel operator used for derivatives computation. See cornerEigenValsAndVecs .
      useHarrisDetector - Parameter indicating whether to use a Harris detector (see #cornerHarris) or #cornerMinEigenVal.
      k - Free parameter of the Harris detector.
    • goodFeaturesToTrackWithQuality

      public static void goodFeaturesToTrackWithQuality​(Mat image, Mat corners, int maxCorners, double qualityLevel, double minDistance, Mat mask, Mat cornersQuality, int blockSize, int gradientSize, boolean useHarrisDetector)
      Same as above, but returns also quality measure of the detected corners.
      Parameters:
      image - Input 8-bit or floating-point 32-bit, single-channel image.
      corners - Output vector of detected corners.
      maxCorners - Maximum number of corners to return. If there are more corners than are found, the strongest of them is returned. maxCorners &lt;= 0 implies that no limit on the maximum is set and all detected corners are returned.
      qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure less than 15 are rejected.
      minDistance - Minimum possible Euclidean distance between the returned corners.
      mask - Region of interest. If the image is not empty (it needs to have the type CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
      cornersQuality - Output vector of quality measure of the detected corners.
      blockSize - Size of an average block for computing a derivative covariation matrix over each pixel neighborhood. See cornerEigenValsAndVecs .
      gradientSize - Aperture parameter for the Sobel operator used for derivatives computation. See cornerEigenValsAndVecs .
      useHarrisDetector - Parameter indicating whether to use a Harris detector (see #cornerHarris) or #cornerMinEigenVal.
    • goodFeaturesToTrackWithQuality

      public static void goodFeaturesToTrackWithQuality​(Mat image, Mat corners, int maxCorners, double qualityLevel, double minDistance, Mat mask, Mat cornersQuality, int blockSize, int gradientSize)
      Same as above, but returns also quality measure of the detected corners.
      Parameters:
      image - Input 8-bit or floating-point 32-bit, single-channel image.
      corners - Output vector of detected corners.
      maxCorners - Maximum number of corners to return. If there are more corners than are found, the strongest of them is returned. maxCorners &lt;= 0 implies that no limit on the maximum is set and all detected corners are returned.
      qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure less than 15 are rejected.
      minDistance - Minimum possible Euclidean distance between the returned corners.
      mask - Region of interest. If the image is not empty (it needs to have the type CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
      cornersQuality - Output vector of quality measure of the detected corners.
      blockSize - Size of an average block for computing a derivative covariation matrix over each pixel neighborhood. See cornerEigenValsAndVecs .
      gradientSize - Aperture parameter for the Sobel operator used for derivatives computation. See cornerEigenValsAndVecs . or #cornerMinEigenVal.
    • goodFeaturesToTrackWithQuality

      public static void goodFeaturesToTrackWithQuality​(Mat image, Mat corners, int maxCorners, double qualityLevel, double minDistance, Mat mask, Mat cornersQuality, int blockSize)
      Same as above, but returns also quality measure of the detected corners.
      Parameters:
      image - Input 8-bit or floating-point 32-bit, single-channel image.
      corners - Output vector of detected corners.
      maxCorners - Maximum number of corners to return. If there are more corners than are found, the strongest of them is returned. maxCorners &lt;= 0 implies that no limit on the maximum is set and all detected corners are returned.
      qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure less than 15 are rejected.
      minDistance - Minimum possible Euclidean distance between the returned corners.
      mask - Region of interest. If the image is not empty (it needs to have the type CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
      cornersQuality - Output vector of quality measure of the detected corners.
      blockSize - Size of an average block for computing a derivative covariation matrix over each pixel neighborhood. See cornerEigenValsAndVecs . See cornerEigenValsAndVecs . or #cornerMinEigenVal.
    • goodFeaturesToTrackWithQuality

      public static void goodFeaturesToTrackWithQuality​(Mat image, Mat corners, int maxCorners, double qualityLevel, double minDistance, Mat mask, Mat cornersQuality)
      Same as above, but returns also quality measure of the detected corners.
      Parameters:
      image - Input 8-bit or floating-point 32-bit, single-channel image.
      corners - Output vector of detected corners.
      maxCorners - Maximum number of corners to return. If there are more corners than are found, the strongest of them is returned. maxCorners &lt;= 0 implies that no limit on the maximum is set and all detected corners are returned.
      qualityLevel - Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure, which is the minimal eigenvalue (see #cornerMinEigenVal ) or the Harris function response (see #cornerHarris ). The corners with the quality measure less than the product are rejected. For example, if the best corner has the quality measure = 1500, and the qualityLevel=0.01 , then all the corners with the quality measure less than 15 are rejected.
      minDistance - Minimum possible Euclidean distance between the returned corners.
      mask - Region of interest. If the image is not empty (it needs to have the type CV_8UC1 and the same size as image ), it specifies the region in which the corners are detected.
      cornersQuality - Output vector of quality measure of the detected corners. pixel neighborhood. See cornerEigenValsAndVecs . See cornerEigenValsAndVecs . or #cornerMinEigenVal.
    • HoughLines

      public static void HoughLines​(Mat image, Mat lines, double rho, double theta, int threshold, double srn, double stn, double min_theta, double max_theta)
      Finds lines in a binary image using the standard Hough transform. The function implements the standard or standard multi-scale Hough transform algorithm for line detection. See <http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm> for a good explanation of Hough transform.
      Parameters:
      image - 8-bit, single-channel binary source image. The image may be modified by the function.
      lines - Output vector of lines. Each line is represented by a 2 or 3 element vector \((\rho, \theta)\) or \((\rho, \theta, \textrm{votes})\) . \(\rho\) is the distance from the coordinate origin \((0,0)\) (top-left corner of the image). \(\theta\) is the line rotation angle in radians ( \(0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line}\) ). \(\textrm{votes}\) is the value of accumulator.
      rho - Distance resolution of the accumulator in pixels.
      theta - Angle resolution of the accumulator in radians.
      threshold - Accumulator threshold parameter. Only those lines are returned that get enough votes ( \(>\texttt{threshold}\) ).
      srn - For the multi-scale Hough transform, it is a divisor for the distance resolution rho . The coarse accumulator distance resolution is rho and the accurate accumulator resolution is rho/srn . If both srn=0 and stn=0 , the classical Hough transform is used. Otherwise, both these parameters should be positive.
      stn - For the multi-scale Hough transform, it is a divisor for the distance resolution theta.
      min_theta - For standard and multi-scale Hough transform, minimum angle to check for lines. Must fall between 0 and max_theta.
      max_theta - For standard and multi-scale Hough transform, maximum angle to check for lines. Must fall between min_theta and CV_PI.
    • HoughLines

      public static void HoughLines​(Mat image, Mat lines, double rho, double theta, int threshold, double srn, double stn, double min_theta)
      Finds lines in a binary image using the standard Hough transform. The function implements the standard or standard multi-scale Hough transform algorithm for line detection. See <http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm> for a good explanation of Hough transform.
      Parameters:
      image - 8-bit, single-channel binary source image. The image may be modified by the function.
      lines - Output vector of lines. Each line is represented by a 2 or 3 element vector \((\rho, \theta)\) or \((\rho, \theta, \textrm{votes})\) . \(\rho\) is the distance from the coordinate origin \((0,0)\) (top-left corner of the image). \(\theta\) is the line rotation angle in radians ( \(0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line}\) ). \(\textrm{votes}\) is the value of accumulator.
      rho - Distance resolution of the accumulator in pixels.
      theta - Angle resolution of the accumulator in radians.
      threshold - Accumulator threshold parameter. Only those lines are returned that get enough votes ( \(>\texttt{threshold}\) ).
      srn - For the multi-scale Hough transform, it is a divisor for the distance resolution rho . The coarse accumulator distance resolution is rho and the accurate accumulator resolution is rho/srn . If both srn=0 and stn=0 , the classical Hough transform is used. Otherwise, both these parameters should be positive.
      stn - For the multi-scale Hough transform, it is a divisor for the distance resolution theta.
      min_theta - For standard and multi-scale Hough transform, minimum angle to check for lines. Must fall between 0 and max_theta. Must fall between min_theta and CV_PI.
    • HoughLines

      public static void HoughLines​(Mat image, Mat lines, double rho, double theta, int threshold, double srn, double stn)
      Finds lines in a binary image using the standard Hough transform. The function implements the standard or standard multi-scale Hough transform algorithm for line detection. See <http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm> for a good explanation of Hough transform.
      Parameters:
      image - 8-bit, single-channel binary source image. The image may be modified by the function.
      lines - Output vector of lines. Each line is represented by a 2 or 3 element vector \((\rho, \theta)\) or \((\rho, \theta, \textrm{votes})\) . \(\rho\) is the distance from the coordinate origin \((0,0)\) (top-left corner of the image). \(\theta\) is the line rotation angle in radians ( \(0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line}\) ). \(\textrm{votes}\) is the value of accumulator.
      rho - Distance resolution of the accumulator in pixels.
      theta - Angle resolution of the accumulator in radians.
      threshold - Accumulator threshold parameter. Only those lines are returned that get enough votes ( \(>\texttt{threshold}\) ).
      srn - For the multi-scale Hough transform, it is a divisor for the distance resolution rho . The coarse accumulator distance resolution is rho and the accurate accumulator resolution is rho/srn . If both srn=0 and stn=0 , the classical Hough transform is used. Otherwise, both these parameters should be positive.
      stn - For the multi-scale Hough transform, it is a divisor for the distance resolution theta. Must fall between 0 and max_theta. Must fall between min_theta and CV_PI.
    • HoughLines

      public static void HoughLines​(Mat image, Mat lines, double rho, double theta, int threshold, double srn)
      Finds lines in a binary image using the standard Hough transform. The function implements the standard or standard multi-scale Hough transform algorithm for line detection. See <http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm> for a good explanation of Hough transform.
      Parameters:
      image - 8-bit, single-channel binary source image. The image may be modified by the function.
      lines - Output vector of lines. Each line is represented by a 2 or 3 element vector \((\rho, \theta)\) or \((\rho, \theta, \textrm{votes})\) . \(\rho\) is the distance from the coordinate origin \((0,0)\) (top-left corner of the image). \(\theta\) is the line rotation angle in radians ( \(0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line}\) ). \(\textrm{votes}\) is the value of accumulator.
      rho - Distance resolution of the accumulator in pixels.
      theta - Angle resolution of the accumulator in radians.
      threshold - Accumulator threshold parameter. Only those lines are returned that get enough votes ( \(>\texttt{threshold}\) ).
      srn - For the multi-scale Hough transform, it is a divisor for the distance resolution rho . The coarse accumulator distance resolution is rho and the accurate accumulator resolution is rho/srn . If both srn=0 and stn=0 , the classical Hough transform is used. Otherwise, both these parameters should be positive. Must fall between 0 and max_theta. Must fall between min_theta and CV_PI.
    • HoughLines

      public static void HoughLines​(Mat image, Mat lines, double rho, double theta, int threshold)
      Finds lines in a binary image using the standard Hough transform. The function implements the standard or standard multi-scale Hough transform algorithm for line detection. See <http://homepages.inf.ed.ac.uk/rbf/HIPR2/hough.htm> for a good explanation of Hough transform.
      Parameters:
      image - 8-bit, single-channel binary source image. The image may be modified by the function.
      lines - Output vector of lines. Each line is represented by a 2 or 3 element vector \((\rho, \theta)\) or \((\rho, \theta, \textrm{votes})\) . \(\rho\) is the distance from the coordinate origin \((0,0)\) (top-left corner of the image). \(\theta\) is the line rotation angle in radians ( \(0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line}\) ). \(\textrm{votes}\) is the value of accumulator.
      rho - Distance resolution of the accumulator in pixels.
      theta - Angle resolution of the accumulator in radians.
      threshold - Accumulator threshold parameter. Only those lines are returned that get enough votes ( \(>\texttt{threshold}\) ). The coarse accumulator distance resolution is rho and the accurate accumulator resolution is rho/srn . If both srn=0 and stn=0 , the classical Hough transform is used. Otherwise, both these parameters should be positive. Must fall between 0 and max_theta. Must fall between min_theta and CV_PI.
    • HoughLinesP

      public static void HoughLinesP​(Mat image, Mat lines, double rho, double theta, int threshold, double minLineLength, double maxLineGap)
      Finds line segments in a binary image using the probabilistic Hough transform. The function implements the probabilistic Hough transform algorithm for line detection, described in CITE: Matas00 See the line detection example below: INCLUDE: snippets/imgproc_HoughLinesP.cpp This is a sample picture the function parameters have been tuned for: ![image](pics/building.jpg) And this is the output of the above program in case of the probabilistic Hough transform: ![image](pics/houghp.png)
      Parameters:
      image - 8-bit, single-channel binary source image. The image may be modified by the function.
      lines - Output vector of lines. Each line is represented by a 4-element vector \((x_1, y_1, x_2, y_2)\) , where \((x_1,y_1)\) and \((x_2, y_2)\) are the ending points of each detected line segment.
      rho - Distance resolution of the accumulator in pixels.
      theta - Angle resolution of the accumulator in radians.
      threshold - Accumulator threshold parameter. Only those lines are returned that get enough votes ( \(>\texttt{threshold}\) ).
      minLineLength - Minimum line length. Line segments shorter than that are rejected.
      maxLineGap - Maximum allowed gap between points on the same line to link them. SEE: LineSegmentDetector
    • HoughLinesP

      public static void HoughLinesP​(Mat image, Mat lines, double rho, double theta, int threshold, double minLineLength)
      Finds line segments in a binary image using the probabilistic Hough transform. The function implements the probabilistic Hough transform algorithm for line detection, described in CITE: Matas00 See the line detection example below: INCLUDE: snippets/imgproc_HoughLinesP.cpp This is a sample picture the function parameters have been tuned for: ![image](pics/building.jpg) And this is the output of the above program in case of the probabilistic Hough transform: ![image](pics/houghp.png)
      Parameters:
      image - 8-bit, single-channel binary source image. The image may be modified by the function.
      lines - Output vector of lines. Each line is represented by a 4-element vector \((x_1, y_1, x_2, y_2)\) , where \((x_1,y_1)\) and \((x_2, y_2)\) are the ending points of each detected line segment.
      rho - Distance resolution of the accumulator in pixels.
      theta - Angle resolution of the accumulator in radians.
      threshold - Accumulator threshold parameter. Only those lines are returned that get enough votes ( \(>\texttt{threshold}\) ).
      minLineLength - Minimum line length. Line segments shorter than that are rejected. SEE: LineSegmentDetector
    • HoughLinesP

      public static void HoughLinesP​(Mat image, Mat lines, double rho, double theta, int threshold)
      Finds line segments in a binary image using the probabilistic Hough transform. The function implements the probabilistic Hough transform algorithm for line detection, described in CITE: Matas00 See the line detection example below: INCLUDE: snippets/imgproc_HoughLinesP.cpp This is a sample picture the function parameters have been tuned for: ![image](pics/building.jpg) And this is the output of the above program in case of the probabilistic Hough transform: ![image](pics/houghp.png)
      Parameters:
      image - 8-bit, single-channel binary source image. The image may be modified by the function.
      lines - Output vector of lines. Each line is represented by a 4-element vector \((x_1, y_1, x_2, y_2)\) , where \((x_1,y_1)\) and \((x_2, y_2)\) are the ending points of each detected line segment.
      rho - Distance resolution of the accumulator in pixels.
      theta - Angle resolution of the accumulator in radians.
      threshold - Accumulator threshold parameter. Only those lines are returned that get enough votes ( \(>\texttt{threshold}\) ). SEE: LineSegmentDetector
    • HoughLinesPointSet

      public static void HoughLinesPointSet​(Mat point, Mat lines, int lines_max, int threshold, double min_rho, double max_rho, double rho_step, double min_theta, double max_theta, double theta_step)
      Finds lines in a set of points using the standard Hough transform. The function finds lines in a set of points using a modification of the Hough transform. INCLUDE: snippets/imgproc_HoughLinesPointSet.cpp
      Parameters:
      point - Input vector of points. Each vector must be encoded as a Point vector \((x,y)\). Type must be CV_32FC2 or CV_32SC2.
      lines - Output vector of found lines. Each vector is encoded as a vector<Vec3d> \((votes, rho, theta)\). The larger the value of 'votes', the higher the reliability of the Hough line.
      lines_max - Max count of Hough lines.
      threshold - Accumulator threshold parameter. Only those lines are returned that get enough votes ( \(>\texttt{threshold}\) ).
      min_rho - Minimum value for \(\rho\) for the accumulator (Note: \(\rho\) can be negative. The absolute value \(|\rho|\) is the distance of a line to the origin.).
      max_rho - Maximum value for \(\rho\) for the accumulator.
      rho_step - Distance resolution of the accumulator.
      min_theta - Minimum angle value of the accumulator in radians.
      max_theta - Maximum angle value of the accumulator in radians.
      theta_step - Angle resolution of the accumulator in radians.
    • HoughCircles

      public static void HoughCircles​(Mat image, Mat circles, int method, double dp, double minDist, double param1, double param2, int minRadius, int maxRadius)
      Finds circles in a grayscale image using the Hough transform. The function finds circles in a grayscale image using a modification of the Hough transform. Example: : INCLUDE: snippets/imgproc_HoughLinesCircles.cpp Note: Usually the function detects the centers of circles well. However, it may fail to find correct radii. You can assist to the function by specifying the radius range ( minRadius and maxRadius ) if you know it. Or, in the case of #HOUGH_GRADIENT method you may set maxRadius to a negative number to return centers only without radius search, and find the correct radius using an additional procedure. It also helps to smooth image a bit unless it's already soft. For example, GaussianBlur() with 7x7 kernel and 1.5x1.5 sigma or similar blurring may help.
      Parameters:
      image - 8-bit, single-channel, grayscale input image.
      circles - Output vector of found circles. Each vector is encoded as 3 or 4 element floating-point vector \((x, y, radius)\) or \((x, y, radius, votes)\) .
      method - Detection method, see #HoughModes. The available methods are #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT.
      dp - Inverse ratio of the accumulator resolution to the image resolution. For example, if dp=1 , the accumulator has the same resolution as the input image. If dp=2 , the accumulator has half as big width and height. For #HOUGH_GRADIENT_ALT the recommended value is dp=1.5, unless some small very circles need to be detected.
      minDist - Minimum distance between the centers of the detected circles. If the parameter is too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is too large, some circles may be missed.
      param1 - First method-specific parameter. In case of #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT, it is the higher threshold of the two passed to the Canny edge detector (the lower one is twice smaller). Note that #HOUGH_GRADIENT_ALT uses #Scharr algorithm to compute image derivatives, so the threshold value shough normally be higher, such as 300 or normally exposed and contrasty images.
      param2 - Second method-specific parameter. In case of #HOUGH_GRADIENT, it is the accumulator threshold for the circle centers at the detection stage. The smaller it is, the more false circles may be detected. Circles, corresponding to the larger accumulator values, will be returned first. In the case of #HOUGH_GRADIENT_ALT algorithm, this is the circle "perfectness" measure. The closer it to 1, the better shaped circles algorithm selects. In most cases 0.9 should be fine. If you want get better detection of small circles, you may decrease it to 0.85, 0.8 or even less. But then also try to limit the search range [minRadius, maxRadius] to avoid many false circles.
      minRadius - Minimum circle radius.
      maxRadius - Maximum circle radius. If <= 0, uses the maximum image dimension. If < 0, #HOUGH_GRADIENT returns centers without finding the radius. #HOUGH_GRADIENT_ALT always computes circle radiuses. SEE: fitEllipse, minEnclosingCircle
    • HoughCircles

      public static void HoughCircles​(Mat image, Mat circles, int method, double dp, double minDist, double param1, double param2, int minRadius)
      Finds circles in a grayscale image using the Hough transform. The function finds circles in a grayscale image using a modification of the Hough transform. Example: : INCLUDE: snippets/imgproc_HoughLinesCircles.cpp Note: Usually the function detects the centers of circles well. However, it may fail to find correct radii. You can assist to the function by specifying the radius range ( minRadius and maxRadius ) if you know it. Or, in the case of #HOUGH_GRADIENT method you may set maxRadius to a negative number to return centers only without radius search, and find the correct radius using an additional procedure. It also helps to smooth image a bit unless it's already soft. For example, GaussianBlur() with 7x7 kernel and 1.5x1.5 sigma or similar blurring may help.
      Parameters:
      image - 8-bit, single-channel, grayscale input image.
      circles - Output vector of found circles. Each vector is encoded as 3 or 4 element floating-point vector \((x, y, radius)\) or \((x, y, radius, votes)\) .
      method - Detection method, see #HoughModes. The available methods are #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT.
      dp - Inverse ratio of the accumulator resolution to the image resolution. For example, if dp=1 , the accumulator has the same resolution as the input image. If dp=2 , the accumulator has half as big width and height. For #HOUGH_GRADIENT_ALT the recommended value is dp=1.5, unless some small very circles need to be detected.
      minDist - Minimum distance between the centers of the detected circles. If the parameter is too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is too large, some circles may be missed.
      param1 - First method-specific parameter. In case of #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT, it is the higher threshold of the two passed to the Canny edge detector (the lower one is twice smaller). Note that #HOUGH_GRADIENT_ALT uses #Scharr algorithm to compute image derivatives, so the threshold value shough normally be higher, such as 300 or normally exposed and contrasty images.
      param2 - Second method-specific parameter. In case of #HOUGH_GRADIENT, it is the accumulator threshold for the circle centers at the detection stage. The smaller it is, the more false circles may be detected. Circles, corresponding to the larger accumulator values, will be returned first. In the case of #HOUGH_GRADIENT_ALT algorithm, this is the circle "perfectness" measure. The closer it to 1, the better shaped circles algorithm selects. In most cases 0.9 should be fine. If you want get better detection of small circles, you may decrease it to 0.85, 0.8 or even less. But then also try to limit the search range [minRadius, maxRadius] to avoid many false circles.
      minRadius - Minimum circle radius. centers without finding the radius. #HOUGH_GRADIENT_ALT always computes circle radiuses. SEE: fitEllipse, minEnclosingCircle
    • HoughCircles

      public static void HoughCircles​(Mat image, Mat circles, int method, double dp, double minDist, double param1, double param2)
      Finds circles in a grayscale image using the Hough transform. The function finds circles in a grayscale image using a modification of the Hough transform. Example: : INCLUDE: snippets/imgproc_HoughLinesCircles.cpp Note: Usually the function detects the centers of circles well. However, it may fail to find correct radii. You can assist to the function by specifying the radius range ( minRadius and maxRadius ) if you know it. Or, in the case of #HOUGH_GRADIENT method you may set maxRadius to a negative number to return centers only without radius search, and find the correct radius using an additional procedure. It also helps to smooth image a bit unless it's already soft. For example, GaussianBlur() with 7x7 kernel and 1.5x1.5 sigma or similar blurring may help.
      Parameters:
      image - 8-bit, single-channel, grayscale input image.
      circles - Output vector of found circles. Each vector is encoded as 3 or 4 element floating-point vector \((x, y, radius)\) or \((x, y, radius, votes)\) .
      method - Detection method, see #HoughModes. The available methods are #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT.
      dp - Inverse ratio of the accumulator resolution to the image resolution. For example, if dp=1 , the accumulator has the same resolution as the input image. If dp=2 , the accumulator has half as big width and height. For #HOUGH_GRADIENT_ALT the recommended value is dp=1.5, unless some small very circles need to be detected.
      minDist - Minimum distance between the centers of the detected circles. If the parameter is too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is too large, some circles may be missed.
      param1 - First method-specific parameter. In case of #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT, it is the higher threshold of the two passed to the Canny edge detector (the lower one is twice smaller). Note that #HOUGH_GRADIENT_ALT uses #Scharr algorithm to compute image derivatives, so the threshold value shough normally be higher, such as 300 or normally exposed and contrasty images.
      param2 - Second method-specific parameter. In case of #HOUGH_GRADIENT, it is the accumulator threshold for the circle centers at the detection stage. The smaller it is, the more false circles may be detected. Circles, corresponding to the larger accumulator values, will be returned first. In the case of #HOUGH_GRADIENT_ALT algorithm, this is the circle "perfectness" measure. The closer it to 1, the better shaped circles algorithm selects. In most cases 0.9 should be fine. If you want get better detection of small circles, you may decrease it to 0.85, 0.8 or even less. But then also try to limit the search range [minRadius, maxRadius] to avoid many false circles. centers without finding the radius. #HOUGH_GRADIENT_ALT always computes circle radiuses. SEE: fitEllipse, minEnclosingCircle
    • HoughCircles

      public static void HoughCircles​(Mat image, Mat circles, int method, double dp, double minDist, double param1)
      Finds circles in a grayscale image using the Hough transform. The function finds circles in a grayscale image using a modification of the Hough transform. Example: : INCLUDE: snippets/imgproc_HoughLinesCircles.cpp Note: Usually the function detects the centers of circles well. However, it may fail to find correct radii. You can assist to the function by specifying the radius range ( minRadius and maxRadius ) if you know it. Or, in the case of #HOUGH_GRADIENT method you may set maxRadius to a negative number to return centers only without radius search, and find the correct radius using an additional procedure. It also helps to smooth image a bit unless it's already soft. For example, GaussianBlur() with 7x7 kernel and 1.5x1.5 sigma or similar blurring may help.
      Parameters:
      image - 8-bit, single-channel, grayscale input image.
      circles - Output vector of found circles. Each vector is encoded as 3 or 4 element floating-point vector \((x, y, radius)\) or \((x, y, radius, votes)\) .
      method - Detection method, see #HoughModes. The available methods are #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT.
      dp - Inverse ratio of the accumulator resolution to the image resolution. For example, if dp=1 , the accumulator has the same resolution as the input image. If dp=2 , the accumulator has half as big width and height. For #HOUGH_GRADIENT_ALT the recommended value is dp=1.5, unless some small very circles need to be detected.
      minDist - Minimum distance between the centers of the detected circles. If the parameter is too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is too large, some circles may be missed.
      param1 - First method-specific parameter. In case of #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT, it is the higher threshold of the two passed to the Canny edge detector (the lower one is twice smaller). Note that #HOUGH_GRADIENT_ALT uses #Scharr algorithm to compute image derivatives, so the threshold value shough normally be higher, such as 300 or normally exposed and contrasty images. accumulator threshold for the circle centers at the detection stage. The smaller it is, the more false circles may be detected. Circles, corresponding to the larger accumulator values, will be returned first. In the case of #HOUGH_GRADIENT_ALT algorithm, this is the circle "perfectness" measure. The closer it to 1, the better shaped circles algorithm selects. In most cases 0.9 should be fine. If you want get better detection of small circles, you may decrease it to 0.85, 0.8 or even less. But then also try to limit the search range [minRadius, maxRadius] to avoid many false circles. centers without finding the radius. #HOUGH_GRADIENT_ALT always computes circle radiuses. SEE: fitEllipse, minEnclosingCircle
    • HoughCircles

      public static void HoughCircles​(Mat image, Mat circles, int method, double dp, double minDist)
      Finds circles in a grayscale image using the Hough transform. The function finds circles in a grayscale image using a modification of the Hough transform. Example: : INCLUDE: snippets/imgproc_HoughLinesCircles.cpp Note: Usually the function detects the centers of circles well. However, it may fail to find correct radii. You can assist to the function by specifying the radius range ( minRadius and maxRadius ) if you know it. Or, in the case of #HOUGH_GRADIENT method you may set maxRadius to a negative number to return centers only without radius search, and find the correct radius using an additional procedure. It also helps to smooth image a bit unless it's already soft. For example, GaussianBlur() with 7x7 kernel and 1.5x1.5 sigma or similar blurring may help.
      Parameters:
      image - 8-bit, single-channel, grayscale input image.
      circles - Output vector of found circles. Each vector is encoded as 3 or 4 element floating-point vector \((x, y, radius)\) or \((x, y, radius, votes)\) .
      method - Detection method, see #HoughModes. The available methods are #HOUGH_GRADIENT and #HOUGH_GRADIENT_ALT.
      dp - Inverse ratio of the accumulator resolution to the image resolution. For example, if dp=1 , the accumulator has the same resolution as the input image. If dp=2 , the accumulator has half as big width and height. For #HOUGH_GRADIENT_ALT the recommended value is dp=1.5, unless some small very circles need to be detected.
      minDist - Minimum distance between the centers of the detected circles. If the parameter is too small, multiple neighbor circles may be falsely detected in addition to a true one. If it is too large, some circles may be missed. it is the higher threshold of the two passed to the Canny edge detector (the lower one is twice smaller). Note that #HOUGH_GRADIENT_ALT uses #Scharr algorithm to compute image derivatives, so the threshold value shough normally be higher, such as 300 or normally exposed and contrasty images. accumulator threshold for the circle centers at the detection stage. The smaller it is, the more false circles may be detected. Circles, corresponding to the larger accumulator values, will be returned first. In the case of #HOUGH_GRADIENT_ALT algorithm, this is the circle "perfectness" measure. The closer it to 1, the better shaped circles algorithm selects. In most cases 0.9 should be fine. If you want get better detection of small circles, you may decrease it to 0.85, 0.8 or even less. But then also try to limit the search range [minRadius, maxRadius] to avoid many false circles. centers without finding the radius. #HOUGH_GRADIENT_ALT always computes circle radiuses. SEE: fitEllipse, minEnclosingCircle
    • erode

      public static void erode​(Mat src, Mat dst, Mat kernel, Point anchor, int iterations, int borderType, Scalar borderValue)
      Erodes an image by using a specific structuring element. The function erodes the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the minimum is taken: \(\texttt{dst} (x,y) = \min _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\) The function supports the in-place mode. Erosion can be applied several ( iterations ) times. In case of multi-channel images, each channel is processed independently.
      Parameters:
      src - input image; the number of channels can be arbitrary, but the depth should be one of CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - output image of the same size and type as src.
      kernel - structuring element used for erosion; if element=Mat(), a 3 x 3 rectangular structuring element is used. Kernel can be created using #getStructuringElement.
      anchor - position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center.
      iterations - number of times erosion is applied.
      borderType - pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.
      borderValue - border value in case of a constant border SEE: dilate, morphologyEx, getStructuringElement
    • erode

      public static void erode​(Mat src, Mat dst, Mat kernel, Point anchor, int iterations, int borderType)
      Erodes an image by using a specific structuring element. The function erodes the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the minimum is taken: \(\texttt{dst} (x,y) = \min _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\) The function supports the in-place mode. Erosion can be applied several ( iterations ) times. In case of multi-channel images, each channel is processed independently.
      Parameters:
      src - input image; the number of channels can be arbitrary, but the depth should be one of CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - output image of the same size and type as src.
      kernel - structuring element used for erosion; if element=Mat(), a 3 x 3 rectangular structuring element is used. Kernel can be created using #getStructuringElement.
      anchor - position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center.
      iterations - number of times erosion is applied.
      borderType - pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. SEE: dilate, morphologyEx, getStructuringElement
    • erode

      public static void erode​(Mat src, Mat dst, Mat kernel, Point anchor, int iterations)
      Erodes an image by using a specific structuring element. The function erodes the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the minimum is taken: \(\texttt{dst} (x,y) = \min _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\) The function supports the in-place mode. Erosion can be applied several ( iterations ) times. In case of multi-channel images, each channel is processed independently.
      Parameters:
      src - input image; the number of channels can be arbitrary, but the depth should be one of CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - output image of the same size and type as src.
      kernel - structuring element used for erosion; if element=Mat(), a 3 x 3 rectangular structuring element is used. Kernel can be created using #getStructuringElement.
      anchor - position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center.
      iterations - number of times erosion is applied. SEE: dilate, morphologyEx, getStructuringElement
    • erode

      public static void erode​(Mat src, Mat dst, Mat kernel, Point anchor)
      Erodes an image by using a specific structuring element. The function erodes the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the minimum is taken: \(\texttt{dst} (x,y) = \min _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\) The function supports the in-place mode. Erosion can be applied several ( iterations ) times. In case of multi-channel images, each channel is processed independently.
      Parameters:
      src - input image; the number of channels can be arbitrary, but the depth should be one of CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - output image of the same size and type as src.
      kernel - structuring element used for erosion; if element=Mat(), a 3 x 3 rectangular structuring element is used. Kernel can be created using #getStructuringElement.
      anchor - position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center. SEE: dilate, morphologyEx, getStructuringElement
    • erode

      public static void erode​(Mat src, Mat dst, Mat kernel)
      Erodes an image by using a specific structuring element. The function erodes the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the minimum is taken: \(\texttt{dst} (x,y) = \min _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\) The function supports the in-place mode. Erosion can be applied several ( iterations ) times. In case of multi-channel images, each channel is processed independently.
      Parameters:
      src - input image; the number of channels can be arbitrary, but the depth should be one of CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - output image of the same size and type as src.
      kernel - structuring element used for erosion; if element=Mat(), a 3 x 3 rectangular structuring element is used. Kernel can be created using #getStructuringElement. anchor is at the element center. SEE: dilate, morphologyEx, getStructuringElement
    • dilate

      public static void dilate​(Mat src, Mat dst, Mat kernel, Point anchor, int iterations, int borderType, Scalar borderValue)
      Dilates an image by using a specific structuring element. The function dilates the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the maximum is taken: \(\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\) The function supports the in-place mode. Dilation can be applied several ( iterations ) times. In case of multi-channel images, each channel is processed independently.
      Parameters:
      src - input image; the number of channels can be arbitrary, but the depth should be one of CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - output image of the same size and type as src.
      kernel - structuring element used for dilation; if elemenat=Mat(), a 3 x 3 rectangular structuring element is used. Kernel can be created using #getStructuringElement
      anchor - position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center.
      iterations - number of times dilation is applied.
      borderType - pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not suported.
      borderValue - border value in case of a constant border SEE: erode, morphologyEx, getStructuringElement
    • dilate

      public static void dilate​(Mat src, Mat dst, Mat kernel, Point anchor, int iterations, int borderType)
      Dilates an image by using a specific structuring element. The function dilates the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the maximum is taken: \(\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\) The function supports the in-place mode. Dilation can be applied several ( iterations ) times. In case of multi-channel images, each channel is processed independently.
      Parameters:
      src - input image; the number of channels can be arbitrary, but the depth should be one of CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - output image of the same size and type as src.
      kernel - structuring element used for dilation; if elemenat=Mat(), a 3 x 3 rectangular structuring element is used. Kernel can be created using #getStructuringElement
      anchor - position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center.
      iterations - number of times dilation is applied.
      borderType - pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not suported. SEE: erode, morphologyEx, getStructuringElement
    • dilate

      public static void dilate​(Mat src, Mat dst, Mat kernel, Point anchor, int iterations)
      Dilates an image by using a specific structuring element. The function dilates the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the maximum is taken: \(\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\) The function supports the in-place mode. Dilation can be applied several ( iterations ) times. In case of multi-channel images, each channel is processed independently.
      Parameters:
      src - input image; the number of channels can be arbitrary, but the depth should be one of CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - output image of the same size and type as src.
      kernel - structuring element used for dilation; if elemenat=Mat(), a 3 x 3 rectangular structuring element is used. Kernel can be created using #getStructuringElement
      anchor - position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center.
      iterations - number of times dilation is applied. SEE: erode, morphologyEx, getStructuringElement
    • dilate

      public static void dilate​(Mat src, Mat dst, Mat kernel, Point anchor)
      Dilates an image by using a specific structuring element. The function dilates the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the maximum is taken: \(\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\) The function supports the in-place mode. Dilation can be applied several ( iterations ) times. In case of multi-channel images, each channel is processed independently.
      Parameters:
      src - input image; the number of channels can be arbitrary, but the depth should be one of CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - output image of the same size and type as src.
      kernel - structuring element used for dilation; if elemenat=Mat(), a 3 x 3 rectangular structuring element is used. Kernel can be created using #getStructuringElement
      anchor - position of the anchor within the element; default value (-1, -1) means that the anchor is at the element center. SEE: erode, morphologyEx, getStructuringElement
    • dilate

      public static void dilate​(Mat src, Mat dst, Mat kernel)
      Dilates an image by using a specific structuring element. The function dilates the source image using the specified structuring element that determines the shape of a pixel neighborhood over which the maximum is taken: \(\texttt{dst} (x,y) = \max _{(x',y'): \, \texttt{element} (x',y') \ne0 } \texttt{src} (x+x',y+y')\) The function supports the in-place mode. Dilation can be applied several ( iterations ) times. In case of multi-channel images, each channel is processed independently.
      Parameters:
      src - input image; the number of channels can be arbitrary, but the depth should be one of CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - output image of the same size and type as src.
      kernel - structuring element used for dilation; if elemenat=Mat(), a 3 x 3 rectangular structuring element is used. Kernel can be created using #getStructuringElement anchor is at the element center. SEE: erode, morphologyEx, getStructuringElement
    • morphologyEx

      public static void morphologyEx​(Mat src, Mat dst, int op, Mat kernel, Point anchor, int iterations, int borderType, Scalar borderValue)
      Performs advanced morphological transformations. The function cv::morphologyEx can perform advanced morphological transformations using an erosion and dilation as basic operations. Any of the operations can be done in-place. In case of multi-channel images, each channel is processed independently.
      Parameters:
      src - Source image. The number of channels can be arbitrary. The depth should be one of CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - Destination image of the same size and type as source image.
      op - Type of a morphological operation, see #MorphTypes
      kernel - Structuring element. It can be created using #getStructuringElement.
      anchor - Anchor position with the kernel. Negative values mean that the anchor is at the kernel center.
      iterations - Number of times erosion and dilation are applied.
      borderType - Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported.
      borderValue - Border value in case of a constant border. The default value has a special meaning. SEE: dilate, erode, getStructuringElement Note: The number of iterations is the number of times erosion or dilatation operation will be applied. For instance, an opening operation (#MORPH_OPEN) with two iterations is equivalent to apply successively: erode -> erode -> dilate -> dilate (and not erode -> dilate -> erode -> dilate).
    • morphologyEx

      public static void morphologyEx​(Mat src, Mat dst, int op, Mat kernel, Point anchor, int iterations, int borderType)
      Performs advanced morphological transformations. The function cv::morphologyEx can perform advanced morphological transformations using an erosion and dilation as basic operations. Any of the operations can be done in-place. In case of multi-channel images, each channel is processed independently.
      Parameters:
      src - Source image. The number of channels can be arbitrary. The depth should be one of CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - Destination image of the same size and type as source image.
      op - Type of a morphological operation, see #MorphTypes
      kernel - Structuring element. It can be created using #getStructuringElement.
      anchor - Anchor position with the kernel. Negative values mean that the anchor is at the kernel center.
      iterations - Number of times erosion and dilation are applied.
      borderType - Pixel extrapolation method, see #BorderTypes. #BORDER_WRAP is not supported. meaning. SEE: dilate, erode, getStructuringElement Note: The number of iterations is the number of times erosion or dilatation operation will be applied. For instance, an opening operation (#MORPH_OPEN) with two iterations is equivalent to apply successively: erode -> erode -> dilate -> dilate (and not erode -> dilate -> erode -> dilate).
    • morphologyEx

      public static void morphologyEx​(Mat src, Mat dst, int op, Mat kernel, Point anchor, int iterations)
      Performs advanced morphological transformations. The function cv::morphologyEx can perform advanced morphological transformations using an erosion and dilation as basic operations. Any of the operations can be done in-place. In case of multi-channel images, each channel is processed independently.
      Parameters:
      src - Source image. The number of channels can be arbitrary. The depth should be one of CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - Destination image of the same size and type as source image.
      op - Type of a morphological operation, see #MorphTypes
      kernel - Structuring element. It can be created using #getStructuringElement.
      anchor - Anchor position with the kernel. Negative values mean that the anchor is at the kernel center.
      iterations - Number of times erosion and dilation are applied. meaning. SEE: dilate, erode, getStructuringElement Note: The number of iterations is the number of times erosion or dilatation operation will be applied. For instance, an opening operation (#MORPH_OPEN) with two iterations is equivalent to apply successively: erode -> erode -> dilate -> dilate (and not erode -> dilate -> erode -> dilate).
    • morphologyEx

      public static void morphologyEx​(Mat src, Mat dst, int op, Mat kernel, Point anchor)
      Performs advanced morphological transformations. The function cv::morphologyEx can perform advanced morphological transformations using an erosion and dilation as basic operations. Any of the operations can be done in-place. In case of multi-channel images, each channel is processed independently.
      Parameters:
      src - Source image. The number of channels can be arbitrary. The depth should be one of CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - Destination image of the same size and type as source image.
      op - Type of a morphological operation, see #MorphTypes
      kernel - Structuring element. It can be created using #getStructuringElement.
      anchor - Anchor position with the kernel. Negative values mean that the anchor is at the kernel center. meaning. SEE: dilate, erode, getStructuringElement Note: The number of iterations is the number of times erosion or dilatation operation will be applied. For instance, an opening operation (#MORPH_OPEN) with two iterations is equivalent to apply successively: erode -> erode -> dilate -> dilate (and not erode -> dilate -> erode -> dilate).
    • morphologyEx

      public static void morphologyEx​(Mat src, Mat dst, int op, Mat kernel)
      Performs advanced morphological transformations. The function cv::morphologyEx can perform advanced morphological transformations using an erosion and dilation as basic operations. Any of the operations can be done in-place. In case of multi-channel images, each channel is processed independently.
      Parameters:
      src - Source image. The number of channels can be arbitrary. The depth should be one of CV_8U, CV_16U, CV_16S, CV_32F or CV_64F.
      dst - Destination image of the same size and type as source image.
      op - Type of a morphological operation, see #MorphTypes
      kernel - Structuring element. It can be created using #getStructuringElement. kernel center. meaning. SEE: dilate, erode, getStructuringElement Note: The number of iterations is the number of times erosion or dilatation operation will be applied. For instance, an opening operation (#MORPH_OPEN) with two iterations is equivalent to apply successively: erode -> erode -> dilate -> dilate (and not erode -> dilate -> erode -> dilate).
    • resize

      public static void resize​(Mat src, Mat dst, Size dsize, double fx, double fy, int interpolation)
      Resizes an image. The function resize resizes the image src down to or up to the specified size. Note that the initial dst type or size are not taken into account. Instead, the size and type are derived from the src,dsize,fx, and fy. If you want to resize src so that it fits the pre-created dst, you may call the function as follows: // explicitly specify dsize=dst.size(); fx and fy will be computed from that. resize(src, dst, dst.size(), 0, 0, interpolation); If you want to decimate the image by factor of 2 in each direction, you can call the function this way: // specify fx and fy and let the function compute the destination image size. resize(src, dst, Size(), 0.5, 0.5, interpolation); To shrink an image, it will generally look best with #INTER_AREA interpolation, whereas to enlarge an image, it will generally look best with #INTER_CUBIC (slow) or #INTER_LINEAR (faster but still looks OK).
      Parameters:
      src - input image.
      dst - output image; it has the size dsize (when it is non-zero) or the size computed from src.size(), fx, and fy; the type of dst is the same as of src.
      dsize - output image size; if it equals zero (None in Python), it is computed as: \(\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}\) Either dsize or both fx and fy must be non-zero.
      fx - scale factor along the horizontal axis; when it equals 0, it is computed as \(\texttt{(double)dsize.width/src.cols}\)
      fy - scale factor along the vertical axis; when it equals 0, it is computed as \(\texttt{(double)dsize.height/src.rows}\)
      interpolation - interpolation method, see #InterpolationFlags SEE: warpAffine, warpPerspective, remap
    • resize

      public static void resize​(Mat src, Mat dst, Size dsize, double fx, double fy)
      Resizes an image. The function resize resizes the image src down to or up to the specified size. Note that the initial dst type or size are not taken into account. Instead, the size and type are derived from the src,dsize,fx, and fy. If you want to resize src so that it fits the pre-created dst, you may call the function as follows: // explicitly specify dsize=dst.size(); fx and fy will be computed from that. resize(src, dst, dst.size(), 0, 0, interpolation); If you want to decimate the image by factor of 2 in each direction, you can call the function this way: // specify fx and fy and let the function compute the destination image size. resize(src, dst, Size(), 0.5, 0.5, interpolation); To shrink an image, it will generally look best with #INTER_AREA interpolation, whereas to enlarge an image, it will generally look best with #INTER_CUBIC (slow) or #INTER_LINEAR (faster but still looks OK).
      Parameters:
      src - input image.
      dst - output image; it has the size dsize (when it is non-zero) or the size computed from src.size(), fx, and fy; the type of dst is the same as of src.
      dsize - output image size; if it equals zero (None in Python), it is computed as: \(\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}\) Either dsize or both fx and fy must be non-zero.
      fx - scale factor along the horizontal axis; when it equals 0, it is computed as \(\texttt{(double)dsize.width/src.cols}\)
      fy - scale factor along the vertical axis; when it equals 0, it is computed as \(\texttt{(double)dsize.height/src.rows}\) SEE: warpAffine, warpPerspective, remap
    • resize

      public static void resize​(Mat src, Mat dst, Size dsize, double fx)
      Resizes an image. The function resize resizes the image src down to or up to the specified size. Note that the initial dst type or size are not taken into account. Instead, the size and type are derived from the src,dsize,fx, and fy. If you want to resize src so that it fits the pre-created dst, you may call the function as follows: // explicitly specify dsize=dst.size(); fx and fy will be computed from that. resize(src, dst, dst.size(), 0, 0, interpolation); If you want to decimate the image by factor of 2 in each direction, you can call the function this way: // specify fx and fy and let the function compute the destination image size. resize(src, dst, Size(), 0.5, 0.5, interpolation); To shrink an image, it will generally look best with #INTER_AREA interpolation, whereas to enlarge an image, it will generally look best with #INTER_CUBIC (slow) or #INTER_LINEAR (faster but still looks OK).
      Parameters:
      src - input image.
      dst - output image; it has the size dsize (when it is non-zero) or the size computed from src.size(), fx, and fy; the type of dst is the same as of src.
      dsize - output image size; if it equals zero (None in Python), it is computed as: \(\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}\) Either dsize or both fx and fy must be non-zero.
      fx - scale factor along the horizontal axis; when it equals 0, it is computed as \(\texttt{(double)dsize.width/src.cols}\) \(\texttt{(double)dsize.height/src.rows}\) SEE: warpAffine, warpPerspective, remap
    • resize

      public static void resize​(Mat src, Mat dst, Size dsize)
      Resizes an image. The function resize resizes the image src down to or up to the specified size. Note that the initial dst type or size are not taken into account. Instead, the size and type are derived from the src,dsize,fx, and fy. If you want to resize src so that it fits the pre-created dst, you may call the function as follows: // explicitly specify dsize=dst.size(); fx and fy will be computed from that. resize(src, dst, dst.size(), 0, 0, interpolation); If you want to decimate the image by factor of 2 in each direction, you can call the function this way: // specify fx and fy and let the function compute the destination image size. resize(src, dst, Size(), 0.5, 0.5, interpolation); To shrink an image, it will generally look best with #INTER_AREA interpolation, whereas to enlarge an image, it will generally look best with #INTER_CUBIC (slow) or #INTER_LINEAR (faster but still looks OK).
      Parameters:
      src - input image.
      dst - output image; it has the size dsize (when it is non-zero) or the size computed from src.size(), fx, and fy; the type of dst is the same as of src.
      dsize - output image size; if it equals zero (None in Python), it is computed as: \(\texttt{dsize = Size(round(fx*src.cols), round(fy*src.rows))}\) Either dsize or both fx and fy must be non-zero. \(\texttt{(double)dsize.width/src.cols}\) \(\texttt{(double)dsize.height/src.rows}\) SEE: warpAffine, warpPerspective, remap
    • warpAffine

      public static void warpAffine​(Mat src, Mat dst, Mat M, Size dsize, int flags, int borderMode, Scalar borderValue)
      Applies an affine transformation to an image. The function warpAffine transforms the source image using the specified matrix: \(\texttt{dst} (x,y) = \texttt{src} ( \texttt{M} _{11} x + \texttt{M} _{12} y + \texttt{M} _{13}, \texttt{M} _{21} x + \texttt{M} _{22} y + \texttt{M} _{23})\) when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with #invertAffineTransform and then put in the formula above instead of M. The function cannot operate in-place.
      Parameters:
      src - input image.
      dst - output image that has the size dsize and the same type as src .
      M - \(2\times 3\) transformation matrix.
      dsize - size of the output image.
      flags - combination of interpolation methods (see #InterpolationFlags) and the optional flag #WARP_INVERSE_MAP that means that M is the inverse transformation ( \(\texttt{dst}\rightarrow\texttt{src}\) ).
      borderMode - pixel extrapolation method (see #BorderTypes); when borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image corresponding to the "outliers" in the source image are not modified by the function.
      borderValue - value used in case of a constant border; by default, it is 0. SEE: warpPerspective, resize, remap, getRectSubPix, transform
    • warpAffine

      public static void warpAffine​(Mat src, Mat dst, Mat M, Size dsize, int flags, int borderMode)
      Applies an affine transformation to an image. The function warpAffine transforms the source image using the specified matrix: \(\texttt{dst} (x,y) = \texttt{src} ( \texttt{M} _{11} x + \texttt{M} _{12} y + \texttt{M} _{13}, \texttt{M} _{21} x + \texttt{M} _{22} y + \texttt{M} _{23})\) when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with #invertAffineTransform and then put in the formula above instead of M. The function cannot operate in-place.
      Parameters:
      src - input image.
      dst - output image that has the size dsize and the same type as src .
      M - \(2\times 3\) transformation matrix.
      dsize - size of the output image.
      flags - combination of interpolation methods (see #InterpolationFlags) and the optional flag #WARP_INVERSE_MAP that means that M is the inverse transformation ( \(\texttt{dst}\rightarrow\texttt{src}\) ).
      borderMode - pixel extrapolation method (see #BorderTypes); when borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image corresponding to the "outliers" in the source image are not modified by the function. SEE: warpPerspective, resize, remap, getRectSubPix, transform
    • warpAffine

      public static void warpAffine​(Mat src, Mat dst, Mat M, Size dsize, int flags)
      Applies an affine transformation to an image. The function warpAffine transforms the source image using the specified matrix: \(\texttt{dst} (x,y) = \texttt{src} ( \texttt{M} _{11} x + \texttt{M} _{12} y + \texttt{M} _{13}, \texttt{M} _{21} x + \texttt{M} _{22} y + \texttt{M} _{23})\) when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with #invertAffineTransform and then put in the formula above instead of M. The function cannot operate in-place.
      Parameters:
      src - input image.
      dst - output image that has the size dsize and the same type as src .
      M - \(2\times 3\) transformation matrix.
      dsize - size of the output image.
      flags - combination of interpolation methods (see #InterpolationFlags) and the optional flag #WARP_INVERSE_MAP that means that M is the inverse transformation ( \(\texttt{dst}\rightarrow\texttt{src}\) ). borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image corresponding to the "outliers" in the source image are not modified by the function. SEE: warpPerspective, resize, remap, getRectSubPix, transform
    • warpAffine

      public static void warpAffine​(Mat src, Mat dst, Mat M, Size dsize)
      Applies an affine transformation to an image. The function warpAffine transforms the source image using the specified matrix: \(\texttt{dst} (x,y) = \texttt{src} ( \texttt{M} _{11} x + \texttt{M} _{12} y + \texttt{M} _{13}, \texttt{M} _{21} x + \texttt{M} _{22} y + \texttt{M} _{23})\) when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with #invertAffineTransform and then put in the formula above instead of M. The function cannot operate in-place.
      Parameters:
      src - input image.
      dst - output image that has the size dsize and the same type as src .
      M - \(2\times 3\) transformation matrix.
      dsize - size of the output image. flag #WARP_INVERSE_MAP that means that M is the inverse transformation ( \(\texttt{dst}\rightarrow\texttt{src}\) ). borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image corresponding to the "outliers" in the source image are not modified by the function. SEE: warpPerspective, resize, remap, getRectSubPix, transform
    • warpPerspective

      public static void warpPerspective​(Mat src, Mat dst, Mat M, Size dsize, int flags, int borderMode, Scalar borderValue)
      Applies a perspective transformation to an image. The function warpPerspective transforms the source image using the specified matrix: \(\texttt{dst} (x,y) = \texttt{src} \left ( \frac{M_{11} x + M_{12} y + M_{13}}{M_{31} x + M_{32} y + M_{33}} , \frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} \right )\) when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invert and then put in the formula above instead of M. The function cannot operate in-place.
      Parameters:
      src - input image.
      dst - output image that has the size dsize and the same type as src .
      M - \(3\times 3\) transformation matrix.
      dsize - size of the output image.
      flags - combination of interpolation methods (#INTER_LINEAR or #INTER_NEAREST) and the optional flag #WARP_INVERSE_MAP, that sets M as the inverse transformation ( \(\texttt{dst}\rightarrow\texttt{src}\) ).
      borderMode - pixel extrapolation method (#BORDER_CONSTANT or #BORDER_REPLICATE).
      borderValue - value used in case of a constant border; by default, it equals 0. SEE: warpAffine, resize, remap, getRectSubPix, perspectiveTransform
    • warpPerspective

      public static void warpPerspective​(Mat src, Mat dst, Mat M, Size dsize, int flags, int borderMode)
      Applies a perspective transformation to an image. The function warpPerspective transforms the source image using the specified matrix: \(\texttt{dst} (x,y) = \texttt{src} \left ( \frac{M_{11} x + M_{12} y + M_{13}}{M_{31} x + M_{32} y + M_{33}} , \frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} \right )\) when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invert and then put in the formula above instead of M. The function cannot operate in-place.
      Parameters:
      src - input image.
      dst - output image that has the size dsize and the same type as src .
      M - \(3\times 3\) transformation matrix.
      dsize - size of the output image.
      flags - combination of interpolation methods (#INTER_LINEAR or #INTER_NEAREST) and the optional flag #WARP_INVERSE_MAP, that sets M as the inverse transformation ( \(\texttt{dst}\rightarrow\texttt{src}\) ).
      borderMode - pixel extrapolation method (#BORDER_CONSTANT or #BORDER_REPLICATE). SEE: warpAffine, resize, remap, getRectSubPix, perspectiveTransform
    • warpPerspective

      public static void warpPerspective​(Mat src, Mat dst, Mat M, Size dsize, int flags)
      Applies a perspective transformation to an image. The function warpPerspective transforms the source image using the specified matrix: \(\texttt{dst} (x,y) = \texttt{src} \left ( \frac{M_{11} x + M_{12} y + M_{13}}{M_{31} x + M_{32} y + M_{33}} , \frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} \right )\) when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invert and then put in the formula above instead of M. The function cannot operate in-place.
      Parameters:
      src - input image.
      dst - output image that has the size dsize and the same type as src .
      M - \(3\times 3\) transformation matrix.
      dsize - size of the output image.
      flags - combination of interpolation methods (#INTER_LINEAR or #INTER_NEAREST) and the optional flag #WARP_INVERSE_MAP, that sets M as the inverse transformation ( \(\texttt{dst}\rightarrow\texttt{src}\) ). SEE: warpAffine, resize, remap, getRectSubPix, perspectiveTransform
    • warpPerspective

      public static void warpPerspective​(Mat src, Mat dst, Mat M, Size dsize)
      Applies a perspective transformation to an image. The function warpPerspective transforms the source image using the specified matrix: \(\texttt{dst} (x,y) = \texttt{src} \left ( \frac{M_{11} x + M_{12} y + M_{13}}{M_{31} x + M_{32} y + M_{33}} , \frac{M_{21} x + M_{22} y + M_{23}}{M_{31} x + M_{32} y + M_{33}} \right )\) when the flag #WARP_INVERSE_MAP is set. Otherwise, the transformation is first inverted with invert and then put in the formula above instead of M. The function cannot operate in-place.
      Parameters:
      src - input image.
      dst - output image that has the size dsize and the same type as src .
      M - \(3\times 3\) transformation matrix.
      dsize - size of the output image. optional flag #WARP_INVERSE_MAP, that sets M as the inverse transformation ( \(\texttt{dst}\rightarrow\texttt{src}\) ). SEE: warpAffine, resize, remap, getRectSubPix, perspectiveTransform
    • remap

      public static void remap​(Mat src, Mat dst, Mat map1, Mat map2, int interpolation, int borderMode, Scalar borderValue)
      Applies a generic geometrical transformation to an image. The function remap transforms the source image using the specified map: \(\texttt{dst} (x,y) = \texttt{src} (map_x(x,y),map_y(x,y))\) where values of pixels with non-integer coordinates are computed using one of available interpolation methods. \(map_x\) and \(map_y\) can be encoded as separate floating-point maps in \(map_1\) and \(map_2\) respectively, or interleaved floating-point maps of \((x,y)\) in \(map_1\), or fixed-point maps created by using #convertMaps. The reason you might want to convert from floating to fixed-point representations of a map is that they can yield much faster (\~2x) remapping operations. In the converted case, \(map_1\) contains pairs (cvFloor(x), cvFloor(y)) and \(map_2\) contains indices in a table of interpolation coefficients. This function cannot operate in-place.
      Parameters:
      src - Source image.
      dst - Destination image. It has the same size as map1 and the same type as src .
      map1 - The first map of either (x,y) points or just x values having the type CV_16SC2 , CV_32FC1, or CV_32FC2. See #convertMaps for details on converting a floating point representation to fixed-point for speed.
      map2 - The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map if map1 is (x,y) points), respectively.
      interpolation - Interpolation method (see #InterpolationFlags). The methods #INTER_AREA and #INTER_LINEAR_EXACT are not supported by this function.
      borderMode - Pixel extrapolation method (see #BorderTypes). When borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image that corresponds to the "outliers" in the source image are not modified by the function.
      borderValue - Value used in case of a constant border. By default, it is 0. Note: Due to current implementation limitations the size of an input and output images should be less than 32767x32767.
    • remap

      public static void remap​(Mat src, Mat dst, Mat map1, Mat map2, int interpolation, int borderMode)
      Applies a generic geometrical transformation to an image. The function remap transforms the source image using the specified map: \(\texttt{dst} (x,y) = \texttt{src} (map_x(x,y),map_y(x,y))\) where values of pixels with non-integer coordinates are computed using one of available interpolation methods. \(map_x\) and \(map_y\) can be encoded as separate floating-point maps in \(map_1\) and \(map_2\) respectively, or interleaved floating-point maps of \((x,y)\) in \(map_1\), or fixed-point maps created by using #convertMaps. The reason you might want to convert from floating to fixed-point representations of a map is that they can yield much faster (\~2x) remapping operations. In the converted case, \(map_1\) contains pairs (cvFloor(x), cvFloor(y)) and \(map_2\) contains indices in a table of interpolation coefficients. This function cannot operate in-place.
      Parameters:
      src - Source image.
      dst - Destination image. It has the same size as map1 and the same type as src .
      map1 - The first map of either (x,y) points or just x values having the type CV_16SC2 , CV_32FC1, or CV_32FC2. See #convertMaps for details on converting a floating point representation to fixed-point for speed.
      map2 - The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map if map1 is (x,y) points), respectively.
      interpolation - Interpolation method (see #InterpolationFlags). The methods #INTER_AREA and #INTER_LINEAR_EXACT are not supported by this function.
      borderMode - Pixel extrapolation method (see #BorderTypes). When borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image that corresponds to the "outliers" in the source image are not modified by the function. Note: Due to current implementation limitations the size of an input and output images should be less than 32767x32767.
    • remap

      public static void remap​(Mat src, Mat dst, Mat map1, Mat map2, int interpolation)
      Applies a generic geometrical transformation to an image. The function remap transforms the source image using the specified map: \(\texttt{dst} (x,y) = \texttt{src} (map_x(x,y),map_y(x,y))\) where values of pixels with non-integer coordinates are computed using one of available interpolation methods. \(map_x\) and \(map_y\) can be encoded as separate floating-point maps in \(map_1\) and \(map_2\) respectively, or interleaved floating-point maps of \((x,y)\) in \(map_1\), or fixed-point maps created by using #convertMaps. The reason you might want to convert from floating to fixed-point representations of a map is that they can yield much faster (\~2x) remapping operations. In the converted case, \(map_1\) contains pairs (cvFloor(x), cvFloor(y)) and \(map_2\) contains indices in a table of interpolation coefficients. This function cannot operate in-place.
      Parameters:
      src - Source image.
      dst - Destination image. It has the same size as map1 and the same type as src .
      map1 - The first map of either (x,y) points or just x values having the type CV_16SC2 , CV_32FC1, or CV_32FC2. See #convertMaps for details on converting a floating point representation to fixed-point for speed.
      map2 - The second map of y values having the type CV_16UC1, CV_32FC1, or none (empty map if map1 is (x,y) points), respectively.
      interpolation - Interpolation method (see #InterpolationFlags). The methods #INTER_AREA and #INTER_LINEAR_EXACT are not supported by this function. borderMode=#BORDER_TRANSPARENT, it means that the pixels in the destination image that corresponds to the "outliers" in the source image are not modified by the function. Note: Due to current implementation limitations the size of an input and output images should be less than 32767x32767.
    • convertMaps

      public static void convertMaps​(Mat map1, Mat map2, Mat dstmap1, Mat dstmap2, int dstmap1type, boolean nninterpolation)
      Converts image transformation maps from one representation to another. The function converts a pair of maps for remap from one representation to another. The following options ( (map1.type(), map2.type()) \(\rightarrow\) (dstmap1.type(), dstmap2.type()) ) are supported:
      • \(\texttt{(CV_32FC1, CV_32FC1)} \rightarrow \texttt{(CV_16SC2, CV_16UC1)}\). This is the most frequently used conversion operation, in which the original floating-point maps (see #remap) are converted to a more compact and much faster fixed-point representation. The first output array contains the rounded coordinates and the second array (created only when nninterpolation=false ) contains indices in the interpolation tables.
      • \(\texttt{(CV_32FC2)} \rightarrow \texttt{(CV_16SC2, CV_16UC1)}\). The same as above but the original maps are stored in one 2-channel matrix.
      • Reverse conversion. Obviously, the reconstructed floating-point maps will not be exactly the same as the originals.
      Parameters:
      map1 - The first input map of type CV_16SC2, CV_32FC1, or CV_32FC2 .
      map2 - The second input map of type CV_16UC1, CV_32FC1, or none (empty matrix), respectively.
      dstmap1 - The first output map that has the type dstmap1type and the same size as src .
      dstmap2 - The second output map.
      dstmap1type - Type of the first output map that should be CV_16SC2, CV_32FC1, or CV_32FC2 .
      nninterpolation - Flag indicating whether the fixed-point maps are used for the nearest-neighbor or for a more complex interpolation. SEE: remap, undistort, initUndistortRectifyMap
    • convertMaps

      public static void convertMaps​(Mat map1, Mat map2, Mat dstmap1, Mat dstmap2, int dstmap1type)
      Converts image transformation maps from one representation to another. The function converts a pair of maps for remap from one representation to another. The following options ( (map1.type(), map2.type()) \(\rightarrow\) (dstmap1.type(), dstmap2.type()) ) are supported:
      • \(\texttt{(CV_32FC1, CV_32FC1)} \rightarrow \texttt{(CV_16SC2, CV_16UC1)}\). This is the most frequently used conversion operation, in which the original floating-point maps (see #remap) are converted to a more compact and much faster fixed-point representation. The first output array contains the rounded coordinates and the second array (created only when nninterpolation=false ) contains indices in the interpolation tables.
      • \(\texttt{(CV_32FC2)} \rightarrow \texttt{(CV_16SC2, CV_16UC1)}\). The same as above but the original maps are stored in one 2-channel matrix.
      • Reverse conversion. Obviously, the reconstructed floating-point maps will not be exactly the same as the originals.
      Parameters:
      map1 - The first input map of type CV_16SC2, CV_32FC1, or CV_32FC2 .
      map2 - The second input map of type CV_16UC1, CV_32FC1, or none (empty matrix), respectively.
      dstmap1 - The first output map that has the type dstmap1type and the same size as src .
      dstmap2 - The second output map.
      dstmap1type - Type of the first output map that should be CV_16SC2, CV_32FC1, or CV_32FC2 . nearest-neighbor or for a more complex interpolation. SEE: remap, undistort, initUndistortRectifyMap
    • getRotationMatrix2D

      public static Mat getRotationMatrix2D​(Point center, double angle, double scale)
      Calculates an affine matrix of 2D rotation. The function calculates the following matrix: \(\begin{bmatrix} \alpha & \beta & (1- \alpha ) \cdot \texttt{center.x} - \beta \cdot \texttt{center.y} \\ - \beta & \alpha & \beta \cdot \texttt{center.x} + (1- \alpha ) \cdot \texttt{center.y} \end{bmatrix}\) where \(\begin{array}{l} \alpha = \texttt{scale} \cdot \cos \texttt{angle} , \\ \beta = \texttt{scale} \cdot \sin \texttt{angle} \end{array}\) The transformation maps the rotation center to itself. If this is not the target, adjust the shift.
      Parameters:
      center - Center of the rotation in the source image.
      angle - Rotation angle in degrees. Positive values mean counter-clockwise rotation (the coordinate origin is assumed to be the top-left corner).
      scale - Isotropic scale factor. SEE: getAffineTransform, warpAffine, transform
      Returns:
      automatically generated
    • invertAffineTransform

      public static void invertAffineTransform​(Mat M, Mat iM)
      Inverts an affine transformation. The function computes an inverse affine transformation represented by \(2 \times 3\) matrix M: \(\begin{bmatrix} a_{11} & a_{12} & b_1 \\ a_{21} & a_{22} & b_2 \end{bmatrix}\) The result is also a \(2 \times 3\) matrix of the same type as M.
      Parameters:
      M - Original affine transformation.
      iM - Output reverse affine transformation.
    • getPerspectiveTransform

      public static Mat getPerspectiveTransform​(Mat src, Mat dst, int solveMethod)
      Calculates a perspective transform from four pairs of the corresponding points. The function calculates the \(3 \times 3\) matrix of a perspective transform so that: \(\begin{bmatrix} t_i x'_i \\ t_i y'_i \\ t_i \end{bmatrix} = \texttt{map_matrix} \cdot \begin{bmatrix} x_i \\ y_i \\ 1 \end{bmatrix}\) where \(dst(i)=(x'_i,y'_i), src(i)=(x_i, y_i), i=0,1,2,3\)
      Parameters:
      src - Coordinates of quadrangle vertices in the source image.
      dst - Coordinates of the corresponding quadrangle vertices in the destination image.
      solveMethod - method passed to cv::solve (#DecompTypes) SEE: findHomography, warpPerspective, perspectiveTransform
      Returns:
      automatically generated
    • getPerspectiveTransform

      public static Mat getPerspectiveTransform​(Mat src, Mat dst)
      Calculates a perspective transform from four pairs of the corresponding points. The function calculates the \(3 \times 3\) matrix of a perspective transform so that: \(\begin{bmatrix} t_i x'_i \\ t_i y'_i \\ t_i \end{bmatrix} = \texttt{map_matrix} \cdot \begin{bmatrix} x_i \\ y_i \\ 1 \end{bmatrix}\) where \(dst(i)=(x'_i,y'_i), src(i)=(x_i, y_i), i=0,1,2,3\)
      Parameters:
      src - Coordinates of quadrangle vertices in the source image.
      dst - Coordinates of the corresponding quadrangle vertices in the destination image. SEE: findHomography, warpPerspective, perspectiveTransform
      Returns:
      automatically generated
    • getAffineTransform

      public static Mat getAffineTransform​(MatOfPoint2f src, MatOfPoint2f dst)
    • getRectSubPix

      public static void getRectSubPix​(Mat image, Size patchSize, Point center, Mat patch, int patchType)
      Retrieves a pixel rectangle from an image with sub-pixel accuracy. The function getRectSubPix extracts pixels from src: \(patch(x, y) = src(x + \texttt{center.x} - ( \texttt{dst.cols} -1)*0.5, y + \texttt{center.y} - ( \texttt{dst.rows} -1)*0.5)\) where the values of the pixels at non-integer coordinates are retrieved using bilinear interpolation. Every channel of multi-channel images is processed independently. Also the image should be a single channel or three channel image. While the center of the rectangle must be inside the image, parts of the rectangle may be outside.
      Parameters:
      image - Source image.
      patchSize - Size of the extracted patch.
      center - Floating point coordinates of the center of the extracted rectangle within the source image. The center must be inside the image.
      patch - Extracted patch that has the size patchSize and the same number of channels as src .
      patchType - Depth of the extracted pixels. By default, they have the same depth as src . SEE: warpAffine, warpPerspective
    • getRectSubPix

      public static void getRectSubPix​(Mat image, Size patchSize, Point center, Mat patch)
      Retrieves a pixel rectangle from an image with sub-pixel accuracy. The function getRectSubPix extracts pixels from src: \(patch(x, y) = src(x + \texttt{center.x} - ( \texttt{dst.cols} -1)*0.5, y + \texttt{center.y} - ( \texttt{dst.rows} -1)*0.5)\) where the values of the pixels at non-integer coordinates are retrieved using bilinear interpolation. Every channel of multi-channel images is processed independently. Also the image should be a single channel or three channel image. While the center of the rectangle must be inside the image, parts of the rectangle may be outside.
      Parameters:
      image - Source image.
      patchSize - Size of the extracted patch.
      center - Floating point coordinates of the center of the extracted rectangle within the source image. The center must be inside the image.
      patch - Extracted patch that has the size patchSize and the same number of channels as src . SEE: warpAffine, warpPerspective
    • logPolar

      @Deprecated public static void logPolar​(Mat src, Mat dst, Point center, double M, int flags)
      Deprecated.
      This function produces same result as cv::warpPolar(src, dst, src.size(), center, maxRadius, flags+WARP_POLAR_LOG); Transform the source image using the following transformation (See REF: polar_remaps_reference_image "Polar remaps reference image d)"): \(\begin{array}{l} dst( \rho , \phi ) = src(x,y) \\ dst.size() \leftarrow src.size() \end{array}\) where \(\begin{array}{l} I = (dx,dy) = (x - center.x,y - center.y) \\ \rho = M \cdot log_e(\texttt{magnitude} (I)) ,\\ \phi = Kangle \cdot \texttt{angle} (I) \\ \end{array}\) and \(\begin{array}{l} M = src.cols / log_e(maxRadius) \\ Kangle = src.rows / 2\Pi \\ \end{array}\) The function emulates the human "foveal" vision and can be used for fast scale and rotation-invariant template matching, for object tracking and so forth.
      Remaps an image to semilog-polar coordinates space.
      Parameters:
      src - Source image
      dst - Destination image. It will have same size and type as src.
      center - The transformation center; where the output precision is maximal
      M - Magnitude scale parameter. It determines the radius of the bounding circle to transform too.
      flags - A combination of interpolation methods, see #InterpolationFlags Note:
      • The function can not operate in-place.
      • To calculate magnitude and angle in degrees #cartToPolar is used internally thus angles are measured from 0 to 360 with accuracy about 0.3 degrees.
      SEE: cv::linearPolar
    • linearPolar

      @Deprecated public static void linearPolar​(Mat src, Mat dst, Point center, double maxRadius, int flags)
      Deprecated.
      This function produces same result as cv::warpPolar(src, dst, src.size(), center, maxRadius, flags) Transform the source image using the following transformation (See REF: polar_remaps_reference_image "Polar remaps reference image c)"): \(\begin{array}{l} dst( \rho , \phi ) = src(x,y) \\ dst.size() \leftarrow src.size() \end{array}\) where \(\begin{array}{l} I = (dx,dy) = (x - center.x,y - center.y) \\ \rho = Kmag \cdot \texttt{magnitude} (I) ,\\ \phi = angle \cdot \texttt{angle} (I) \end{array}\) and \(\begin{array}{l} Kx = src.cols / maxRadius \\ Ky = src.rows / 2\Pi \end{array}\)
      Remaps an image to polar coordinates space.
      Parameters:
      src - Source image
      dst - Destination image. It will have same size and type as src.
      center - The transformation center;
      maxRadius - The radius of the bounding circle to transform. It determines the inverse magnitude scale parameter too.
      flags - A combination of interpolation methods, see #InterpolationFlags Note:
      • The function can not operate in-place.
      • To calculate magnitude and angle in degrees #cartToPolar is used internally thus angles are measured from 0 to 360 with accuracy about 0.3 degrees.
      SEE: cv::logPolar
    • warpPolar

      public static void warpPolar​(Mat src, Mat dst, Size dsize, Point center, double maxRadius, int flags)
      Remaps an image to polar or semilog-polar coordinates space polar_remaps_reference_image ![Polar remaps reference](pics/polar_remap_doc.png) Transform the source image using the following transformation: \( dst(\rho , \phi ) = src(x,y) \) where \( \begin{array}{l} \vec{I} = (x - center.x, \;y - center.y) \\ \phi = Kangle \cdot \texttt{angle} (\vec{I}) \\ \rho = \left\{\begin{matrix} Klin \cdot \texttt{magnitude} (\vec{I}) & default \\ Klog \cdot log_e(\texttt{magnitude} (\vec{I})) & if \; semilog \\ \end{matrix}\right. \end{array} \) and \( \begin{array}{l} Kangle = dsize.height / 2\Pi \\ Klin = dsize.width / maxRadius \\ Klog = dsize.width / log_e(maxRadius) \\ \end{array} \) \par Linear vs semilog mapping Polar mapping can be linear or semi-log. Add one of #WarpPolarMode to flags to specify the polar mapping mode. Linear is the default mode. The semilog mapping emulates the human "foveal" vision that permit very high acuity on the line of sight (central vision) in contrast to peripheral vision where acuity is minor. \par Option on dsize:
      • if both values in dsize &lt;=0 (default), the destination image will have (almost) same area of source bounding circle: \(\begin{array}{l} dsize.area \leftarrow (maxRadius^2 \cdot \Pi) \\ dsize.width = \texttt{cvRound}(maxRadius) \\ dsize.height = \texttt{cvRound}(maxRadius \cdot \Pi) \\ \end{array}\)
      • if only dsize.height &lt;= 0, the destination image area will be proportional to the bounding circle area but scaled by Kx * Kx: \(\begin{array}{l} dsize.height = \texttt{cvRound}(dsize.width \cdot \Pi) \\ \end{array} \)
      • if both values in dsize &gt; 0 , the destination image will have the given size therefore the area of the bounding circle will be scaled to dsize.
      \par Reverse mapping You can get reverse mapping adding #WARP_INVERSE_MAP to flags \snippet polar_transforms.cpp InverseMap In addiction, to calculate the original coordinate from a polar mapped coordinate \((rho, phi)->(x, y)\): \snippet polar_transforms.cpp InverseCoordinate
      Parameters:
      src - Source image.
      dst - Destination image. It will have same type as src.
      dsize - The destination image size (see description for valid options).
      center - The transformation center.
      maxRadius - The radius of the bounding circle to transform. It determines the inverse magnitude scale parameter too.
      flags - A combination of interpolation methods, #InterpolationFlags + #WarpPolarMode.
      • Add #WARP_POLAR_LINEAR to select linear polar mapping (default)
      • Add #WARP_POLAR_LOG to select semilog polar mapping
      • Add #WARP_INVERSE_MAP for reverse mapping.
      Note:
      • The function can not operate in-place.
      • To calculate magnitude and angle in degrees #cartToPolar is used internally thus angles are measured from 0 to 360 with accuracy about 0.3 degrees.
      • This function uses #remap. Due to current implementation limitations the size of an input and output images should be less than 32767x32767.
      SEE: cv::remap
    • integral3

      public static void integral3​(Mat src, Mat sum, Mat sqsum, Mat tilted, int sdepth, int sqdepth)
      Calculates the integral of an image. The function calculates one or more integral images for the source image as follows: \(\texttt{sum} (X,Y) = \sum _{x<X,y<Y} \texttt{image} (x,y)\) \(\texttt{sqsum} (X,Y) = \sum _{x<X,y<Y} \texttt{image} (x,y)^2\) \(\texttt{tilted} (X,Y) = \sum _{y<Y,abs(x-X+1) \leq Y-y-1} \texttt{image} (x,y)\) Using these integral images, you can calculate sum, mean, and standard deviation over a specific up-right or rotated rectangular region of the image in a constant time, for example: \(\sum _{x_1 \leq x < x_2, \, y_1 \leq y < y_2} \texttt{image} (x,y) = \texttt{sum} (x_2,y_2)- \texttt{sum} (x_1,y_2)- \texttt{sum} (x_2,y_1)+ \texttt{sum} (x_1,y_1)\) It makes possible to do a fast blurring or fast block correlation with a variable window size, for example. In case of multi-channel images, sums for each channel are accumulated independently. As a practical example, the next figure shows the calculation of the integral of a straight rectangle Rect(3,3,3,2) and of a tilted rectangle Rect(5,1,2,3) . The selected pixels in the original image are shown, as well as the relative pixels in the integral images sum and tilted . ![integral calculation example](pics/integral.png)
      Parameters:
      src - input image as \(W \times H\), 8-bit or floating-point (32f or 64f).
      sum - integral image as \((W+1)\times (H+1)\) , 32-bit integer or floating-point (32f or 64f).
      sqsum - integral image for squared pixel values; it is \((W+1)\times (H+1)\), double-precision floating-point (64f) array.
      tilted - integral for the image rotated by 45 degrees; it is \((W+1)\times (H+1)\) array with the same data type as sum.
      sdepth - desired depth of the integral and the tilted integral images, CV_32S, CV_32F, or CV_64F.
      sqdepth - desired depth of the integral image of squared pixel values, CV_32F or CV_64F.
    • integral3

      public static void integral3​(Mat src, Mat sum, Mat sqsum, Mat tilted, int sdepth)
      Calculates the integral of an image. The function calculates one or more integral images for the source image as follows: \(\texttt{sum} (X,Y) = \sum _{x<X,y<Y} \texttt{image} (x,y)\) \(\texttt{sqsum} (X,Y) = \sum _{x<X,y<Y} \texttt{image} (x,y)^2\) \(\texttt{tilted} (X,Y) = \sum _{y<Y,abs(x-X+1) \leq Y-y-1} \texttt{image} (x,y)\) Using these integral images, you can calculate sum, mean, and standard deviation over a specific up-right or rotated rectangular region of the image in a constant time, for example: \(\sum _{x_1 \leq x < x_2, \, y_1 \leq y < y_2} \texttt{image} (x,y) = \texttt{sum} (x_2,y_2)- \texttt{sum} (x_1,y_2)- \texttt{sum} (x_2,y_1)+ \texttt{sum} (x_1,y_1)\) It makes possible to do a fast blurring or fast block correlation with a variable window size, for example. In case of multi-channel images, sums for each channel are accumulated independently. As a practical example, the next figure shows the calculation of the integral of a straight rectangle Rect(3,3,3,2) and of a tilted rectangle Rect(5,1,2,3) . The selected pixels in the original image are shown, as well as the relative pixels in the integral images sum and tilted . ![integral calculation example](pics/integral.png)
      Parameters:
      src - input image as \(W \times H\), 8-bit or floating-point (32f or 64f).
      sum - integral image as \((W+1)\times (H+1)\) , 32-bit integer or floating-point (32f or 64f).
      sqsum - integral image for squared pixel values; it is \((W+1)\times (H+1)\), double-precision floating-point (64f) array.
      tilted - integral for the image rotated by 45 degrees; it is \((W+1)\times (H+1)\) array with the same data type as sum.
      sdepth - desired depth of the integral and the tilted integral images, CV_32S, CV_32F, or CV_64F.
    • integral3

      public static void integral3​(Mat src, Mat sum, Mat sqsum, Mat tilted)
      Calculates the integral of an image. The function calculates one or more integral images for the source image as follows: \(\texttt{sum} (X,Y) = \sum _{x<X,y<Y} \texttt{image} (x,y)\) \(\texttt{sqsum} (X,Y) = \sum _{x<X,y<Y} \texttt{image} (x,y)^2\) \(\texttt{tilted} (X,Y) = \sum _{y<Y,abs(x-X+1) \leq Y-y-1} \texttt{image} (x,y)\) Using these integral images, you can calculate sum, mean, and standard deviation over a specific up-right or rotated rectangular region of the image in a constant time, for example: \(\sum _{x_1 \leq x < x_2, \, y_1 \leq y < y_2} \texttt{image} (x,y) = \texttt{sum} (x_2,y_2)- \texttt{sum} (x_1,y_2)- \texttt{sum} (x_2,y_1)+ \texttt{sum} (x_1,y_1)\) It makes possible to do a fast blurring or fast block correlation with a variable window size, for example. In case of multi-channel images, sums for each channel are accumulated independently. As a practical example, the next figure shows the calculation of the integral of a straight rectangle Rect(3,3,3,2) and of a tilted rectangle Rect(5,1,2,3) . The selected pixels in the original image are shown, as well as the relative pixels in the integral images sum and tilted . ![integral calculation example](pics/integral.png)
      Parameters:
      src - input image as \(W \times H\), 8-bit or floating-point (32f or 64f).
      sum - integral image as \((W+1)\times (H+1)\) , 32-bit integer or floating-point (32f or 64f).
      sqsum - integral image for squared pixel values; it is \((W+1)\times (H+1)\), double-precision floating-point (64f) array.
      tilted - integral for the image rotated by 45 degrees; it is \((W+1)\times (H+1)\) array with the same data type as sum. CV_64F.
    • integral

      public static void integral​(Mat src, Mat sum, int sdepth)
    • integral

      public static void integral​(Mat src, Mat sum)
    • integral2

      public static void integral2​(Mat src, Mat sum, Mat sqsum, int sdepth, int sqdepth)
    • integral2

      public static void integral2​(Mat src, Mat sum, Mat sqsum, int sdepth)
    • integral2

      public static void integral2​(Mat src, Mat sum, Mat sqsum)
    • accumulate

      public static void accumulate​(Mat src, Mat dst, Mat mask)
      Adds an image to the accumulator image. The function adds src or some of its elements to dst : \(\texttt{dst} (x,y) \leftarrow \texttt{dst} (x,y) + \texttt{src} (x,y) \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\) The function supports multi-channel images. Each channel is processed independently. The function cv::accumulate can be used, for example, to collect statistics of a scene background viewed by a still camera and for the further foreground-background segmentation.
      Parameters:
      src - Input image of type CV_8UC(n), CV_16UC(n), CV_32FC(n) or CV_64FC(n), where n is a positive integer.
      dst - %Accumulator image with the same number of channels as input image, and a depth of CV_32F or CV_64F.
      mask - Optional operation mask. SEE: accumulateSquare, accumulateProduct, accumulateWeighted
    • accumulate

      public static void accumulate​(Mat src, Mat dst)
      Adds an image to the accumulator image. The function adds src or some of its elements to dst : \(\texttt{dst} (x,y) \leftarrow \texttt{dst} (x,y) + \texttt{src} (x,y) \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\) The function supports multi-channel images. Each channel is processed independently. The function cv::accumulate can be used, for example, to collect statistics of a scene background viewed by a still camera and for the further foreground-background segmentation.
      Parameters:
      src - Input image of type CV_8UC(n), CV_16UC(n), CV_32FC(n) or CV_64FC(n), where n is a positive integer.
      dst - %Accumulator image with the same number of channels as input image, and a depth of CV_32F or CV_64F. SEE: accumulateSquare, accumulateProduct, accumulateWeighted
    • accumulateSquare

      public static void accumulateSquare​(Mat src, Mat dst, Mat mask)
      Adds the square of a source image to the accumulator image. The function adds the input image src or its selected region, raised to a power of 2, to the accumulator dst : \(\texttt{dst} (x,y) \leftarrow \texttt{dst} (x,y) + \texttt{src} (x,y)^2 \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\) The function supports multi-channel images. Each channel is processed independently.
      Parameters:
      src - Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
      dst - %Accumulator image with the same number of channels as input image, 32-bit or 64-bit floating-point.
      mask - Optional operation mask. SEE: accumulateSquare, accumulateProduct, accumulateWeighted
    • accumulateSquare

      public static void accumulateSquare​(Mat src, Mat dst)
      Adds the square of a source image to the accumulator image. The function adds the input image src or its selected region, raised to a power of 2, to the accumulator dst : \(\texttt{dst} (x,y) \leftarrow \texttt{dst} (x,y) + \texttt{src} (x,y)^2 \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\) The function supports multi-channel images. Each channel is processed independently.
      Parameters:
      src - Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
      dst - %Accumulator image with the same number of channels as input image, 32-bit or 64-bit floating-point. SEE: accumulateSquare, accumulateProduct, accumulateWeighted
    • accumulateProduct

      public static void accumulateProduct​(Mat src1, Mat src2, Mat dst, Mat mask)
      Adds the per-element product of two input images to the accumulator image. The function adds the product of two images or their selected regions to the accumulator dst : \(\texttt{dst} (x,y) \leftarrow \texttt{dst} (x,y) + \texttt{src1} (x,y) \cdot \texttt{src2} (x,y) \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\) The function supports multi-channel images. Each channel is processed independently.
      Parameters:
      src1 - First input image, 1- or 3-channel, 8-bit or 32-bit floating point.
      src2 - Second input image of the same type and the same size as src1 .
      dst - %Accumulator image with the same number of channels as input images, 32-bit or 64-bit floating-point.
      mask - Optional operation mask. SEE: accumulate, accumulateSquare, accumulateWeighted
    • accumulateProduct

      public static void accumulateProduct​(Mat src1, Mat src2, Mat dst)
      Adds the per-element product of two input images to the accumulator image. The function adds the product of two images or their selected regions to the accumulator dst : \(\texttt{dst} (x,y) \leftarrow \texttt{dst} (x,y) + \texttt{src1} (x,y) \cdot \texttt{src2} (x,y) \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\) The function supports multi-channel images. Each channel is processed independently.
      Parameters:
      src1 - First input image, 1- or 3-channel, 8-bit or 32-bit floating point.
      src2 - Second input image of the same type and the same size as src1 .
      dst - %Accumulator image with the same number of channels as input images, 32-bit or 64-bit floating-point. SEE: accumulate, accumulateSquare, accumulateWeighted
    • accumulateWeighted

      public static void accumulateWeighted​(Mat src, Mat dst, double alpha, Mat mask)
      Updates a running average. The function calculates the weighted sum of the input image src and the accumulator dst so that dst becomes a running average of a frame sequence: \(\texttt{dst} (x,y) \leftarrow (1- \texttt{alpha} ) \cdot \texttt{dst} (x,y) + \texttt{alpha} \cdot \texttt{src} (x,y) \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\) That is, alpha regulates the update speed (how fast the accumulator "forgets" about earlier images). The function supports multi-channel images. Each channel is processed independently.
      Parameters:
      src - Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
      dst - %Accumulator image with the same number of channels as input image, 32-bit or 64-bit floating-point.
      alpha - Weight of the input image.
      mask - Optional operation mask. SEE: accumulate, accumulateSquare, accumulateProduct
    • accumulateWeighted

      public static void accumulateWeighted​(Mat src, Mat dst, double alpha)
      Updates a running average. The function calculates the weighted sum of the input image src and the accumulator dst so that dst becomes a running average of a frame sequence: \(\texttt{dst} (x,y) \leftarrow (1- \texttt{alpha} ) \cdot \texttt{dst} (x,y) + \texttt{alpha} \cdot \texttt{src} (x,y) \quad \text{if} \quad \texttt{mask} (x,y) \ne 0\) That is, alpha regulates the update speed (how fast the accumulator "forgets" about earlier images). The function supports multi-channel images. Each channel is processed independently.
      Parameters:
      src - Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
      dst - %Accumulator image with the same number of channels as input image, 32-bit or 64-bit floating-point.
      alpha - Weight of the input image. SEE: accumulate, accumulateSquare, accumulateProduct
    • phaseCorrelate

      public static Point phaseCorrelate​(Mat src1, Mat src2, Mat window, double[] response)
      The function is used to detect translational shifts that occur between two images. The operation takes advantage of the Fourier shift theorem for detecting the translational shift in the frequency domain. It can be used for fast image registration as well as motion estimation. For more information please see <http://en.wikipedia.org/wiki/Phase_correlation> Calculates the cross-power spectrum of two supplied source arrays. The arrays are padded if needed with getOptimalDFTSize. The function performs the following equations:
      • First it applies a Hanning window (see <http://en.wikipedia.org/wiki/Hann_function>) to each image to remove possible edge effects. This window is cached until the array size changes to speed up processing time.
      • Next it computes the forward DFTs of each source array: \(\mathbf{G}_a = \mathcal{F}\{src_1\}, \; \mathbf{G}_b = \mathcal{F}\{src_2\}\) where \(\mathcal{F}\) is the forward DFT.
      • It then computes the cross-power spectrum of each frequency domain array: \(R = \frac{ \mathbf{G}_a \mathbf{G}_b^*}{|\mathbf{G}_a \mathbf{G}_b^*|}\)
      • Next the cross-correlation is converted back into the time domain via the inverse DFT: \(r = \mathcal{F}^{-1}\{R\}\)
      • Finally, it computes the peak location and computes a 5x5 weighted centroid around the peak to achieve sub-pixel accuracy. \((\Delta x, \Delta y) = \texttt{weightedCentroid} \{\arg \max_{(x, y)}\{r\}\}\)
      • If non-zero, the response parameter is computed as the sum of the elements of r within the 5x5 centroid around the peak location. It is normalized to a maximum of 1 (meaning there is a single peak) and will be smaller when there are multiple peaks.
      Parameters:
      src1 - Source floating point array (CV_32FC1 or CV_64FC1)
      src2 - Source floating point array (CV_32FC1 or CV_64FC1)
      window - Floating point array with windowing coefficients to reduce edge effects (optional).
      response - Signal power within the 5x5 centroid around the peak, between 0 and 1 (optional).
      Returns:
      detected phase shift (sub-pixel) between the two arrays. SEE: dft, getOptimalDFTSize, idft, mulSpectrums createHanningWindow
    • phaseCorrelate

      public static Point phaseCorrelate​(Mat src1, Mat src2, Mat window)
      The function is used to detect translational shifts that occur between two images. The operation takes advantage of the Fourier shift theorem for detecting the translational shift in the frequency domain. It can be used for fast image registration as well as motion estimation. For more information please see <http://en.wikipedia.org/wiki/Phase_correlation> Calculates the cross-power spectrum of two supplied source arrays. The arrays are padded if needed with getOptimalDFTSize. The function performs the following equations:
      • First it applies a Hanning window (see <http://en.wikipedia.org/wiki/Hann_function>) to each image to remove possible edge effects. This window is cached until the array size changes to speed up processing time.
      • Next it computes the forward DFTs of each source array: \(\mathbf{G}_a = \mathcal{F}\{src_1\}, \; \mathbf{G}_b = \mathcal{F}\{src_2\}\) where \(\mathcal{F}\) is the forward DFT.
      • It then computes the cross-power spectrum of each frequency domain array: \(R = \frac{ \mathbf{G}_a \mathbf{G}_b^*}{|\mathbf{G}_a \mathbf{G}_b^*|}\)
      • Next the cross-correlation is converted back into the time domain via the inverse DFT: \(r = \mathcal{F}^{-1}\{R\}\)
      • Finally, it computes the peak location and computes a 5x5 weighted centroid around the peak to achieve sub-pixel accuracy. \((\Delta x, \Delta y) = \texttt{weightedCentroid} \{\arg \max_{(x, y)}\{r\}\}\)
      • If non-zero, the response parameter is computed as the sum of the elements of r within the 5x5 centroid around the peak location. It is normalized to a maximum of 1 (meaning there is a single peak) and will be smaller when there are multiple peaks.
      Parameters:
      src1 - Source floating point array (CV_32FC1 or CV_64FC1)
      src2 - Source floating point array (CV_32FC1 or CV_64FC1)
      window - Floating point array with windowing coefficients to reduce edge effects (optional).
      Returns:
      detected phase shift (sub-pixel) between the two arrays. SEE: dft, getOptimalDFTSize, idft, mulSpectrums createHanningWindow
    • phaseCorrelate

      public static Point phaseCorrelate​(Mat src1, Mat src2)
      The function is used to detect translational shifts that occur between two images. The operation takes advantage of the Fourier shift theorem for detecting the translational shift in the frequency domain. It can be used for fast image registration as well as motion estimation. For more information please see <http://en.wikipedia.org/wiki/Phase_correlation> Calculates the cross-power spectrum of two supplied source arrays. The arrays are padded if needed with getOptimalDFTSize. The function performs the following equations:
      • First it applies a Hanning window (see <http://en.wikipedia.org/wiki/Hann_function>) to each image to remove possible edge effects. This window is cached until the array size changes to speed up processing time.
      • Next it computes the forward DFTs of each source array: \(\mathbf{G}_a = \mathcal{F}\{src_1\}, \; \mathbf{G}_b = \mathcal{F}\{src_2\}\) where \(\mathcal{F}\) is the forward DFT.
      • It then computes the cross-power spectrum of each frequency domain array: \(R = \frac{ \mathbf{G}_a \mathbf{G}_b^*}{|\mathbf{G}_a \mathbf{G}_b^*|}\)
      • Next the cross-correlation is converted back into the time domain via the inverse DFT: \(r = \mathcal{F}^{-1}\{R\}\)
      • Finally, it computes the peak location and computes a 5x5 weighted centroid around the peak to achieve sub-pixel accuracy. \((\Delta x, \Delta y) = \texttt{weightedCentroid} \{\arg \max_{(x, y)}\{r\}\}\)
      • If non-zero, the response parameter is computed as the sum of the elements of r within the 5x5 centroid around the peak location. It is normalized to a maximum of 1 (meaning there is a single peak) and will be smaller when there are multiple peaks.
      Parameters:
      src1 - Source floating point array (CV_32FC1 or CV_64FC1)
      src2 - Source floating point array (CV_32FC1 or CV_64FC1)
      Returns:
      detected phase shift (sub-pixel) between the two arrays. SEE: dft, getOptimalDFTSize, idft, mulSpectrums createHanningWindow
    • createHanningWindow

      public static void createHanningWindow​(Mat dst, Size winSize, int type)
      This function computes a Hanning window coefficients in two dimensions. See (http://en.wikipedia.org/wiki/Hann_function) and (http://en.wikipedia.org/wiki/Window_function) for more information. An example is shown below: // create hanning window of size 100x100 and type CV_32F Mat hann; createHanningWindow(hann, Size(100, 100), CV_32F);
      Parameters:
      dst - Destination array to place Hann coefficients in
      winSize - The window size specifications (both width and height must be > 1)
      type - Created array type
    • divSpectrums

      public static void divSpectrums​(Mat a, Mat b, Mat c, int flags, boolean conjB)
      Performs the per-element division of the first Fourier spectrum by the second Fourier spectrum. The function cv::divSpectrums performs the per-element division of the first array by the second array. The arrays are CCS-packed or complex matrices that are results of a real or complex Fourier transform.
      Parameters:
      a - first input array.
      b - second input array of the same size and type as src1 .
      c - output array of the same size and type as src1 .
      flags - operation flags; currently, the only supported flag is cv::DFT_ROWS, which indicates that each row of src1 and src2 is an independent 1D Fourier spectrum. If you do not want to use this flag, then simply add a 0 as value.
      conjB - optional flag that conjugates the second input array before the multiplication (true) or not (false).
    • divSpectrums

      public static void divSpectrums​(Mat a, Mat b, Mat c, int flags)
      Performs the per-element division of the first Fourier spectrum by the second Fourier spectrum. The function cv::divSpectrums performs the per-element division of the first array by the second array. The arrays are CCS-packed or complex matrices that are results of a real or complex Fourier transform.
      Parameters:
      a - first input array.
      b - second input array of the same size and type as src1 .
      c - output array of the same size and type as src1 .
      flags - operation flags; currently, the only supported flag is cv::DFT_ROWS, which indicates that each row of src1 and src2 is an independent 1D Fourier spectrum. If you do not want to use this flag, then simply add a 0 as value. or not (false).
    • threshold

      public static double threshold​(Mat src, Mat dst, double thresh, double maxval, int type)
      Applies a fixed-level threshold to each array element. The function applies fixed-level thresholding to a multiple-channel array. The function is typically used to get a bi-level (binary) image out of a grayscale image ( #compare could be also used for this purpose) or for removing a noise, that is, filtering out pixels with too small or too large values. There are several types of thresholding supported by the function. They are determined by type parameter. Also, the special values #THRESH_OTSU or #THRESH_TRIANGLE may be combined with one of the above values. In these cases, the function determines the optimal threshold value using the Otsu's or Triangle algorithm and uses it instead of the specified thresh. Note: Currently, the Otsu's and Triangle methods are implemented only for 8-bit single-channel images.
      Parameters:
      src - input array (multiple-channel, 8-bit or 32-bit floating point).
      dst - output array of the same size and type and the same number of channels as src.
      thresh - threshold value.
      maxval - maximum value to use with the #THRESH_BINARY and #THRESH_BINARY_INV thresholding types.
      type - thresholding type (see #ThresholdTypes).
      Returns:
      the computed threshold value if Otsu's or Triangle methods used. SEE: adaptiveThreshold, findContours, compare, min, max
    • adaptiveThreshold

      public static void adaptiveThreshold​(Mat src, Mat dst, double maxValue, int adaptiveMethod, int thresholdType, int blockSize, double C)
      Applies an adaptive threshold to an array. The function transforms a grayscale image to a binary image according to the formulae:
      • THRESH_BINARY \(dst(x,y) = \fork{\texttt{maxValue}}{if \(src(x,y) > T(x,y)\)}{0}{otherwise}\)
      • THRESH_BINARY_INV \(dst(x,y) = \fork{0}{if \(src(x,y) > T(x,y)\)}{\texttt{maxValue}}{otherwise}\) where \(T(x,y)\) is a threshold calculated individually for each pixel (see adaptiveMethod parameter).
      The function can process the image in-place.
      Parameters:
      src - Source 8-bit single-channel image.
      dst - Destination image of the same size and the same type as src.
      maxValue - Non-zero value assigned to the pixels for which the condition is satisfied
      adaptiveMethod - Adaptive thresholding algorithm to use, see #AdaptiveThresholdTypes. The #BORDER_REPLICATE | #BORDER_ISOLATED is used to process boundaries.
      thresholdType - Thresholding type that must be either #THRESH_BINARY or #THRESH_BINARY_INV, see #ThresholdTypes.
      blockSize - Size of a pixel neighborhood that is used to calculate a threshold value for the pixel: 3, 5, 7, and so on.
      C - Constant subtracted from the mean or weighted mean (see the details below). Normally, it is positive but may be zero or negative as well. SEE: threshold, blur, GaussianBlur
    • pyrDown

      public static void pyrDown​(Mat src, Mat dst, Size dstsize, int borderType)
      Blurs an image and downsamples it. By default, size of the output image is computed as Size((src.cols+1)/2, (src.rows+1)/2), but in any case, the following conditions should be satisfied: \(\begin{array}{l} | \texttt{dstsize.width} *2-src.cols| \leq 2 \\ | \texttt{dstsize.height} *2-src.rows| \leq 2 \end{array}\) The function performs the downsampling step of the Gaussian pyramid construction. First, it convolves the source image with the kernel: \(\frac{1}{256} \begin{bmatrix} 1 & 4 & 6 & 4 & 1 \\ 4 & 16 & 24 & 16 & 4 \\ 6 & 24 & 36 & 24 & 6 \\ 4 & 16 & 24 & 16 & 4 \\ 1 & 4 & 6 & 4 & 1 \end{bmatrix}\) Then, it downsamples the image by rejecting even rows and columns.
      Parameters:
      src - input image.
      dst - output image; it has the specified size and the same type as src.
      dstsize - size of the output image.
      borderType - Pixel extrapolation method, see #BorderTypes (#BORDER_CONSTANT isn't supported)
    • pyrDown

      public static void pyrDown​(Mat src, Mat dst, Size dstsize)
      Blurs an image and downsamples it. By default, size of the output image is computed as Size((src.cols+1)/2, (src.rows+1)/2), but in any case, the following conditions should be satisfied: \(\begin{array}{l} | \texttt{dstsize.width} *2-src.cols| \leq 2 \\ | \texttt{dstsize.height} *2-src.rows| \leq 2 \end{array}\) The function performs the downsampling step of the Gaussian pyramid construction. First, it convolves the source image with the kernel: \(\frac{1}{256} \begin{bmatrix} 1 & 4 & 6 & 4 & 1 \\ 4 & 16 & 24 & 16 & 4 \\ 6 & 24 & 36 & 24 & 6 \\ 4 & 16 & 24 & 16 & 4 \\ 1 & 4 & 6 & 4 & 1 \end{bmatrix}\) Then, it downsamples the image by rejecting even rows and columns.
      Parameters:
      src - input image.
      dst - output image; it has the specified size and the same type as src.
      dstsize - size of the output image.
    • pyrDown

      public static void pyrDown​(Mat src, Mat dst)
      Blurs an image and downsamples it. By default, size of the output image is computed as Size((src.cols+1)/2, (src.rows+1)/2), but in any case, the following conditions should be satisfied: \(\begin{array}{l} | \texttt{dstsize.width} *2-src.cols| \leq 2 \\ | \texttt{dstsize.height} *2-src.rows| \leq 2 \end{array}\) The function performs the downsampling step of the Gaussian pyramid construction. First, it convolves the source image with the kernel: \(\frac{1}{256} \begin{bmatrix} 1 & 4 & 6 & 4 & 1 \\ 4 & 16 & 24 & 16 & 4 \\ 6 & 24 & 36 & 24 & 6 \\ 4 & 16 & 24 & 16 & 4 \\ 1 & 4 & 6 & 4 & 1 \end{bmatrix}\) Then, it downsamples the image by rejecting even rows and columns.
      Parameters:
      src - input image.
      dst - output image; it has the specified size and the same type as src.
    • pyrUp

      public static void pyrUp​(Mat src, Mat dst, Size dstsize, int borderType)
      Upsamples an image and then blurs it. By default, size of the output image is computed as Size(src.cols\*2, (src.rows\*2), but in any case, the following conditions should be satisfied: \(\begin{array}{l} | \texttt{dstsize.width} -src.cols*2| \leq ( \texttt{dstsize.width} \mod 2) \\ | \texttt{dstsize.height} -src.rows*2| \leq ( \texttt{dstsize.height} \mod 2) \end{array}\) The function performs the upsampling step of the Gaussian pyramid construction, though it can actually be used to construct the Laplacian pyramid. First, it upsamples the source image by injecting even zero rows and columns and then convolves the result with the same kernel as in pyrDown multiplied by 4.
      Parameters:
      src - input image.
      dst - output image. It has the specified size and the same type as src .
      dstsize - size of the output image.
      borderType - Pixel extrapolation method, see #BorderTypes (only #BORDER_DEFAULT is supported)
    • pyrUp

      public static void pyrUp​(Mat src, Mat dst, Size dstsize)
      Upsamples an image and then blurs it. By default, size of the output image is computed as Size(src.cols\*2, (src.rows\*2), but in any case, the following conditions should be satisfied: \(\begin{array}{l} | \texttt{dstsize.width} -src.cols*2| \leq ( \texttt{dstsize.width} \mod 2) \\ | \texttt{dstsize.height} -src.rows*2| \leq ( \texttt{dstsize.height} \mod 2) \end{array}\) The function performs the upsampling step of the Gaussian pyramid construction, though it can actually be used to construct the Laplacian pyramid. First, it upsamples the source image by injecting even zero rows and columns and then convolves the result with the same kernel as in pyrDown multiplied by 4.
      Parameters:
      src - input image.
      dst - output image. It has the specified size and the same type as src .
      dstsize - size of the output image.
    • pyrUp

      public static void pyrUp​(Mat src, Mat dst)
      Upsamples an image and then blurs it. By default, size of the output image is computed as Size(src.cols\*2, (src.rows\*2), but in any case, the following conditions should be satisfied: \(\begin{array}{l} | \texttt{dstsize.width} -src.cols*2| \leq ( \texttt{dstsize.width} \mod 2) \\ | \texttt{dstsize.height} -src.rows*2| \leq ( \texttt{dstsize.height} \mod 2) \end{array}\) The function performs the upsampling step of the Gaussian pyramid construction, though it can actually be used to construct the Laplacian pyramid. First, it upsamples the source image by injecting even zero rows and columns and then convolves the result with the same kernel as in pyrDown multiplied by 4.
      Parameters:
      src - input image.
      dst - output image. It has the specified size and the same type as src .
    • calcHist

      public static void calcHist​(List<Mat> images, MatOfInt channels, Mat mask, Mat hist, MatOfInt histSize, MatOfFloat ranges, boolean accumulate)
    • calcHist

      public static void calcHist​(List<Mat> images, MatOfInt channels, Mat mask, Mat hist, MatOfInt histSize, MatOfFloat ranges)
    • calcBackProject

      public static void calcBackProject​(List<Mat> images, MatOfInt channels, Mat hist, Mat dst, MatOfFloat ranges, double scale)
    • compareHist

      public static double compareHist​(Mat H1, Mat H2, int method)
      Compares two histograms. The function cv::compareHist compares two dense or two sparse histograms using the specified method. The function returns \(d(H_1, H_2)\) . While the function works well with 1-, 2-, 3-dimensional dense histograms, it may not be suitable for high-dimensional sparse histograms. In such histograms, because of aliasing and sampling problems, the coordinates of non-zero histogram bins can slightly shift. To compare such histograms or more general sparse configurations of weighted points, consider using the #EMD function.
      Parameters:
      H1 - First compared histogram.
      H2 - Second compared histogram of the same size as H1 .
      method - Comparison method, see #HistCompMethods
      Returns:
      automatically generated
    • equalizeHist

      public static void equalizeHist​(Mat src, Mat dst)
      Equalizes the histogram of a grayscale image. The function equalizes the histogram of the input image using the following algorithm:
      • Calculate the histogram \(H\) for src .
      • Normalize the histogram so that the sum of histogram bins is 255.
      • Compute the integral of the histogram: \(H'_i = \sum _{0 \le j < i} H(j)\)
      • Transform the image using \(H'\) as a look-up table: \(\texttt{dst}(x,y) = H'(\texttt{src}(x,y))\)
      The algorithm normalizes the brightness and increases the contrast of the image.
      Parameters:
      src - Source 8-bit single channel image.
      dst - Destination image of the same size and type as src .
    • createCLAHE

      public static CLAHE createCLAHE​(double clipLimit, Size tileGridSize)
      Creates a smart pointer to a cv::CLAHE class and initializes it.
      Parameters:
      clipLimit - Threshold for contrast limiting.
      tileGridSize - Size of grid for histogram equalization. Input image will be divided into equally sized rectangular tiles. tileGridSize defines the number of tiles in row and column.
      Returns:
      automatically generated
    • createCLAHE

      public static CLAHE createCLAHE​(double clipLimit)
      Creates a smart pointer to a cv::CLAHE class and initializes it.
      Parameters:
      clipLimit - Threshold for contrast limiting. equally sized rectangular tiles. tileGridSize defines the number of tiles in row and column.
      Returns:
      automatically generated
    • createCLAHE

      public static CLAHE createCLAHE()
      Creates a smart pointer to a cv::CLAHE class and initializes it. equally sized rectangular tiles. tileGridSize defines the number of tiles in row and column.
      Returns:
      automatically generated
    • EMD

      public static float EMD​(Mat signature1, Mat signature2, int distType, Mat cost, Mat flow)
      Computes the "minimal work" distance between two weighted point configurations. The function computes the earth mover distance and/or a lower boundary of the distance between the two weighted point configurations. One of the applications described in CITE: RubnerSept98, CITE: Rubner2000 is multi-dimensional histogram comparison for image retrieval. EMD is a transportation problem that is solved using some modification of a simplex algorithm, thus the complexity is exponential in the worst case, though, on average it is much faster. In the case of a real metric the lower boundary can be calculated even faster (using linear-time algorithm) and it can be used to determine roughly whether the two signatures are far enough so that they cannot relate to the same object.
      Parameters:
      signature1 - First signature, a \(\texttt{size1}\times \texttt{dims}+1\) floating-point matrix. Each row stores the point weight followed by the point coordinates. The matrix is allowed to have a single column (weights only) if the user-defined cost matrix is used. The weights must be non-negative and have at least one non-zero value.
      signature2 - Second signature of the same format as signature1 , though the number of rows may be different. The total weights may be different. In this case an extra "dummy" point is added to either signature1 or signature2. The weights must be non-negative and have at least one non-zero value.
      distType - Used metric. See #DistanceTypes.
      cost - User-defined \(\texttt{size1}\times \texttt{size2}\) cost matrix. Also, if a cost matrix is used, lower boundary lowerBound cannot be calculated because it needs a metric function. signatures that is a distance between mass centers. The lower boundary may not be calculated if the user-defined cost matrix is used, the total weights of point configurations are not equal, or if the signatures consist of weights only (the signature matrices have a single column). You must initialize \*lowerBound . If the calculated distance between mass centers is greater or equal to \*lowerBound (it means that the signatures are far enough), the function does not calculate EMD. In any case \*lowerBound is set to the calculated distance between mass centers on return. Thus, if you want to calculate both distance between mass centers and EMD, \*lowerBound should be set to 0.
      flow - Resultant \(\texttt{size1} \times \texttt{size2}\) flow matrix: \(\texttt{flow}_{i,j}\) is a flow from \(i\) -th point of signature1 to \(j\) -th point of signature2 .
      Returns:
      automatically generated
    • EMD

      public static float EMD​(Mat signature1, Mat signature2, int distType, Mat cost)
      Computes the "minimal work" distance between two weighted point configurations. The function computes the earth mover distance and/or a lower boundary of the distance between the two weighted point configurations. One of the applications described in CITE: RubnerSept98, CITE: Rubner2000 is multi-dimensional histogram comparison for image retrieval. EMD is a transportation problem that is solved using some modification of a simplex algorithm, thus the complexity is exponential in the worst case, though, on average it is much faster. In the case of a real metric the lower boundary can be calculated even faster (using linear-time algorithm) and it can be used to determine roughly whether the two signatures are far enough so that they cannot relate to the same object.
      Parameters:
      signature1 - First signature, a \(\texttt{size1}\times \texttt{dims}+1\) floating-point matrix. Each row stores the point weight followed by the point coordinates. The matrix is allowed to have a single column (weights only) if the user-defined cost matrix is used. The weights must be non-negative and have at least one non-zero value.
      signature2 - Second signature of the same format as signature1 , though the number of rows may be different. The total weights may be different. In this case an extra "dummy" point is added to either signature1 or signature2. The weights must be non-negative and have at least one non-zero value.
      distType - Used metric. See #DistanceTypes.
      cost - User-defined \(\texttt{size1}\times \texttt{size2}\) cost matrix. Also, if a cost matrix is used, lower boundary lowerBound cannot be calculated because it needs a metric function. signatures that is a distance between mass centers. The lower boundary may not be calculated if the user-defined cost matrix is used, the total weights of point configurations are not equal, or if the signatures consist of weights only (the signature matrices have a single column). You must initialize \*lowerBound . If the calculated distance between mass centers is greater or equal to \*lowerBound (it means that the signatures are far enough), the function does not calculate EMD. In any case \*lowerBound is set to the calculated distance between mass centers on return. Thus, if you want to calculate both distance between mass centers and EMD, \*lowerBound should be set to 0. a flow from \(i\) -th point of signature1 to \(j\) -th point of signature2 .
      Returns:
      automatically generated
    • EMD

      public static float EMD​(Mat signature1, Mat signature2, int distType)
      Computes the "minimal work" distance between two weighted point configurations. The function computes the earth mover distance and/or a lower boundary of the distance between the two weighted point configurations. One of the applications described in CITE: RubnerSept98, CITE: Rubner2000 is multi-dimensional histogram comparison for image retrieval. EMD is a transportation problem that is solved using some modification of a simplex algorithm, thus the complexity is exponential in the worst case, though, on average it is much faster. In the case of a real metric the lower boundary can be calculated even faster (using linear-time algorithm) and it can be used to determine roughly whether the two signatures are far enough so that they cannot relate to the same object.
      Parameters:
      signature1 - First signature, a \(\texttt{size1}\times \texttt{dims}+1\) floating-point matrix. Each row stores the point weight followed by the point coordinates. The matrix is allowed to have a single column (weights only) if the user-defined cost matrix is used. The weights must be non-negative and have at least one non-zero value.
      signature2 - Second signature of the same format as signature1 , though the number of rows may be different. The total weights may be different. In this case an extra "dummy" point is added to either signature1 or signature2. The weights must be non-negative and have at least one non-zero value.
      distType - Used metric. See #DistanceTypes. is used, lower boundary lowerBound cannot be calculated because it needs a metric function. signatures that is a distance between mass centers. The lower boundary may not be calculated if the user-defined cost matrix is used, the total weights of point configurations are not equal, or if the signatures consist of weights only (the signature matrices have a single column). You must initialize \*lowerBound . If the calculated distance between mass centers is greater or equal to \*lowerBound (it means that the signatures are far enough), the function does not calculate EMD. In any case \*lowerBound is set to the calculated distance between mass centers on return. Thus, if you want to calculate both distance between mass centers and EMD, \*lowerBound should be set to 0. a flow from \(i\) -th point of signature1 to \(j\) -th point of signature2 .
      Returns:
      automatically generated
    • watershed

      public static void watershed​(Mat image, Mat markers)
      Performs a marker-based image segmentation using the watershed algorithm. The function implements one of the variants of watershed, non-parametric marker-based segmentation algorithm, described in CITE: Meyer92 . Before passing the image to the function, you have to roughly outline the desired regions in the image markers with positive (>0) indices. So, every region is represented as one or more connected components with the pixel values 1, 2, 3, and so on. Such markers can be retrieved from a binary mask using #findContours and #drawContours (see the watershed.cpp demo). The markers are "seeds" of the future image regions. All the other pixels in markers , whose relation to the outlined regions is not known and should be defined by the algorithm, should be set to 0's. In the function output, each pixel in markers is set to a value of the "seed" components or to -1 at boundaries between the regions. Note: Any two neighbor connected components are not necessarily separated by a watershed boundary (-1's pixels); for example, they can touch each other in the initial marker image passed to the function.
      Parameters:
      image - Input 8-bit 3-channel image.
      markers - Input/output 32-bit single-channel image (map) of markers. It should have the same size as image . SEE: findContours
    • pyrMeanShiftFiltering

      public static void pyrMeanShiftFiltering​(Mat src, Mat dst, double sp, double sr, int maxLevel, TermCriteria termcrit)
      Performs initial step of meanshift segmentation of an image. The function implements the filtering stage of meanshift segmentation, that is, the output of the function is the filtered "posterized" image with color gradients and fine-grain texture flattened. At every pixel (X,Y) of the input image (or down-sized input image, see below) the function executes meanshift iterations, that is, the pixel (X,Y) neighborhood in the joint space-color hyperspace is considered: \((x,y): X- \texttt{sp} \le x \le X+ \texttt{sp} , Y- \texttt{sp} \le y \le Y+ \texttt{sp} , ||(R,G,B)-(r,g,b)|| \le \texttt{sr}\) where (R,G,B) and (r,g,b) are the vectors of color components at (X,Y) and (x,y), respectively (though, the algorithm does not depend on the color space used, so any 3-component color space can be used instead). Over the neighborhood the average spatial value (X',Y') and average color vector (R',G',B') are found and they act as the neighborhood center on the next iteration: \((X,Y)~(X',Y'), (R,G,B)~(R',G',B').\) After the iterations over, the color components of the initial pixel (that is, the pixel from where the iterations started) are set to the final value (average color at the last iteration): \(I(X,Y) <- (R*,G*,B*)\) When maxLevel > 0, the gaussian pyramid of maxLevel+1 levels is built, and the above procedure is run on the smallest layer first. After that, the results are propagated to the larger layer and the iterations are run again only on those pixels where the layer colors differ by more than sr from the lower-resolution layer of the pyramid. That makes boundaries of color regions sharper. Note that the results will be actually different from the ones obtained by running the meanshift procedure on the whole original image (i.e. when maxLevel==0).
      Parameters:
      src - The source 8-bit, 3-channel image.
      dst - The destination image of the same format and the same size as the source.
      sp - The spatial window radius.
      sr - The color window radius.
      maxLevel - Maximum level of the pyramid for the segmentation.
      termcrit - Termination criteria: when to stop meanshift iterations.
    • pyrMeanShiftFiltering

      public static void pyrMeanShiftFiltering​(Mat src, Mat dst, double sp, double sr, int maxLevel)
      Performs initial step of meanshift segmentation of an image. The function implements the filtering stage of meanshift segmentation, that is, the output of the function is the filtered "posterized" image with color gradients and fine-grain texture flattened. At every pixel (X,Y) of the input image (or down-sized input image, see below) the function executes meanshift iterations, that is, the pixel (X,Y) neighborhood in the joint space-color hyperspace is considered: \((x,y): X- \texttt{sp} \le x \le X+ \texttt{sp} , Y- \texttt{sp} \le y \le Y+ \texttt{sp} , ||(R,G,B)-(r,g,b)|| \le \texttt{sr}\) where (R,G,B) and (r,g,b) are the vectors of color components at (X,Y) and (x,y), respectively (though, the algorithm does not depend on the color space used, so any 3-component color space can be used instead). Over the neighborhood the average spatial value (X',Y') and average color vector (R',G',B') are found and they act as the neighborhood center on the next iteration: \((X,Y)~(X',Y'), (R,G,B)~(R',G',B').\) After the iterations over, the color components of the initial pixel (that is, the pixel from where the iterations started) are set to the final value (average color at the last iteration): \(I(X,Y) <- (R*,G*,B*)\) When maxLevel > 0, the gaussian pyramid of maxLevel+1 levels is built, and the above procedure is run on the smallest layer first. After that, the results are propagated to the larger layer and the iterations are run again only on those pixels where the layer colors differ by more than sr from the lower-resolution layer of the pyramid. That makes boundaries of color regions sharper. Note that the results will be actually different from the ones obtained by running the meanshift procedure on the whole original image (i.e. when maxLevel==0).
      Parameters:
      src - The source 8-bit, 3-channel image.
      dst - The destination image of the same format and the same size as the source.
      sp - The spatial window radius.
      sr - The color window radius.
      maxLevel - Maximum level of the pyramid for the segmentation.
    • pyrMeanShiftFiltering

      public static void pyrMeanShiftFiltering​(Mat src, Mat dst, double sp, double sr)
      Performs initial step of meanshift segmentation of an image. The function implements the filtering stage of meanshift segmentation, that is, the output of the function is the filtered "posterized" image with color gradients and fine-grain texture flattened. At every pixel (X,Y) of the input image (or down-sized input image, see below) the function executes meanshift iterations, that is, the pixel (X,Y) neighborhood in the joint space-color hyperspace is considered: \((x,y): X- \texttt{sp} \le x \le X+ \texttt{sp} , Y- \texttt{sp} \le y \le Y+ \texttt{sp} , ||(R,G,B)-(r,g,b)|| \le \texttt{sr}\) where (R,G,B) and (r,g,b) are the vectors of color components at (X,Y) and (x,y), respectively (though, the algorithm does not depend on the color space used, so any 3-component color space can be used instead). Over the neighborhood the average spatial value (X',Y') and average color vector (R',G',B') are found and they act as the neighborhood center on the next iteration: \((X,Y)~(X',Y'), (R,G,B)~(R',G',B').\) After the iterations over, the color components of the initial pixel (that is, the pixel from where the iterations started) are set to the final value (average color at the last iteration): \(I(X,Y) <- (R*,G*,B*)\) When maxLevel > 0, the gaussian pyramid of maxLevel+1 levels is built, and the above procedure is run on the smallest layer first. After that, the results are propagated to the larger layer and the iterations are run again only on those pixels where the layer colors differ by more than sr from the lower-resolution layer of the pyramid. That makes boundaries of color regions sharper. Note that the results will be actually different from the ones obtained by running the meanshift procedure on the whole original image (i.e. when maxLevel==0).
      Parameters:
      src - The source 8-bit, 3-channel image.
      dst - The destination image of the same format and the same size as the source.
      sp - The spatial window radius.
      sr - The color window radius.
    • grabCut

      public static void grabCut​(Mat img, Mat mask, Rect rect, Mat bgdModel, Mat fgdModel, int iterCount, int mode)
      Runs the GrabCut algorithm. The function implements the [GrabCut image segmentation algorithm](http://en.wikipedia.org/wiki/GrabCut).
      Parameters:
      img - Input 8-bit 3-channel image.
      mask - Input/output 8-bit single-channel mask. The mask is initialized by the function when mode is set to #GC_INIT_WITH_RECT. Its elements may have one of the #GrabCutClasses.
      rect - ROI containing a segmented object. The pixels outside of the ROI are marked as "obvious background". The parameter is only used when mode==#GC_INIT_WITH_RECT .
      bgdModel - Temporary array for the background model. Do not modify it while you are processing the same image.
      fgdModel - Temporary arrays for the foreground model. Do not modify it while you are processing the same image.
      iterCount - Number of iterations the algorithm should make before returning the result. Note that the result can be refined with further calls with mode==#GC_INIT_WITH_MASK or mode==GC_EVAL .
      mode - Operation mode that could be one of the #GrabCutModes
    • grabCut

      public static void grabCut​(Mat img, Mat mask, Rect rect, Mat bgdModel, Mat fgdModel, int iterCount)
      Runs the GrabCut algorithm. The function implements the [GrabCut image segmentation algorithm](http://en.wikipedia.org/wiki/GrabCut).
      Parameters:
      img - Input 8-bit 3-channel image.
      mask - Input/output 8-bit single-channel mask. The mask is initialized by the function when mode is set to #GC_INIT_WITH_RECT. Its elements may have one of the #GrabCutClasses.
      rect - ROI containing a segmented object. The pixels outside of the ROI are marked as "obvious background". The parameter is only used when mode==#GC_INIT_WITH_RECT .
      bgdModel - Temporary array for the background model. Do not modify it while you are processing the same image.
      fgdModel - Temporary arrays for the foreground model. Do not modify it while you are processing the same image.
      iterCount - Number of iterations the algorithm should make before returning the result. Note that the result can be refined with further calls with mode==#GC_INIT_WITH_MASK or mode==GC_EVAL .
    • distanceTransformWithLabels

      public static void distanceTransformWithLabels​(Mat src, Mat dst, Mat labels, int distanceType, int maskSize, int labelType)
      Calculates the distance to the closest zero pixel for each pixel of the source image. The function cv::distanceTransform calculates the approximate or precise distance from every binary image pixel to the nearest zero pixel. For zero image pixels, the distance will obviously be zero. When maskSize == #DIST_MASK_PRECISE and distanceType == #DIST_L2 , the function runs the algorithm described in CITE: Felzenszwalb04 . This algorithm is parallelized with the TBB library. In other cases, the algorithm CITE: Borgefors86 is used. This means that for a pixel the function finds the shortest path to the nearest zero pixel consisting of basic shifts: horizontal, vertical, diagonal, or knight's move (the latest is available for a \(5\times 5\) mask). The overall distance is calculated as a sum of these basic distances. Since the distance function should be symmetric, all of the horizontal and vertical shifts must have the same cost (denoted as a ), all the diagonal shifts must have the same cost (denoted as b), and all knight's moves must have the same cost (denoted as c). For the #DIST_C and #DIST_L1 types, the distance is calculated precisely, whereas for #DIST_L2 (Euclidean distance) the distance can be calculated only with a relative error (a \(5\times 5\) mask gives more accurate results). For a,b, and c, OpenCV uses the values suggested in the original paper:
      • DIST_L1: a = 1, b = 2
      • DIST_L2:
        • 3 x 3: a=0.955, b=1.3693
        • 5 x 5: a=1, b=1.4, c=2.1969
      • DIST_C: a = 1, b = 1
      Typically, for a fast, coarse distance estimation #DIST_L2, a \(3\times 3\) mask is used. For a more accurate distance estimation #DIST_L2, a \(5\times 5\) mask or the precise algorithm is used. Note that both the precise and the approximate algorithms are linear on the number of pixels. This variant of the function does not only compute the minimum distance for each pixel \((x, y)\) but also identifies the nearest connected component consisting of zero pixels (labelType==#DIST_LABEL_CCOMP) or the nearest zero pixel (labelType==#DIST_LABEL_PIXEL). Index of the component/pixel is stored in labels(x, y). When labelType==#DIST_LABEL_CCOMP, the function automatically finds connected components of zero pixels in the input image and marks them with distinct labels. When labelType==#DIST_LABEL_PIXEL, the function scans through the input image and marks all the zero pixels with distinct labels. In this mode, the complexity is still linear. That is, the function provides a very fast way to compute the Voronoi diagram for a binary image. Currently, the second variant can use only the approximate distance transform algorithm, i.e. maskSize=#DIST_MASK_PRECISE is not supported yet.
      Parameters:
      src - 8-bit, single-channel (binary) source image.
      dst - Output image with calculated distances. It is a 8-bit or 32-bit floating-point, single-channel image of the same size as src.
      labels - Output 2D array of labels (the discrete Voronoi diagram). It has the type CV_32SC1 and the same size as src.
      distanceType - Type of distance, see #DistanceTypes
      maskSize - Size of the distance transform mask, see #DistanceTransformMasks. #DIST_MASK_PRECISE is not supported by this variant. In case of the #DIST_L1 or #DIST_C distance type, the parameter is forced to 3 because a \(3\times 3\) mask gives the same result as \(5\times 5\) or any larger aperture.
      labelType - Type of the label array to build, see #DistanceTransformLabelTypes.
    • distanceTransformWithLabels

      public static void distanceTransformWithLabels​(Mat src, Mat dst, Mat labels, int distanceType, int maskSize)
      Calculates the distance to the closest zero pixel for each pixel of the source image. The function cv::distanceTransform calculates the approximate or precise distance from every binary image pixel to the nearest zero pixel. For zero image pixels, the distance will obviously be zero. When maskSize == #DIST_MASK_PRECISE and distanceType == #DIST_L2 , the function runs the algorithm described in CITE: Felzenszwalb04 . This algorithm is parallelized with the TBB library. In other cases, the algorithm CITE: Borgefors86 is used. This means that for a pixel the function finds the shortest path to the nearest zero pixel consisting of basic shifts: horizontal, vertical, diagonal, or knight's move (the latest is available for a \(5\times 5\) mask). The overall distance is calculated as a sum of these basic distances. Since the distance function should be symmetric, all of the horizontal and vertical shifts must have the same cost (denoted as a ), all the diagonal shifts must have the same cost (denoted as b), and all knight's moves must have the same cost (denoted as c). For the #DIST_C and #DIST_L1 types, the distance is calculated precisely, whereas for #DIST_L2 (Euclidean distance) the distance can be calculated only with a relative error (a \(5\times 5\) mask gives more accurate results). For a,b, and c, OpenCV uses the values suggested in the original paper:
      • DIST_L1: a = 1, b = 2
      • DIST_L2:
        • 3 x 3: a=0.955, b=1.3693
        • 5 x 5: a=1, b=1.4, c=2.1969
      • DIST_C: a = 1, b = 1
      Typically, for a fast, coarse distance estimation #DIST_L2, a \(3\times 3\) mask is used. For a more accurate distance estimation #DIST_L2, a \(5\times 5\) mask or the precise algorithm is used. Note that both the precise and the approximate algorithms are linear on the number of pixels. This variant of the function does not only compute the minimum distance for each pixel \((x, y)\) but also identifies the nearest connected component consisting of zero pixels (labelType==#DIST_LABEL_CCOMP) or the nearest zero pixel (labelType==#DIST_LABEL_PIXEL). Index of the component/pixel is stored in labels(x, y). When labelType==#DIST_LABEL_CCOMP, the function automatically finds connected components of zero pixels in the input image and marks them with distinct labels. When labelType==#DIST_LABEL_PIXEL, the function scans through the input image and marks all the zero pixels with distinct labels. In this mode, the complexity is still linear. That is, the function provides a very fast way to compute the Voronoi diagram for a binary image. Currently, the second variant can use only the approximate distance transform algorithm, i.e. maskSize=#DIST_MASK_PRECISE is not supported yet.
      Parameters:
      src - 8-bit, single-channel (binary) source image.
      dst - Output image with calculated distances. It is a 8-bit or 32-bit floating-point, single-channel image of the same size as src.
      labels - Output 2D array of labels (the discrete Voronoi diagram). It has the type CV_32SC1 and the same size as src.
      distanceType - Type of distance, see #DistanceTypes
      maskSize - Size of the distance transform mask, see #DistanceTransformMasks. #DIST_MASK_PRECISE is not supported by this variant. In case of the #DIST_L1 or #DIST_C distance type, the parameter is forced to 3 because a \(3\times 3\) mask gives the same result as \(5\times 5\) or any larger aperture.
    • distanceTransform

      public static void distanceTransform​(Mat src, Mat dst, int distanceType, int maskSize, int dstType)
      Parameters:
      src - 8-bit, single-channel (binary) source image.
      dst - Output image with calculated distances. It is a 8-bit or 32-bit floating-point, single-channel image of the same size as src .
      distanceType - Type of distance, see #DistanceTypes
      maskSize - Size of the distance transform mask, see #DistanceTransformMasks. In case of the #DIST_L1 or #DIST_C distance type, the parameter is forced to 3 because a \(3\times 3\) mask gives the same result as \(5\times 5\) or any larger aperture.
      dstType - Type of output image. It can be CV_8U or CV_32F. Type CV_8U can be used only for the first variant of the function and distanceType == #DIST_L1.
    • distanceTransform

      public static void distanceTransform​(Mat src, Mat dst, int distanceType, int maskSize)
      Parameters:
      src - 8-bit, single-channel (binary) source image.
      dst - Output image with calculated distances. It is a 8-bit or 32-bit floating-point, single-channel image of the same size as src .
      distanceType - Type of distance, see #DistanceTypes
      maskSize - Size of the distance transform mask, see #DistanceTransformMasks. In case of the #DIST_L1 or #DIST_C distance type, the parameter is forced to 3 because a \(3\times 3\) mask gives the same result as \(5\times 5\) or any larger aperture. the first variant of the function and distanceType == #DIST_L1.
    • floodFill

      public static int floodFill​(Mat image, Mat mask, Point seedPoint, Scalar newVal, Rect rect, Scalar loDiff, Scalar upDiff, int flags)
      Fills a connected component with the given color. The function cv::floodFill fills a connected component starting from the seed point with the specified color. The connectivity is determined by the color/brightness closeness of the neighbor pixels. The pixel at \((x,y)\) is considered to belong to the repainted domain if:
      • in case of a grayscale image and floating range \(\texttt{src} (x',y')- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} (x',y')+ \texttt{upDiff}\)
      • in case of a grayscale image and fixed range \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)+ \texttt{upDiff}\)
      • in case of a color image and floating range \(\texttt{src} (x',y')_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} (x',y')_r+ \texttt{upDiff} _r,\) \(\texttt{src} (x',y')_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} (x',y')_g+ \texttt{upDiff} _g\) and \(\texttt{src} (x',y')_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} (x',y')_b+ \texttt{upDiff} _b\)
      • in case of a color image and fixed range \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r+ \texttt{upDiff} _r,\) \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g+ \texttt{upDiff} _g\) and \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b+ \texttt{upDiff} _b\)
      where \(src(x',y')\) is the value of one of pixel neighbors that is already known to belong to the component. That is, to be added to the connected component, a color/brightness of the pixel should be close enough to:
      • Color/brightness of one of its neighbors that already belong to the connected component in case of a floating range.
      • Color/brightness of the seed point in case of a fixed range.
      Use these functions to either mark a connected component with the specified color in-place, or build a mask and then extract the contour, or copy the region to another image, and so on.
      Parameters:
      image - Input/output 1- or 3-channel, 8-bit, or floating-point image. It is modified by the function unless the #FLOODFILL_MASK_ONLY flag is set in the second variant of the function. See the details below.
      mask - Operation mask that should be a single-channel 8-bit image, 2 pixels wider and 2 pixels taller than image. If an empty Mat is passed it will be created automatically. Since this is both an input and output parameter, you must take responsibility of initializing it. Flood-filling cannot go across non-zero pixels in the input mask. For example, an edge detector output can be used as a mask to stop filling at edges. On output, pixels in the mask corresponding to filled pixels in the image are set to 1 or to the specified value in flags as described below. Additionally, the function fills the border of the mask with ones to simplify internal processing. It is therefore possible to use the same mask in multiple calls to the function to make sure the filled areas do not overlap.
      seedPoint - Starting point.
      newVal - New value of the repainted domain pixels.
      loDiff - Maximal lower brightness/color difference between the currently observed pixel and one of its neighbors belonging to the component, or a seed pixel being added to the component.
      upDiff - Maximal upper brightness/color difference between the currently observed pixel and one of its neighbors belonging to the component, or a seed pixel being added to the component.
      rect - Optional output parameter set by the function to the minimum bounding rectangle of the repainted domain.
      flags - Operation flags. The first 8 bits contain a connectivity value. The default value of 4 means that only the four nearest neighbor pixels (those that share an edge) are considered. A connectivity value of 8 means that the eight nearest neighbor pixels (those that share a corner) will be considered. The next 8 bits (8-16) contain a value between 1 and 255 with which to fill the mask (the default value is 1). For example, 4 | ( 255 << 8 ) will consider 4 nearest neighbours and fill the mask with a value of 255. The following additional options occupy higher bits and therefore may be further combined with the connectivity and mask fill values using bit-wise or (|), see #FloodFillFlags. Note: Since the mask is larger than the filled image, a pixel \((x, y)\) in image corresponds to the pixel \((x+1, y+1)\) in the mask . SEE: findContours
      Returns:
      automatically generated
    • floodFill

      public static int floodFill​(Mat image, Mat mask, Point seedPoint, Scalar newVal, Rect rect, Scalar loDiff, Scalar upDiff)
      Fills a connected component with the given color. The function cv::floodFill fills a connected component starting from the seed point with the specified color. The connectivity is determined by the color/brightness closeness of the neighbor pixels. The pixel at \((x,y)\) is considered to belong to the repainted domain if:
      • in case of a grayscale image and floating range \(\texttt{src} (x',y')- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} (x',y')+ \texttt{upDiff}\)
      • in case of a grayscale image and fixed range \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)+ \texttt{upDiff}\)
      • in case of a color image and floating range \(\texttt{src} (x',y')_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} (x',y')_r+ \texttt{upDiff} _r,\) \(\texttt{src} (x',y')_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} (x',y')_g+ \texttt{upDiff} _g\) and \(\texttt{src} (x',y')_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} (x',y')_b+ \texttt{upDiff} _b\)
      • in case of a color image and fixed range \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r+ \texttt{upDiff} _r,\) \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g+ \texttt{upDiff} _g\) and \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b+ \texttt{upDiff} _b\)
      where \(src(x',y')\) is the value of one of pixel neighbors that is already known to belong to the component. That is, to be added to the connected component, a color/brightness of the pixel should be close enough to:
      • Color/brightness of one of its neighbors that already belong to the connected component in case of a floating range.
      • Color/brightness of the seed point in case of a fixed range.
      Use these functions to either mark a connected component with the specified color in-place, or build a mask and then extract the contour, or copy the region to another image, and so on.
      Parameters:
      image - Input/output 1- or 3-channel, 8-bit, or floating-point image. It is modified by the function unless the #FLOODFILL_MASK_ONLY flag is set in the second variant of the function. See the details below.
      mask - Operation mask that should be a single-channel 8-bit image, 2 pixels wider and 2 pixels taller than image. If an empty Mat is passed it will be created automatically. Since this is both an input and output parameter, you must take responsibility of initializing it. Flood-filling cannot go across non-zero pixels in the input mask. For example, an edge detector output can be used as a mask to stop filling at edges. On output, pixels in the mask corresponding to filled pixels in the image are set to 1 or to the specified value in flags as described below. Additionally, the function fills the border of the mask with ones to simplify internal processing. It is therefore possible to use the same mask in multiple calls to the function to make sure the filled areas do not overlap.
      seedPoint - Starting point.
      newVal - New value of the repainted domain pixels.
      loDiff - Maximal lower brightness/color difference between the currently observed pixel and one of its neighbors belonging to the component, or a seed pixel being added to the component.
      upDiff - Maximal upper brightness/color difference between the currently observed pixel and one of its neighbors belonging to the component, or a seed pixel being added to the component.
      rect - Optional output parameter set by the function to the minimum bounding rectangle of the repainted domain. 4 means that only the four nearest neighbor pixels (those that share an edge) are considered. A connectivity value of 8 means that the eight nearest neighbor pixels (those that share a corner) will be considered. The next 8 bits (8-16) contain a value between 1 and 255 with which to fill the mask (the default value is 1). For example, 4 | ( 255 << 8 ) will consider 4 nearest neighbours and fill the mask with a value of 255. The following additional options occupy higher bits and therefore may be further combined with the connectivity and mask fill values using bit-wise or (|), see #FloodFillFlags. Note: Since the mask is larger than the filled image, a pixel \((x, y)\) in image corresponds to the pixel \((x+1, y+1)\) in the mask . SEE: findContours
      Returns:
      automatically generated
    • floodFill

      public static int floodFill​(Mat image, Mat mask, Point seedPoint, Scalar newVal, Rect rect, Scalar loDiff)
      Fills a connected component with the given color. The function cv::floodFill fills a connected component starting from the seed point with the specified color. The connectivity is determined by the color/brightness closeness of the neighbor pixels. The pixel at \((x,y)\) is considered to belong to the repainted domain if:
      • in case of a grayscale image and floating range \(\texttt{src} (x',y')- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} (x',y')+ \texttt{upDiff}\)
      • in case of a grayscale image and fixed range \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)+ \texttt{upDiff}\)
      • in case of a color image and floating range \(\texttt{src} (x',y')_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} (x',y')_r+ \texttt{upDiff} _r,\) \(\texttt{src} (x',y')_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} (x',y')_g+ \texttt{upDiff} _g\) and \(\texttt{src} (x',y')_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} (x',y')_b+ \texttt{upDiff} _b\)
      • in case of a color image and fixed range \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r+ \texttt{upDiff} _r,\) \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g+ \texttt{upDiff} _g\) and \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b+ \texttt{upDiff} _b\)
      where \(src(x',y')\) is the value of one of pixel neighbors that is already known to belong to the component. That is, to be added to the connected component, a color/brightness of the pixel should be close enough to:
      • Color/brightness of one of its neighbors that already belong to the connected component in case of a floating range.
      • Color/brightness of the seed point in case of a fixed range.
      Use these functions to either mark a connected component with the specified color in-place, or build a mask and then extract the contour, or copy the region to another image, and so on.
      Parameters:
      image - Input/output 1- or 3-channel, 8-bit, or floating-point image. It is modified by the function unless the #FLOODFILL_MASK_ONLY flag is set in the second variant of the function. See the details below.
      mask - Operation mask that should be a single-channel 8-bit image, 2 pixels wider and 2 pixels taller than image. If an empty Mat is passed it will be created automatically. Since this is both an input and output parameter, you must take responsibility of initializing it. Flood-filling cannot go across non-zero pixels in the input mask. For example, an edge detector output can be used as a mask to stop filling at edges. On output, pixels in the mask corresponding to filled pixels in the image are set to 1 or to the specified value in flags as described below. Additionally, the function fills the border of the mask with ones to simplify internal processing. It is therefore possible to use the same mask in multiple calls to the function to make sure the filled areas do not overlap.
      seedPoint - Starting point.
      newVal - New value of the repainted domain pixels.
      loDiff - Maximal lower brightness/color difference between the currently observed pixel and one of its neighbors belonging to the component, or a seed pixel being added to the component. one of its neighbors belonging to the component, or a seed pixel being added to the component.
      rect - Optional output parameter set by the function to the minimum bounding rectangle of the repainted domain. 4 means that only the four nearest neighbor pixels (those that share an edge) are considered. A connectivity value of 8 means that the eight nearest neighbor pixels (those that share a corner) will be considered. The next 8 bits (8-16) contain a value between 1 and 255 with which to fill the mask (the default value is 1). For example, 4 | ( 255 << 8 ) will consider 4 nearest neighbours and fill the mask with a value of 255. The following additional options occupy higher bits and therefore may be further combined with the connectivity and mask fill values using bit-wise or (|), see #FloodFillFlags. Note: Since the mask is larger than the filled image, a pixel \((x, y)\) in image corresponds to the pixel \((x+1, y+1)\) in the mask . SEE: findContours
      Returns:
      automatically generated
    • floodFill

      public static int floodFill​(Mat image, Mat mask, Point seedPoint, Scalar newVal, Rect rect)
      Fills a connected component with the given color. The function cv::floodFill fills a connected component starting from the seed point with the specified color. The connectivity is determined by the color/brightness closeness of the neighbor pixels. The pixel at \((x,y)\) is considered to belong to the repainted domain if:
      • in case of a grayscale image and floating range \(\texttt{src} (x',y')- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} (x',y')+ \texttt{upDiff}\)
      • in case of a grayscale image and fixed range \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)+ \texttt{upDiff}\)
      • in case of a color image and floating range \(\texttt{src} (x',y')_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} (x',y')_r+ \texttt{upDiff} _r,\) \(\texttt{src} (x',y')_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} (x',y')_g+ \texttt{upDiff} _g\) and \(\texttt{src} (x',y')_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} (x',y')_b+ \texttt{upDiff} _b\)
      • in case of a color image and fixed range \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r+ \texttt{upDiff} _r,\) \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g+ \texttt{upDiff} _g\) and \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b+ \texttt{upDiff} _b\)
      where \(src(x',y')\) is the value of one of pixel neighbors that is already known to belong to the component. That is, to be added to the connected component, a color/brightness of the pixel should be close enough to:
      • Color/brightness of one of its neighbors that already belong to the connected component in case of a floating range.
      • Color/brightness of the seed point in case of a fixed range.
      Use these functions to either mark a connected component with the specified color in-place, or build a mask and then extract the contour, or copy the region to another image, and so on.
      Parameters:
      image - Input/output 1- or 3-channel, 8-bit, or floating-point image. It is modified by the function unless the #FLOODFILL_MASK_ONLY flag is set in the second variant of the function. See the details below.
      mask - Operation mask that should be a single-channel 8-bit image, 2 pixels wider and 2 pixels taller than image. If an empty Mat is passed it will be created automatically. Since this is both an input and output parameter, you must take responsibility of initializing it. Flood-filling cannot go across non-zero pixels in the input mask. For example, an edge detector output can be used as a mask to stop filling at edges. On output, pixels in the mask corresponding to filled pixels in the image are set to 1 or to the specified value in flags as described below. Additionally, the function fills the border of the mask with ones to simplify internal processing. It is therefore possible to use the same mask in multiple calls to the function to make sure the filled areas do not overlap.
      seedPoint - Starting point.
      newVal - New value of the repainted domain pixels. one of its neighbors belonging to the component, or a seed pixel being added to the component. one of its neighbors belonging to the component, or a seed pixel being added to the component.
      rect - Optional output parameter set by the function to the minimum bounding rectangle of the repainted domain. 4 means that only the four nearest neighbor pixels (those that share an edge) are considered. A connectivity value of 8 means that the eight nearest neighbor pixels (those that share a corner) will be considered. The next 8 bits (8-16) contain a value between 1 and 255 with which to fill the mask (the default value is 1). For example, 4 | ( 255 << 8 ) will consider 4 nearest neighbours and fill the mask with a value of 255. The following additional options occupy higher bits and therefore may be further combined with the connectivity and mask fill values using bit-wise or (|), see #FloodFillFlags. Note: Since the mask is larger than the filled image, a pixel \((x, y)\) in image corresponds to the pixel \((x+1, y+1)\) in the mask . SEE: findContours
      Returns:
      automatically generated
    • floodFill

      public static int floodFill​(Mat image, Mat mask, Point seedPoint, Scalar newVal)
      Fills a connected component with the given color. The function cv::floodFill fills a connected component starting from the seed point with the specified color. The connectivity is determined by the color/brightness closeness of the neighbor pixels. The pixel at \((x,y)\) is considered to belong to the repainted domain if:
      • in case of a grayscale image and floating range \(\texttt{src} (x',y')- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} (x',y')+ \texttt{upDiff}\)
      • in case of a grayscale image and fixed range \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)- \texttt{loDiff} \leq \texttt{src} (x,y) \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)+ \texttt{upDiff}\)
      • in case of a color image and floating range \(\texttt{src} (x',y')_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} (x',y')_r+ \texttt{upDiff} _r,\) \(\texttt{src} (x',y')_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} (x',y')_g+ \texttt{upDiff} _g\) and \(\texttt{src} (x',y')_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} (x',y')_b+ \texttt{upDiff} _b\)
      • in case of a color image and fixed range \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r- \texttt{loDiff} _r \leq \texttt{src} (x,y)_r \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_r+ \texttt{upDiff} _r,\) \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g- \texttt{loDiff} _g \leq \texttt{src} (x,y)_g \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_g+ \texttt{upDiff} _g\) and \(\texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b- \texttt{loDiff} _b \leq \texttt{src} (x,y)_b \leq \texttt{src} ( \texttt{seedPoint} .x, \texttt{seedPoint} .y)_b+ \texttt{upDiff} _b\)
      where \(src(x',y')\) is the value of one of pixel neighbors that is already known to belong to the component. That is, to be added to the connected component, a color/brightness of the pixel should be close enough to:
      • Color/brightness of one of its neighbors that already belong to the connected component in case of a floating range.
      • Color/brightness of the seed point in case of a fixed range.
      Use these functions to either mark a connected component with the specified color in-place, or build a mask and then extract the contour, or copy the region to another image, and so on.
      Parameters:
      image - Input/output 1- or 3-channel, 8-bit, or floating-point image. It is modified by the function unless the #FLOODFILL_MASK_ONLY flag is set in the second variant of the function. See the details below.
      mask - Operation mask that should be a single-channel 8-bit image, 2 pixels wider and 2 pixels taller than image. If an empty Mat is passed it will be created automatically. Since this is both an input and output parameter, you must take responsibility of initializing it. Flood-filling cannot go across non-zero pixels in the input mask. For example, an edge detector output can be used as a mask to stop filling at edges. On output, pixels in the mask corresponding to filled pixels in the image are set to 1 or to the specified value in flags as described below. Additionally, the function fills the border of the mask with ones to simplify internal processing. It is therefore possible to use the same mask in multiple calls to the function to make sure the filled areas do not overlap.
      seedPoint - Starting point.
      newVal - New value of the repainted domain pixels. one of its neighbors belonging to the component, or a seed pixel being added to the component. one of its neighbors belonging to the component, or a seed pixel being added to the component. repainted domain. 4 means that only the four nearest neighbor pixels (those that share an edge) are considered. A connectivity value of 8 means that the eight nearest neighbor pixels (those that share a corner) will be considered. The next 8 bits (8-16) contain a value between 1 and 255 with which to fill the mask (the default value is 1). For example, 4 | ( 255 << 8 ) will consider 4 nearest neighbours and fill the mask with a value of 255. The following additional options occupy higher bits and therefore may be further combined with the connectivity and mask fill values using bit-wise or (|), see #FloodFillFlags. Note: Since the mask is larger than the filled image, a pixel \((x, y)\) in image corresponds to the pixel \((x+1, y+1)\) in the mask . SEE: findContours
      Returns:
      automatically generated
    • blendLinear

      public static void blendLinear​(Mat src1, Mat src2, Mat weights1, Mat weights2, Mat dst)
      variant without mask parameter
      Parameters:
      src1 - automatically generated
      src2 - automatically generated
      weights1 - automatically generated
      weights2 - automatically generated
      dst - automatically generated
    • cvtColor

      public static void cvtColor​(Mat src, Mat dst, int code, int dstCn)
      Converts an image from one color space to another. The function converts an input image from one color space to another. In case of a transformation to-from RGB color space, the order of the channels should be specified explicitly (RGB or BGR). Note that the default color format in OpenCV is often referred to as RGB but it is actually BGR (the bytes are reversed). So the first byte in a standard (24-bit) color image will be an 8-bit Blue component, the second byte will be Green, and the third byte will be Red. The fourth, fifth, and sixth bytes would then be the second pixel (Blue, then Green, then Red), and so on. The conventional ranges for R, G, and B channel values are:
      • 0 to 255 for CV_8U images
      • 0 to 65535 for CV_16U images
      • 0 to 1 for CV_32F images
      In case of linear transformations, the range does not matter. But in case of a non-linear transformation, an input RGB image should be normalized to the proper value range to get the correct results, for example, for RGB \(\rightarrow\) L\*u\*v\* transformation. For example, if you have a 32-bit floating-point image directly converted from an 8-bit image without any scaling, then it will have the 0..255 value range instead of 0..1 assumed by the function. So, before calling #cvtColor , you need first to scale the image down: img *= 1./255; cvtColor(img, img, COLOR_BGR2Luv); If you use #cvtColor with 8-bit images, the conversion will have some information lost. For many applications, this will not be noticeable but it is recommended to use 32-bit images in applications that need the full range of colors or that convert an image before an operation and then convert back. If conversion adds the alpha channel, its value will set to the maximum of corresponding channel range: 255 for CV_8U, 65535 for CV_16U, 1 for CV_32F.
      Parameters:
      src - input image: 8-bit unsigned, 16-bit unsigned ( CV_16UC... ), or single-precision floating-point.
      dst - output image of the same size and depth as src.
      code - color space conversion code (see #ColorConversionCodes).
      dstCn - number of channels in the destination image; if the parameter is 0, the number of the channels is derived automatically from src and code. SEE: REF: imgproc_color_conversions
    • cvtColor

      public static void cvtColor​(Mat src, Mat dst, int code)
      Converts an image from one color space to another. The function converts an input image from one color space to another. In case of a transformation to-from RGB color space, the order of the channels should be specified explicitly (RGB or BGR). Note that the default color format in OpenCV is often referred to as RGB but it is actually BGR (the bytes are reversed). So the first byte in a standard (24-bit) color image will be an 8-bit Blue component, the second byte will be Green, and the third byte will be Red. The fourth, fifth, and sixth bytes would then be the second pixel (Blue, then Green, then Red), and so on. The conventional ranges for R, G, and B channel values are:
      • 0 to 255 for CV_8U images
      • 0 to 65535 for CV_16U images
      • 0 to 1 for CV_32F images
      In case of linear transformations, the range does not matter. But in case of a non-linear transformation, an input RGB image should be normalized to the proper value range to get the correct results, for example, for RGB \(\rightarrow\) L\*u\*v\* transformation. For example, if you have a 32-bit floating-point image directly converted from an 8-bit image without any scaling, then it will have the 0..255 value range instead of 0..1 assumed by the function. So, before calling #cvtColor , you need first to scale the image down: img *= 1./255; cvtColor(img, img, COLOR_BGR2Luv); If you use #cvtColor with 8-bit images, the conversion will have some information lost. For many applications, this will not be noticeable but it is recommended to use 32-bit images in applications that need the full range of colors or that convert an image before an operation and then convert back. If conversion adds the alpha channel, its value will set to the maximum of corresponding channel range: 255 for CV_8U, 65535 for CV_16U, 1 for CV_32F.
      Parameters:
      src - input image: 8-bit unsigned, 16-bit unsigned ( CV_16UC... ), or single-precision floating-point.
      dst - output image of the same size and depth as src.
      code - color space conversion code (see #ColorConversionCodes). channels is derived automatically from src and code. SEE: REF: imgproc_color_conversions
    • cvtColorTwoPlane

      public static void cvtColorTwoPlane​(Mat src1, Mat src2, Mat dst, int code)
      Converts an image from one color space to another where the source image is stored in two planes. This function only supports YUV420 to RGB conversion as of now.
      • #COLOR_YUV2BGR_NV12
      • #COLOR_YUV2RGB_NV12
      • #COLOR_YUV2BGRA_NV12
      • #COLOR_YUV2RGBA_NV12
      • #COLOR_YUV2BGR_NV21
      • #COLOR_YUV2RGB_NV21
      • #COLOR_YUV2BGRA_NV21
      • #COLOR_YUV2RGBA_NV21
      Parameters:
      src1 - automatically generated
      src2 - automatically generated
      dst - automatically generated
      code - automatically generated
    • demosaicing

      public static void demosaicing​(Mat src, Mat dst, int code, int dstCn)
      main function for all demosaicing processes
      Parameters:
      src - input image: 8-bit unsigned or 16-bit unsigned.
      dst - output image of the same size and depth as src.
      code - Color space conversion code (see the description below).
      dstCn - number of channels in the destination image; if the parameter is 0, the number of the channels is derived automatically from src and code. The function can do the following transformations:
      • Demosaicing using bilinear interpolation
      #COLOR_BayerBG2BGR , #COLOR_BayerGB2BGR , #COLOR_BayerRG2BGR , #COLOR_BayerGR2BGR #COLOR_BayerBG2GRAY , #COLOR_BayerGB2GRAY , #COLOR_BayerRG2GRAY , #COLOR_BayerGR2GRAY
      • Demosaicing using Variable Number of Gradients.
      #COLOR_BayerBG2BGR_VNG , #COLOR_BayerGB2BGR_VNG , #COLOR_BayerRG2BGR_VNG , #COLOR_BayerGR2BGR_VNG
      • Edge-Aware Demosaicing.
      #COLOR_BayerBG2BGR_EA , #COLOR_BayerGB2BGR_EA , #COLOR_BayerRG2BGR_EA , #COLOR_BayerGR2BGR_EA
      • Demosaicing with alpha channel
      #COLOR_BayerBG2BGRA , #COLOR_BayerGB2BGRA , #COLOR_BayerRG2BGRA , #COLOR_BayerGR2BGRA SEE: cvtColor
    • demosaicing

      public static void demosaicing​(Mat src, Mat dst, int code)
      main function for all demosaicing processes
      Parameters:
      src - input image: 8-bit unsigned or 16-bit unsigned.
      dst - output image of the same size and depth as src.
      code - Color space conversion code (see the description below). channels is derived automatically from src and code. The function can do the following transformations:
      • Demosaicing using bilinear interpolation
      #COLOR_BayerBG2BGR , #COLOR_BayerGB2BGR , #COLOR_BayerRG2BGR , #COLOR_BayerGR2BGR #COLOR_BayerBG2GRAY , #COLOR_BayerGB2GRAY , #COLOR_BayerRG2GRAY , #COLOR_BayerGR2GRAY
      • Demosaicing using Variable Number of Gradients.
      #COLOR_BayerBG2BGR_VNG , #COLOR_BayerGB2BGR_VNG , #COLOR_BayerRG2BGR_VNG , #COLOR_BayerGR2BGR_VNG
      • Edge-Aware Demosaicing.
      #COLOR_BayerBG2BGR_EA , #COLOR_BayerGB2BGR_EA , #COLOR_BayerRG2BGR_EA , #COLOR_BayerGR2BGR_EA
      • Demosaicing with alpha channel
      #COLOR_BayerBG2BGRA , #COLOR_BayerGB2BGRA , #COLOR_BayerRG2BGRA , #COLOR_BayerGR2BGRA SEE: cvtColor
    • moments

      public static Moments moments​(Mat array, boolean binaryImage)
      Calculates all of the moments up to the third order of a polygon or rasterized shape. The function computes moments, up to the 3rd order, of a vector shape or a rasterized shape. The results are returned in the structure cv::Moments.
      Parameters:
      array - Raster image (single-channel, 8-bit or floating-point 2D array) or an array ( \(1 \times N\) or \(N \times 1\) ) of 2D points (Point or Point2f ).
      binaryImage - If it is true, all non-zero image pixels are treated as 1's. The parameter is used for images only.
      Returns:
      moments. Note: Only applicable to contour moments calculations from Python bindings: Note that the numpy type for the input array should be either np.int32 or np.float32. SEE: contourArea, arcLength
    • moments

      public static Moments moments​(Mat array)
      Calculates all of the moments up to the third order of a polygon or rasterized shape. The function computes moments, up to the 3rd order, of a vector shape or a rasterized shape. The results are returned in the structure cv::Moments.
      Parameters:
      array - Raster image (single-channel, 8-bit or floating-point 2D array) or an array ( \(1 \times N\) or \(N \times 1\) ) of 2D points (Point or Point2f ). used for images only.
      Returns:
      moments. Note: Only applicable to contour moments calculations from Python bindings: Note that the numpy type for the input array should be either np.int32 or np.float32. SEE: contourArea, arcLength
    • HuMoments

      public static void HuMoments​(Moments m, Mat hu)
    • matchTemplate

      public static void matchTemplate​(Mat image, Mat templ, Mat result, int method, Mat mask)
      Compares a template against overlapped image regions. The function slides through image , compares the overlapped patches of size \(w \times h\) against templ using the specified method and stores the comparison results in result . #TemplateMatchModes describes the formulae for the available comparison methods ( \(I\) denotes image, \(T\) template, \(R\) result, \(M\) the optional mask ). The summation is done over template and/or the image patch: \(x' = 0...w-1, y' = 0...h-1\) After the function finishes the comparison, the best matches can be found as global minimums (when #TM_SQDIFF was used) or maximums (when #TM_CCORR or #TM_CCOEFF was used) using the #minMaxLoc function. In case of a color image, template summation in the numerator and each sum in the denominator is done over all of the channels and separate mean values are used for each channel. That is, the function can take a color template and a color image. The result will still be a single-channel image, which is easier to analyze.