Implements the Canny algorithm for edge detection.
Parameters: |
---|
The function finds the edges on the input image image and marks them in the output image edges using the Canny algorithm. The smallest value between threshold1 and threshold2 is used for edge linking, the largest value is used to find the initial segments of strong edges.
Calculates eigenvalues and eigenvectors of image blocks for corner detection.
Parameters: |
---|
For every pixel, the function cvCornerEigenValsAndVecs considers a neigborhood S(p). It calcualtes the covariation matrix of derivatives over the neigborhood as:
After that it finds eigenvectors and eigenvalues of the matrix and stores them into destination image in form where
are the eigenvalues of ; not sorted
are the eigenvectors corresponding to
are the eigenvectors corresponding to
Harris edge detector.
Parameters: |
|
---|
The function runs the Harris edge detector on the image. Similarly to CornerMinEigenVal and CornerEigenValsAndVecs , for each pixel it calculates a gradient covariation matrix over a neighborhood. Then, it stores
to the destination image. Corners in the image can be found as the local maxima of the destination image.
Calculates the minimal eigenvalue of gradient matrices for corner detection.
Parameters: |
|
---|
The function is similar to CornerEigenValsAndVecs but it calculates and stores only the minimal eigen value of derivative covariation matrix for every pixel, i.e. in terms of the previous function.
A SURF keypoint, represented as a tuple ((x, y), laplacian, size, dir, hessian) .
- x¶
- x-coordinate of the feature within the image
- y¶
- y-coordinate of the feature within the image
- laplacian¶
- -1, 0 or +1. sign of the laplacian at the point. Can be used to speedup feature comparison since features with laplacians of different signs can not match
- size¶
- size of the feature
- dir¶
- orientation of the feature: 0..360 degrees
- hessian¶
- value of the hessian (can be used to approximately estimate the feature strengths; see also params.hessianThreshold)
Extracts Speeded Up Robust Features from an image.
Parameters: |
|
---|
The function cvExtractSURF finds robust features in the image, as described in [Bay06] . For each feature it returns its location, size, orientation and optionally the descriptor, basic or extended. The function can be used for object tracking and localization, image stitching etc.
To extract strong SURF features from an image
>>> import cv
>>> im = cv.LoadImageM("building.jpg", cv.CV_LOAD_IMAGE_GRAYSCALE)
>>> (keypoints, descriptors) = cv.ExtractSURF(im, None, cv.CreateMemStorage(), (0, 30000, 3, 1))
>>> print len(keypoints), len(descriptors)
6 6
>>> for ((x, y), laplacian, size, dir, hessian) in keypoints:
... print "x=%d y=%d laplacian=%d size=%d dir=%f hessian=%f" % (x, y, laplacian, size, dir, hessian)
x=30 y=27 laplacian=-1 size=31 dir=69.778503 hessian=36979.789062
x=296 y=197 laplacian=1 size=33 dir=111.081039 hessian=31514.349609
x=296 y=266 laplacian=1 size=32 dir=107.092300 hessian=31477.908203
x=254 y=284 laplacian=1 size=31 dir=279.137360 hessian=34169.800781
x=498 y=525 laplacian=-1 size=33 dir=278.006592 hessian=31002.759766
x=777 y=281 laplacian=1 size=70 dir=167.940964 hessian=35538.363281
Refines the corner locations.
Parameters: |
|
---|
The function iterates to find the sub-pixel accurate location of corners, or radial saddle points, as shown in on the picture below. It returns the refined coordinates as a list of (x, y) pairs.
Sub-pixel accurate corner locator is based on the observation that every vector from the center to a point located within a neighborhood of is orthogonal to the image gradient at subject to image and measurement noise. Consider the expression:
where is the image gradient at the one of the points in a neighborhood of . The value of is to be found such that is minimized. A system of equations may be set up with set to zero:
where the gradients are summed within a neighborhood (“search window”) of . Calling the first gradient term and the second gradient term gives:
The algorithm sets the center of the neighborhood window at this new center and then iterates until the center keeps within a set threshold.
Retrieves keypoints using the StarDetector algorithm.
Parameters: |
|
---|
The function GetStarKeypoints extracts keypoints that are local scale-space extremas. The scale-space is constructed by computing approximate values of laplacians with different sigma’s at each pixel. Instead of using pyramids, a popular approach to save computing time, all of the laplacians are computed at each pixel of the original high-resolution image. But each approximate laplacian value is computed in O(1) time regardless of the sigma, thanks to the use of integral images. The algorithm is based on the paper Agrawal08 , but instead of a square, hexagon or octagon it uses an 8-end star shape, hence the name, consisting of overlapping upright and tilted squares.
Each keypoint is represented by a tuple ((x, y), size, response) :
- x, y Screen coordinates of the keypoint
- size feature size, up to maxSize
- response approximated laplacian value for the keypoint
Determines strong corners on an image.
Parameters: |
|
---|
The function finds the corners with big eigenvalues in the image. The function first calculates the minimal eigenvalue for every source image pixel using the CornerMinEigenVal function and stores them in eigImage . Then it performs non-maxima suppression (only the local maxima in neighborhood are retained). The next step rejects the corners with the minimal eigenvalue less than . Finally, the function ensures that the distance between any two corners is not smaller than minDistance . The weaker corners (with a smaller min eigenvalue) that are too close to the stronger corners are rejected.
Note that the if the function is called with different values A and B of the parameter qualityLevel , and A > {B}, the array of returned corners with qualityLevel=A will be the prefix of the output corners array with qualityLevel=B .
Finds lines in a binary image using a Hough transform.
Parameters: |
|
---|
The function implements a few variants of the Hough transform for line detection.
Calculates the feature map for corner detection.
Parameters: |
---|
The function calculates the function
where denotes one of the first image derivatives and denotes a second image derivative.
The corners can be found as local maximums of the function below:
import cv
def precornerdetect(image):
# assume that the image is floating-point
corners = cv.CloneMat(image)
cv.PreCornerDetect(image, corners, 3)
dilated_corners = cv.CloneMat(image)
cv.Dilate(corners, dilated_corners, None, 1)
corner_mask = cv.CreateMat(image.rows, image.cols, cv.CV_8UC1)
cv.Sub(corners, dilated_corners, corners)
cv.CmpS(corners, 0, corner_mask, cv.CV_CMP_GE)
return (corners, corner_mask)