There is a function called corner that works very well, given the correct input parameters.
For example, setting the appropriate QualityLevel yields accurate results:
clear clc A = imread('Octagon.jpg'); A_gray = rgb2gray(A); figure; Ca = corner(A_gray,'QualityLevel',.2)
The coordinates ar are stored in Ca as an N x 2 matrix. Here N = 8.
imshow(A) hold on scatter(Ca(:,1),Ca(:,2),80,'filled','k') hold off B = imread('Pentagon.jpg'); B_gray = rgb2gray(B); figure; Cb = corner(B_gray,'QualityLevel',.2) imshow(B) hold on scatter(Cb(:,1),Cb(:,2),80,'filled','k') hold off
Outputs:

and

Yay
source share