vision.CornerDetector System object

Package: vision

Detect corner features

Description

The corner detector object finds corners in a grayscale image. It returns corner locations as a matrix of [x y] coordinates. The object finds corners in an image using the Harris corner detection (by Harris & Stephens), minimum eigenvalue (by Shi & Tomasi), or local intensity comparison (Features from Accelerated Segment Test, FAST by Rosten & Drummond) method.

Construction

cornerDetector = vision.CornerDetector returns a corner detector object, cornerDetector, that finds corners in an image using a Harris corner detector.

cornerDetector = vision.CornerDetector(Name,Value) configures the corner detector object properties. You specify these properties as one or more name-value pair arguments. Unspecified properties have default values.

To detect corners:

  1. Define and set up your corner detector using the constructor.

  2. Call the step method with the input image, I, the corner detector object, cornerDetector, and any optional properties. See the syntax below for using the step method.

LOC = step(cornerDetector,I) returns corners in the grayscale input image I. The step method outputs the location of detected corners, specified as an M-by-2 matrix of [x y] coordinates, where M is the number of detected corners. M can be less than or equal to the value specified by the MaximumCornerCount property.

METRIC = step(cornerDetector,I) returns a matrix, METRIC, with corner metric values. This applies when you set the MetricMatrixOutputPort property to true. The output, METRIC, represents corner strength. The size of the METRIC matrix is the same as that of the input image.

[LOC,METRIC] = step(cornerDetector,I) returns the locations of the corners in the M-by-2 matrix, LOC, and the corner metric matrix in METRIC. This applies when you set both the CornerLocationOutputPort and MetricMatrixOutputPort properties to true.

Properties

Method

Method to find corner values

Specify the method to find the corner values. Specify as one of Harris corner detection (Harris & Stephens) | Minimum eigenvalue (Shi & Tomasi) | Local intensity comparison (Rosten & Drummond).

Default: Harris corner detection (Harris & Stephens)

Sensitivity

Harris corner sensitivity factor

Specify the sensitivity factor, k, used in the Harris corner detection algorithm as a scalar numeric value such that 0 < k < 0.25. The smaller the value of k, the more likely the algorithm will detect sharp corners. This property only applies when you set the Method property to Harris corner detection (Harris & Stephens). This property is tunable.

Default: 0.04

SmoothingFilterCoefficients

Smoothing filter coefficients

Specify the filter coefficients for the separable smoothing filter as a real-valued numeric vector. The vector must have an odd number of elements and a length of at least 3. For more information, see fspecial. This property applies only when you set the Method property to either Harris corner detection (Harris & Stephens) or Minimum eigenvalue (Shi & Tomasi).

Default: Output of fspecial('gaussian',[1 5],1.5)

IntensityThreshold

Intensity comparison threshold

Specify a positive scalar value. The object uses the intensity threshold to find valid bright or dark surrounding pixels. This property applies only when you set the Method property to Local intensity comparison (Rosten & Drummond). This property is tunable.

Default: 0.1

MaximumAngleThreshold

Maximum angle in degrees for valid corner

Specify the maximum angle in degrees to indicate a corner as one of 22.5 | 45.0 | 67.5 | 90.0 | 112.5 | 135.0 | 157.5. This property only applies when you set the Method property to Local intensity comparison (Rosten & Drummond). This property is tunable.

Default: 157.5

CornerLocationOutputPort

Enable output of corner location

Set this property to true to output the corner location after corner detection. This property and the MetricMatrixOutputPort property cannot both be set to false.

Default: true

MetricMatrixOutputPort

Enable output of corner metric matrix

Set this property to true to output the metric matrix after corner detection. This property and the CornerLocationOutputPort property cannot both be set to false.

Default: false

MaximumCornerCount

Maximum number of corners to detect

Specify the maximum number of corners to detect as a positive scalar integer value. This property only applies when you set the CornerLocationOutputPort property to true.

Default: 200

CornerThreshold

Minimum metric value to indicate a corner

Specify a positive scalar number for the minimum metric value that indicates a corner. This property applies only when you set the CornerLocationOutputPort property to true. This property is tunable.

Default: 0.0005

NeighborhoodSize

Size of suppressed region around detected corner

Specify the size of the neighborhood around the corner metric value over which the object zeros out the values. The neighborhood size is a two element vector of positive odd integers, [r c]. Here, r indicates the number of rows in the neighborhood, and c indicates the number of columns. This property only applies when you set the CornerLocationOutputPort property to true.

Default: [11 11]

 Fixed-Point Properties

Methods

cloneCreate corner detector with same property values
getNumInputsNumber of expected inputs to step method
getNumOutputsNumber of outputs from step method
isLockedLocked status for input attributes and nontunable properties
release Allow property value and input characteristics changes
stepDetect corners in input image

Examples

expand all

Detect Corners in an Input Image

Detect corners in an input image using the FAST algorithm.

Read the input image.

I = im2single(imread('circuit.tif'));

Select FAST algorithm by Rosten & Drummond.

cornerDetector = vision.CornerDetector('Method','Local intensity comparison (Rosten & Drummond)');

Find corners

pts = step(cornerDetector, I);

Create the markers. The color data range must match the data range of the input image. The color format for the marker is [red, green, blue].

color = [1 0 0];
drawMarkers = vision.MarkerInserter('Shape', 'Circle', 'BorderColor', 'Custom', 'CustomBorderColor', color);

Convert the grayscale input image I to an RGB image J before inserting color markers.

J = repmat(I,[1 1 3]);

Display the image with markers

J = step(drawMarkers, J, pts);
imshow(J); title ('Corners detected in a grayscale image'); 
Was this topic helpful?