Edge Detection
Canny
Finds edges in an image using the Canny algorithm.InputArray
8-bit input image.
InputArray
16-bit x derivative of input image (CV_16SC1 or CV_16SC3).
InputArray
16-bit y derivative of input image (same type as dx).
OutputArray
Output edge map; single channels 8-bit image, which has the same size as image.
double
First threshold for the hysteresis procedure.
double
Second threshold for the hysteresis procedure.
int
default:"3"
Aperture size for the Sobel operator.
bool
default:"false"
A flag, indicating whether a more accurate L2 norm should be used to calculate the image gradient magnitude (L2gradient=true), or whether the default L1 norm is enough (L2gradient=false).
- C++
- Python
Derivatives and Gradients
Sobel
Calculates the first, second, third, or mixed image derivatives using an extended Sobel operator.InputArray
Input image.
OutputArray
Output image of the same size and the same number of channels as src.
int
Output image depth. In the case of 8-bit input images it will result in truncated derivatives.
int
Order of the derivative x.
int
Order of the derivative y.
int
default:"3"
Size of the extended Sobel kernel; it must be 1, 3, 5, or 7.
double
default:"1"
Optional scale factor for the computed derivative values; by default, no scaling is applied.
double
default:"0"
Optional delta value that is added to the results prior to storing them in dst.
int
default:"BORDER_DEFAULT"
Pixel extrapolation method. BORDER_WRAP is not supported.
Scharr
Calculates the first x- or y- image derivative using Scharr operator.InputArray
Input image.
OutputArray
Output image of the same size and the same number of channels as src.
int
Output image depth.
int
Order of the derivative x.
int
Order of the derivative y.
double
default:"1"
Optional scale factor for the computed derivative values.
double
default:"0"
Optional delta value that is added to the results prior to storing them in dst.
int
default:"BORDER_DEFAULT"
Pixel extrapolation method. BORDER_WRAP is not supported.
Laplacian
Calculates the Laplacian of an image.InputArray
Source image.
OutputArray
Destination image of the same size and the same number of channels as src.
int
Desired depth of the destination image.
int
default:"1"
Aperture size used to compute the second-derivative filters. The size must be positive and odd.
double
default:"1"
Optional scale factor for the computed Laplacian values.
double
default:"0"
Optional delta value that is added to the results prior to storing them in dst.
int
default:"BORDER_DEFAULT"
Pixel extrapolation method. BORDER_WRAP is not supported.
Corner Detection
cornerHarris
Harris corner detector.InputArray
Input single-channel 8-bit or floating-point image.
OutputArray
Image to store the Harris detector responses. It has the type CV_32FC1 and the same size as src.
int
Neighborhood size.
int
Aperture parameter for the Sobel operator.
double
Harris detector free parameter.
int
default:"BORDER_DEFAULT"
Pixel extrapolation method. BORDER_WRAP is not supported.
cornerMinEigenVal
Calculates the minimal eigenvalue of gradient matrices for corner detection.InputArray
Input single-channel 8-bit or floating-point image.
OutputArray
Image to store the minimal eigenvalues. It has the type CV_32FC1 and the same size as src.
int
Neighborhood size.
int
default:"3"
Aperture parameter for the Sobel operator.
int
default:"BORDER_DEFAULT"
Pixel extrapolation method. BORDER_WRAP is not supported.
goodFeaturesToTrack
Determines strong corners on an image.InputArray
Input 8-bit or floating-point 32-bit, single-channel image.
OutputArray
Output vector of detected corners.
int
Maximum number of corners to return. If there are more corners than are found, the strongest of them is returned. maxCorners <= 0 implies that no limit on the maximum is set.
double
Parameter characterizing the minimal accepted quality of image corners. The parameter value is multiplied by the best corner quality measure.
double
Minimum possible Euclidean distance between the returned corners.
InputArray
default:"noArray()"
Optional region of interest.
int
default:"3"
Size of an average block for computing a derivative covariation matrix over each pixel neighborhood.
bool
default:"false"
Parameter indicating whether to use a Harris detector or cornerMinEigenVal.
double
default:"0.04"
Free parameter of the Harris detector.
Hough Transform
HoughLines
Finds lines in a binary image using the standard Hough transform.InputArray
8-bit, single-channel binary source image. The image may be modified by the function.
OutputArray
Output vector of lines. Each line is represented by a 2 or 3 element vector (ρ, θ) or (ρ, θ, votes).
double
Distance resolution of the accumulator in pixels.
double
Angle resolution of the accumulator in radians.
int
Accumulator threshold parameter. Only those lines are returned that get enough votes (>threshold).
double
default:"0"
For the multi-scale Hough transform, it is a divisor for the distance resolution rho.
double
default:"0"
For the multi-scale Hough transform, it is a divisor for the distance resolution theta.
double
default:"0"
Minimum angle to check for lines. Must fall between 0 and max_theta.
double
default:"CV_PI"
Upper bound for the angle. Must fall between min_theta and CV_PI.
HoughLinesP
Finds line segments in a binary image using the probabilistic Hough transform.InputArray
8-bit, single-channel binary source image. The image may be modified by the function.
OutputArray
Output vector of lines. Each line is represented by a 4-element vector (x₁, y₁, x₂, y₂), where (x₁,y₁) and (x₂, y₂) are the ending points of each detected line segment.
double
Distance resolution of the accumulator in pixels.
double
Angle resolution of the accumulator in radians.
int
Accumulator threshold parameter. Only those lines are returned that get enough votes (>threshold).
double
default:"0"
Minimum line length. Line segments shorter than that are rejected.
double
default:"0"
Maximum allowed gap between points on the same line to link them.
HoughCircles
Finds circles in a grayscale image using the Hough transform.InputArray
8-bit, single-channel, grayscale input image.
OutputArray
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).
int
Detection method. The available methods are HOUGH_GRADIENT and HOUGH_GRADIENT_ALT.
double
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.
double
Minimum distance between the centers of the detected circles.
double
default:"100"
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.
double
default:"100"
Second method-specific parameter. In case of HOUGH_GRADIENT, it is the accumulator threshold for the circle centers at the detection stage.
int
default:"0"
Minimum circle radius.
int
default:"0"
Maximum circle radius. If <= 0, uses the maximum image dimension.
- C++
- Python
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.
Enumerations
HoughModes
Variants of Hough transform:HOUGH_STANDARD- Classical or standard Hough transformHOUGH_PROBABILISTIC- Probabilistic Hough transform (more efficient)HOUGH_MULTI_SCALE- Multi-scale variant of the classical Hough transformHOUGH_GRADIENT- 21HT for circlesHOUGH_GRADIENT_ALT- Variation of HOUGH_GRADIENT to get better accuracy
