10 Finds edges in an image using the [Canny86]_ algorithm.
12 .. ocv:function:: void Canny( InputArray image, OutputArray edges, double threshold1, double threshold2, int apertureSize=3, bool L2gradient=false )
14 .. ocv:pyfunction:: cv2.Canny(image, threshold1, threshold2[, edges[, apertureSize[, L2gradient]]]) -> edges
16 .. ocv:cfunction:: void cvCanny( const CvArr* image, CvArr* edges, double threshold1, double threshold2, int aperture_size=3 )
18 .. ocv:pyoldfunction:: cv.Canny(image, edges, threshold1, threshold2, aperture_size=3) -> None
20 :param image: single-channel 8-bit input image.
22 :param edges: output edge map; it has the same size and type as ``image`` .
24 :param threshold1: first threshold for the hysteresis procedure.
26 :param threshold2: second threshold for the hysteresis procedure.
28 :param apertureSize: aperture size for the :ocv:func:`Sobel` operator.
30 :param L2gradient: a flag, indicating whether a more accurate :math:`L_2` norm :math:`=\sqrt{(dI/dx)^2 + (dI/dy)^2}` should be used to calculate the image gradient magnitude ( ``L2gradient=true`` ), or whether the default :math:`L_1` norm :math:`=|dI/dx|+|dI/dy|` is enough ( ``L2gradient=false`` ).
32 The function finds edges in the input image ``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
33 http://en.wikipedia.org/wiki/Canny_edge_detector
37 * An example on using the canny edge detector can be found at opencv_source_code/samples/cpp/edge.cpp
39 * (Python) An example on using the canny edge detector can be found at opencv_source_code/samples/cpp/edge.py
41 cornerEigenValsAndVecs
42 ----------------------
43 Calculates eigenvalues and eigenvectors of image blocks for corner detection.
45 .. ocv:function:: void cornerEigenValsAndVecs( InputArray src, OutputArray dst, int blockSize, int ksize, int borderType=BORDER_DEFAULT )
47 .. ocv:pyfunction:: cv2.cornerEigenValsAndVecs(src, blockSize, ksize[, dst[, borderType]]) -> dst
49 .. ocv:cfunction:: void cvCornerEigenValsAndVecs( const CvArr* image, CvArr* eigenvv, int block_size, int aperture_size=3 )
51 .. ocv:pyoldfunction:: cv.CornerEigenValsAndVecs(image, eigenvv, blockSize, aperture_size=3) -> None
53 :param src: Input single-channel 8-bit or floating-point image.
55 :param dst: Image to store the results. It has the same size as ``src`` and the type ``CV_32FC(6)`` .
57 :param blockSize: Neighborhood size (see details below).
59 :param ksize: Aperture parameter for the :ocv:func:`Sobel` operator.
61 :param borderType: Pixel extrapolation method. See :ocv:func:`borderInterpolate` .
64 :math:`p` , the function ``cornerEigenValsAndVecs`` considers a ``blockSize`` :math:`\times` ``blockSize`` neighborhood
65 :math:`S(p)` . It calculates the covariation matrix of derivatives over the neighborhood as:
69 M = \begin{bmatrix} \sum _{S(p)}(dI/dx)^2 & \sum _{S(p)}(dI/dx dI/dy)^2 \\ \sum _{S(p)}(dI/dx dI/dy)^2 & \sum _{S(p)}(dI/dy)^2 \end{bmatrix}
71 where the derivatives are computed using the
72 :ocv:func:`Sobel` operator.
74 After that, it finds eigenvectors and eigenvalues of
75 :math:`M` and stores them in the destination image as
76 :math:`(\lambda_1, \lambda_2, x_1, y_1, x_2, y_2)` where
78 * :math:`\lambda_1, \lambda_2` are the non-sorted eigenvalues of :math:`M`
80 * :math:`x_1, y_1` are the eigenvectors corresponding to :math:`\lambda_1`
82 * :math:`x_2, y_2` are the eigenvectors corresponding to :math:`\lambda_2`
84 The output of the function can be used for robust edge or corner detection.
88 :ocv:func:`cornerMinEigenVal`,
89 :ocv:func:`cornerHarris`,
90 :ocv:func:`preCornerDetect`
94 * (Python) An example on how to use eigenvectors and eigenvalues to estimate image texture flow direction can be found at opencv_source_code/samples/python2/texture_flow.py
100 .. ocv:function:: void cornerHarris( InputArray src, OutputArray dst, int blockSize, int ksize, double k, int borderType=BORDER_DEFAULT )
102 .. ocv:pyfunction:: cv2.cornerHarris(src, blockSize, ksize, k[, dst[, borderType]]) -> dst
104 .. ocv:cfunction:: void cvCornerHarris( const CvArr* image, CvArr* harris_responce, int block_size, int aperture_size=3, double k=0.04 )
106 .. ocv:pyoldfunction:: cv.CornerHarris(image, harris_dst, blockSize, aperture_size=3, k=0.04) -> None
108 :param src: Input single-channel 8-bit or floating-point image.
110 :param dst: Image to store the Harris detector responses. It has the type ``CV_32FC1`` and the same size as ``src`` .
112 :param blockSize: Neighborhood size (see the details on :ocv:func:`cornerEigenValsAndVecs` ).
114 :param ksize: Aperture parameter for the :ocv:func:`Sobel` operator.
116 :param k: Harris detector free parameter. See the formula below.
118 :param borderType: Pixel extrapolation method. See :ocv:func:`borderInterpolate` .
120 The function runs the Harris edge detector on the image. Similarly to
121 :ocv:func:`cornerMinEigenVal` and
122 :ocv:func:`cornerEigenValsAndVecs` , for each pixel
123 :math:`(x, y)` it calculates a
124 :math:`2\times2` gradient covariance matrix
125 :math:`M^{(x,y)}` over a
126 :math:`\texttt{blockSize} \times \texttt{blockSize}` neighborhood. Then, it computes the following characteristic:
130 \texttt{dst} (x,y) = \mathrm{det} M^{(x,y)} - k \cdot \left ( \mathrm{tr} M^{(x,y)} \right )^2
132 Corners in the image can be found as the local maxima of this response map.
138 Calculates the minimal eigenvalue of gradient matrices for corner detection.
140 .. ocv:function:: void cornerMinEigenVal( InputArray src, OutputArray dst, int blockSize, int ksize=3, int borderType=BORDER_DEFAULT )
142 .. ocv:pyfunction:: cv2.cornerMinEigenVal(src, blockSize[, dst[, ksize[, borderType]]]) -> dst
144 .. ocv:cfunction:: void cvCornerMinEigenVal( const CvArr* image, CvArr* eigenval, int block_size, int aperture_size=3 )
146 .. ocv:pyoldfunction:: cv.CornerMinEigenVal(image, eigenval, blockSize, aperture_size=3) -> None
148 :param src: Input single-channel 8-bit or floating-point image.
150 :param dst: Image to store the minimal eigenvalues. It has the type ``CV_32FC1`` and the same size as ``src`` .
152 :param blockSize: Neighborhood size (see the details on :ocv:func:`cornerEigenValsAndVecs` ).
154 :param ksize: Aperture parameter for the :ocv:func:`Sobel` operator.
156 :param borderType: Pixel extrapolation method. See :ocv:func:`borderInterpolate` .
158 The function is similar to
159 :ocv:func:`cornerEigenValsAndVecs` but it calculates and stores only the minimal eigenvalue of the covariance matrix of derivatives, that is,
160 :math:`\min(\lambda_1, \lambda_2)` in terms of the formulae in the
161 :ocv:func:`cornerEigenValsAndVecs` description.
167 Refines the corner locations.
169 .. ocv:function:: void cornerSubPix( InputArray image, InputOutputArray corners, Size winSize, Size zeroZone, TermCriteria criteria )
171 .. ocv:pyfunction:: cv2.cornerSubPix(image, corners, winSize, zeroZone, criteria) -> None
173 .. ocv:cfunction:: void cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners, int count, CvSize win, CvSize zero_zone, CvTermCriteria criteria )
175 .. ocv:pyoldfunction:: cv.FindCornerSubPix(image, corners, win, zero_zone, criteria) -> corners
177 :param image: Input image.
179 :param corners: Initial coordinates of the input corners and refined coordinates provided for output.
181 :param winSize: Half of the side length of the search window. For example, if ``winSize=Size(5,5)`` , then a :math:`5*2+1 \times 5*2+1 = 11 \times 11` search window is used.
183 :param 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.
185 :param 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.
187 The function iterates to find the sub-pixel accurate location of corners or radial saddle points, as shown on the figure below.
189 .. image:: pics/cornersubpix.png
191 Sub-pixel accurate corner locator is based on the observation that every vector from the center
193 :math:`p` located within a neighborhood of
194 :math:`q` is orthogonal to the image gradient at
195 :math:`p` subject to image and measurement noise. Consider the expression:
199 \epsilon _i = {DI_{p_i}}^T \cdot (q - p_i)
202 :math:`{DI_{p_i}}` is an image gradient at one of the points
203 :math:`p_i` in a neighborhood of
204 :math:`q` . The value of
205 :math:`q` is to be found so that
206 :math:`\epsilon_i` is minimized. A system of equations may be set up with
207 :math:`\epsilon_i` set to zero:
211 \sum _i(DI_{p_i} \cdot {DI_{p_i}}^T) - \sum _i(DI_{p_i} \cdot {DI_{p_i}}^T \cdot p_i)
213 where the gradients are summed within a neighborhood ("search window") of
214 :math:`q` . Calling the first gradient term
215 :math:`G` and the second gradient term
222 The algorithm sets the center of the neighborhood window at this new center
223 :math:`q` and then iterates until the center stays within a set threshold.
229 Determines strong corners on an image.
231 .. ocv:function:: void goodFeaturesToTrack( InputArray image, OutputArray corners, int maxCorners, double qualityLevel, double minDistance, InputArray mask=noArray(), int blockSize=3, bool useHarrisDetector=false, double k=0.04 )
233 .. ocv:pyfunction:: cv2.goodFeaturesToTrack(image, maxCorners, qualityLevel, minDistance[, corners[, mask[, blockSize[, useHarrisDetector[, k]]]]]) -> corners
235 .. ocv:cfunction:: void cvGoodFeaturesToTrack( const CvArr* image, CvArr* eig_image, CvArr* temp_image, CvPoint2D32f* corners, int* corner_count, double quality_level, double min_distance, const CvArr* mask=NULL, int block_size=3, int use_harris=0, double k=0.04 )
237 .. ocv:pyoldfunction:: cv.GoodFeaturesToTrack(image, eigImage, tempImage, cornerCount, qualityLevel, minDistance, mask=None, blockSize=3, useHarris=0, k=0.04) -> cornerCount
239 :param image: Input 8-bit or floating-point 32-bit, single-channel image.
241 :param eig_image: The parameter is ignored.
243 :param temp_image: The parameter is ignored.
245 :param corners: Output vector of detected corners.
247 :param maxCorners: Maximum number of corners to return. If there are more corners than are found, the strongest of them is returned.
249 :param 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 :ocv:func:`cornerMinEigenVal` ) or the Harris function response (see :ocv:func:`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.
251 :param minDistance: Minimum possible Euclidean distance between the returned corners.
253 :param 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.
255 :param blockSize: Size of an average block for computing a derivative covariation matrix over each pixel neighborhood. See :ocv:func:`cornerEigenValsAndVecs` .
257 :param useHarrisDetector: Parameter indicating whether to use a Harris detector (see :ocv:func:`cornerHarris`) or :ocv:func:`cornerMinEigenVal`.
259 :param k: Free parameter of the Harris detector.
261 The function finds the most prominent corners in the image or in the specified image region, as described in [Shi94]_:
264 Function calculates the corner quality measure at every source image pixel using the
265 :ocv:func:`cornerMinEigenVal` or
266 :ocv:func:`cornerHarris` .
269 Function performs a non-maximum suppression (the local maximums in *3 x 3* neighborhood are retained).
272 The corners with the minimal eigenvalue less than
273 :math:`\texttt{qualityLevel} \cdot \max_{x,y} qualityMeasureMap(x,y)` are rejected.
276 The remaining corners are sorted by the quality measure in the descending order.
279 Function throws away each corner for which there is a stronger corner at a distance less than ``maxDistance``.
281 The function can be used to initialize a point-based tracker of an object.
283 .. 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`` .
287 :ocv:func:`cornerMinEigenVal`,
288 :ocv:func:`cornerHarris`,
289 :ocv:func:`calcOpticalFlowPyrLK`,
290 :ocv:func:`estimateRigidTransform`,
295 Finds circles in a grayscale image using the Hough transform.
297 .. ocv:function:: void HoughCircles( InputArray image, OutputArray circles, int method, double dp, double minDist, double param1=100, double param2=100, int minRadius=0, int maxRadius=0 )
299 .. ocv:cfunction:: CvSeq* cvHoughCircles( CvArr* image, void* circle_storage, int method, double dp, double min_dist, double param1=100, double param2=100, int min_radius=0, int max_radius=0 )
301 .. ocv:pyfunction:: cv2.HoughCircles(image, method, dp, minDist[, circles[, param1[, param2[, minRadius[, maxRadius]]]]]) -> circles
303 :param image: 8-bit, single-channel, grayscale input image.
305 :param circles: Output vector of found circles. Each vector is encoded as a 3-element floating-point vector :math:`(x, y, radius)` .
307 :param circle_storage: In C function this is a memory storage that will contain the output sequence of found circles.
309 :param method: Detection method to use. Currently, the only implemented method is ``CV_HOUGH_GRADIENT`` , which is basically *21HT* , described in [Yuen90]_.
311 :param 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.
313 :param 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.
315 :param param1: First method-specific parameter. In case of ``CV_HOUGH_GRADIENT`` , it is the higher threshold of the two passed to the :ocv:func:`Canny` edge detector (the lower one is twice smaller).
317 :param param2: Second method-specific parameter. In case of ``CV_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.
319 :param minRadius: Minimum circle radius.
321 :param maxRadius: Maximum circle radius.
323 The function finds circles in a grayscale image using a modification of the Hough transform.
333 int main(int argc, char** argv)
336 if( argc != 2 && !(img=imread(argv[1], 1)).data)
338 cvtColor(img, gray, CV_BGR2GRAY);
339 // smooth it, otherwise a lot of false circles may be detected
340 GaussianBlur( gray, gray, Size(9, 9), 2, 2 );
341 vector<Vec3f> circles;
342 HoughCircles(gray, circles, CV_HOUGH_GRADIENT,
343 2, gray->rows/4, 200, 100 );
344 for( size_t i = 0; i < circles.size(); i++ )
346 Point center(cvRound(circles[i][0]), cvRound(circles[i][1]));
347 int radius = cvRound(circles[i][2]);
348 // draw the circle center
349 circle( img, center, 3, Scalar(0,255,0), -1, 8, 0 );
350 // draw the circle outline
351 circle( img, center, radius, Scalar(0,0,255), 3, 8, 0 );
353 namedWindow( "circles", 1 );
354 imshow( "circles", img );
358 .. 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, you may ignore the returned radius, use only the center, and find the correct radius using an additional procedure.
362 :ocv:func:`fitEllipse`,
363 :ocv:func:`minEnclosingCircle`
367 * An example using the Hough circle detector can be found at opencv_source_code/samples/cpp/houghcircles.cpp
371 Finds lines in a binary image using the standard Hough transform.
373 .. ocv:function:: void HoughLines( InputArray image, OutputArray lines, double rho, double theta, int threshold, double srn=0, double stn=0 )
375 .. ocv:pyfunction:: cv2.HoughLines(image, rho, theta, threshold[, lines[, srn[, stn]]]) -> lines
377 .. ocv:cfunction:: CvSeq* cvHoughLines2( CvArr* image, void* line_storage, int method, double rho, double theta, int threshold, double param1=0, double param2=0 )
379 .. ocv:pyoldfunction:: cv.HoughLines2(image, storage, method, rho, theta, threshold, param1=0, param2=0)-> lines
381 :param image: 8-bit, single-channel binary source image. The image may be modified by the function.
383 :param lines: Output vector of lines. Each line is represented by a two-element vector :math:`(\rho, \theta)` . :math:`\rho` is the distance from the coordinate origin :math:`(0,0)` (top-left corner of the image). :math:`\theta` is the line rotation angle in radians ( :math:`0 \sim \textrm{vertical line}, \pi/2 \sim \textrm{horizontal line}` ).
385 :param rho: Distance resolution of the accumulator in pixels.
387 :param theta: Angle resolution of the accumulator in radians.
389 :param threshold: Accumulator threshold parameter. Only those lines are returned that get enough votes ( :math:`>\texttt{threshold}` ).
391 :param 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.
393 :param stn: For the multi-scale Hough transform, it is a divisor for the distance resolution ``theta``.
395 :param method: One of the following Hough transform variants:
397 * **CV_HOUGH_STANDARD** classical or standard Hough transform. Every line is represented by two floating-point numbers :math:`(\rho, \theta)` , where :math:`\rho` is a distance between (0,0) point and the line, and :math:`\theta` is the angle between x-axis and the normal to the line. Thus, the matrix must be (the created sequence will be) of ``CV_32FC2`` type
400 * **CV_HOUGH_PROBABILISTIC** probabilistic Hough transform (more efficient in case if the picture contains a few long linear segments). It returns line segments rather than the whole line. Each segment is represented by starting and ending points, and the matrix must be (the created sequence will be) of the ``CV_32SC4`` type.
402 * **CV_HOUGH_MULTI_SCALE** multi-scale variant of the classical Hough transform. The lines are encoded the same way as ``CV_HOUGH_STANDARD``.
405 :param param1: First method-dependent parameter:
407 * For the classical Hough transform, it is not used (0).
409 * For the probabilistic Hough transform, it is the minimum line length.
411 * For the multi-scale Hough transform, it is ``srn``.
413 :param param2: Second method-dependent parameter:
415 * For the classical Hough transform, it is not used (0).
417 * For the probabilistic Hough transform, it is the maximum gap between line segments lying on the same line to treat them as a single line segment (that is, to join them).
419 * For the multi-scale Hough transform, it is ``stn``.
421 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.
422 See also the example in :ocv:func:`HoughLinesP` description.
426 * An example using the Hough line detector can be found at opencv_source_code/samples/cpp/houghlines.cpp
430 Finds line segments in a binary image using the probabilistic Hough transform.
432 .. ocv:function:: void HoughLinesP( InputArray image, OutputArray lines, double rho, double theta, int threshold, double minLineLength=0, double maxLineGap=0 )
434 .. ocv:pyfunction:: cv2.HoughLinesP(image, rho, theta, threshold[, lines[, minLineLength[, maxLineGap]]]) -> lines
436 :param image: 8-bit, single-channel binary source image. The image may be modified by the function.
438 :param lines: Output vector of lines. Each line is represented by a 4-element vector :math:`(x_1, y_1, x_2, y_2)` , where :math:`(x_1,y_1)` and :math:`(x_2, y_2)` are the ending points of each detected line segment.
440 :param rho: Distance resolution of the accumulator in pixels.
442 :param theta: Angle resolution of the accumulator in radians.
444 :param threshold: Accumulator threshold parameter. Only those lines are returned that get enough votes ( :math:`>\texttt{threshold}` ).
446 :param minLineLength: Minimum line length. Line segments shorter than that are rejected.
448 :param maxLineGap: Maximum allowed gap between points on the same line to link them.
450 The function implements the probabilistic Hough transform algorithm for line detection, described in
451 [Matas00]_. See the line detection example below: ::
453 /* This is a standalone program. Pass an image name as the first parameter
454 of the program. Switch between standard and probabilistic Hough transform
455 by changing "#if 1" to "#if 0" and back */
462 int main(int argc, char** argv)
464 Mat src, dst, color_dst;
465 if( argc != 2 || !(src=imread(argv[1], 0)).data)
468 Canny( src, dst, 50, 200, 3 );
469 cvtColor( dst, color_dst, CV_GRAY2BGR );
473 HoughLines( dst, lines, 1, CV_PI/180, 100 );
475 for( size_t i = 0; i < lines.size(); i++ )
477 float rho = lines[i][0];
478 float theta = lines[i][1];
479 double a = cos(theta), b = sin(theta);
480 double x0 = a*rho, y0 = b*rho;
481 Point pt1(cvRound(x0 + 1000*(-b)),
482 cvRound(y0 + 1000*(a)));
483 Point pt2(cvRound(x0 - 1000*(-b)),
484 cvRound(y0 - 1000*(a)));
485 line( color_dst, pt1, pt2, Scalar(0,0,255), 3, 8 );
489 HoughLinesP( dst, lines, 1, CV_PI/180, 80, 30, 10 );
490 for( size_t i = 0; i < lines.size(); i++ )
492 line( color_dst, Point(lines[i][0], lines[i][1]),
493 Point(lines[i][2], lines[i][3]), Scalar(0,0,255), 3, 8 );
496 namedWindow( "Source", 1 );
497 imshow( "Source", src );
499 namedWindow( "Detected Lines", 1 );
500 imshow( "Detected Lines", color_dst );
506 This is a sample picture the function parameters have been tuned for:
508 .. image:: pics/building.jpg
510 And this is the output of the above program in case of the probabilistic Hough transform:
512 .. image:: pics/houghp.png
518 Calculates a feature map for corner detection.
520 .. ocv:function:: void preCornerDetect( InputArray src, OutputArray dst, int ksize, int borderType=BORDER_DEFAULT )
522 .. ocv:pyfunction:: cv2.preCornerDetect(src, ksize[, dst[, borderType]]) -> dst
524 .. ocv:cfunction:: void cvPreCornerDetect( const CvArr* image, CvArr* corners, int aperture_size=3 )
526 .. ocv:pyoldfunction:: cv.PreCornerDetect(image, corners, apertureSize=3)-> None
528 :param src: Source single-channel 8-bit of floating-point image.
530 :param dst: Output image that has the type ``CV_32F`` and the same size as ``src`` .
532 :param ksize: Aperture size of the :ocv:func:`Sobel` .
534 :param borderType: Pixel extrapolation method. See :ocv:func:`borderInterpolate` .
536 The function calculates the complex spatial derivative-based function of the source image
540 \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}
543 :math:`D_x`,:math:`D_y` are the first image derivatives,
544 :math:`D_{xx}`,:math:`D_{yy}` are the second image derivatives, and
545 :math:`D_{xy}` is the mixed derivative.
547 The corners can be found as local maximums of the functions, as shown below: ::
549 Mat corners, dilated_corners;
550 preCornerDetect(image, corners, 3);
551 // dilation with 3x3 rectangular structuring element
552 dilate(corners, dilated_corners, Mat(), 1);
553 Mat corner_mask = corners == dilated_corners;
555 .. [Canny86] J. Canny. *A Computational Approach to Edge Detection*, IEEE Trans. on Pattern Analysis and Machine Intelligence, 8(6), pp. 679-698 (1986).
557 .. [Matas00] Matas, J. and Galambos, C. and Kittler, J.V., *Robust Detection of Lines Using the Progressive Probabilistic Hough Transform*. CVIU 78 1, pp 119-137 (2000)
559 .. [Shi94] J. Shi and C. Tomasi. *Good Features to Track*. Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pages 593-600, June 1994.
561 .. [Yuen90] Yuen, H. K. and Princen, J. and Illingworth, J. and Kittler, J., *Comparative study of Hough transform methods for circle finding*. Image Vision Comput. 8 1, pp 71–77 (1990)