Main Content

corner

(Not recommended) Find corner points in image

corner is not recommended. Use detectHarrisFeatures (Computer Vision Toolbox) or detectMinEigenFeatures (Computer Vision Toolbox) in Computer Vision Toolbox™ instead.

Description

C = corner(I) detects corners in image I and returns their coordinates in matrix C.

C = corner(I,method) detects corners in image I using the specified method.

C = corner(I,N) detects corners in image I and returns a maximum of N corners.

C = corner(I,method,N) detects corners using the specified method and maximum number of corners.

example

C = corner(___,Name,Value) specifies parameters and corresponding values that control various aspects of the corner detection algorithm.

Examples

collapse all

This example shows how to locate corners with the corner function and adjust your results by refining the maximum number of desired corners.

Create a checkerboard image.

I = checkerboard(40,2,2);

Find the corners in the image.

C = corner(I);

Display the corners when the maximum number of desired corners is the default setting of 200.

subplot(1,2,1);
imshow(I);
hold on
plot(C(:,1), C(:,2), '*', 'Color', 'c')
title('Maximum Corners = 200')
hold off

Display the corners when the maximum number of desired corners is 3.

corners_max_specified = corner(I,3);
subplot(1,2,2);
imshow(I);
hold on
plot(corners_max_specified(:,1), corners_max_specified(:,2), ...
   '*', 'Color', 'm')
title('Maximum Corners = 3')
hold off

Input Arguments

collapse all

Grayscale or binary image, specified as an m-by-n numeric matrix.

Corner detection method, specified as 'Harris' for the Harris corner detector, or 'MinimumEigenvalue' for Shi & Tomasi's minimum eigenvalue method.

Maximum number of corners that the corner function can return, specified as a positive integer.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: corner(I,'QualityLevel',0.2) specifies the minimum quality level of corners in image I as 0.2.

Filter coefficients for the separable smoothing filter, specified as the comma-separated pair consisting of 'FilterCoefficients' and a numeric vector. The vector, V, must have odd length and a minimum length of 3. The outer product, V*V', gives the full filter kernel. The default filter coefficients are given by fspecial('gaussian',[5 1],1.5).

Minimum accepted quality of corners, specified as the comma-separated pair consisting of 'QualityLevel' and a numeric scalar in the range (0, 1). For a quality level Q, the toolbox rejects candidate corners with corner metric values less than Q * max(corner metric). Use larger values of Q to remove erroneous corners.

Sensitivity factor used in the Harris detection algorithm, specified as the comma-separated pair consisting of 'SensitivityFactor' and a numeric scalar in the range (0, 0.25). The smaller the sensitivity factor, the more likely the algorithm is to detect sharp corners. Use this parameter with the 'Harris' method only.

Output Arguments

collapse all

x and y coordinates of the corner points detected in image I, returned as a p-by-2 matrix.

Data Types: double

Tips

The corner and cornermetric functions both detect corners in images. For most applications, use the streamlined corner function to find corners in one step. If you want greater control over corner selection, use the cornermetric function to compute a corner metric matrix and then write your own algorithm to find peak values.

Algorithms

The corner function performs nonmaxima suppression on candidate corners, and corners are at least two pixels apart.

Version History

Introduced in R2010b

See Also

| (Computer Vision Toolbox) | (Computer Vision Toolbox)