cornermetric

Create corner metric matrix from image

Description

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:

ValueDescription
'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:

ParameterDescription
'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.

Examples

expand all

Find Corner Features in Grayscale Image

Read image and use part of it for processing.

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

Generate a corner metric matrix.

C = cornermetric(I);

Adjust the corner metric for viewing.

C_adjusted = imadjust(C);
subplot(1,3,2);
imshow(C_adjusted);
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);
subplot(1,3,3);
imshow(RGB);
title('Corner Points');

More About

expand all

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.

See Also

|

Was this topic helpful?