www.gusucode.com > vision 源码程序 matlab案例代码 > vision/DetectCornersinanInputImageExample.m

    %% 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');