This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Create corner metric matrix from image

cornermetric is not recommended. Use detectHarrisFeatures or detectMinEigenFeatures and the cornerPoints class in Computer Vision System Toolbox™ instead.


C = cornermetric(I) generates a corner metric matrix for the grayscale or logical image I. The corner metric, C, is used to detect corner features in I and is the same size as I. Larger values in C correspond to pixels in I with a higher likelihood of being a corner feature.

C = cornermetric(I, method) generates a corner metric matrix for the grayscale or logical image I using the specified method. Valid values for method are:

'Harris'The Harris corner detector. This is the default method.
'MinimumEigenvalue'Shi and Tomasi's minimum eigenvalue method.

C = cornermetric(..., param1, val1, param2, val2, ...) generates a corner metric matrix for I, specifying parameters and corresponding values that control various aspects of the corner metric calculation algorithm. Parameters include:

'FilterCoefficients' A vector, V, of filter coefficients for the separable smoothing filter. This parameter is valid with the 'Harris' and 'MinimumEigenvalue' methods. The outer product, V*V', gives the full filter kernel. The length of the vector must be odd and at least 3. The default is fspecial('gaussian',[5 1],1.5).
'SensitivityFactor' A scalar k, 0 < k < 0.25, specifying the sensitivity factor used in the Harris detection algorithm. For smaller values of k, the algorithm is more likely to detect sharper corners. This parameter is only valid with the 'Harris' method.
Default value: 0.04

Class Support

I is a nonsparse numeric array. C is a matrix of class double.


collapse all

Read image and use part of it for processing.

I = imread('pout.tif');
I = I(1:150,1:120);
title('Original Image');

Generate a corner metric matrix.

C = cornermetric(I);

Adjust the corner metric for viewing.

C_adjusted = imadjust(C);
title('Corner Metric');

Find and display corner features.

corner_peaks = imregionalmax(C);
corner_idx = find(corner_peaks == true);
[r g b] = deal(I);
r(corner_idx) = 255;
g(corner_idx) = 255;
b(corner_idx) = 0;
RGB = cat(3,r,g,b);
title('Corner Points');

More About

collapse all


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.

See Also

Introduced in R2008b

Was this topic helpful?