I have a binary image that represents a 'rectangle'. The rectangle is not perfect because a top view of the box was taken (then converted to a binary image). My objective is to find four corner points of the black rectangle. In order for the corner function to work the edges must be completely straight.
clc; clear;image = imread('0148pm.jpg');g = rgb2gray(image)level = graythresh(g);binary = im2bw(image,level);imwrite(binary,'imageBinary.jpg');% Iinv = ~binary; %Invert your binary image
% Iinv = bwareaopen(Iinv,20); %Get rid of small areas (below your size criterion)
% I = ~Inv; %Invert back
imshow(I);% fill = bwmorph(binary,'hbreak');
%
% f = bwmorph(fill,'majority');
% % k = bwmorph(f,'close');
%corner algorithm///////////////////////////////////////////////////
% C = corner(k,'MinimumEigenvalue', 4)
% imtool(k);
% hold on
% plot(C(:,1), C(:,2), 'r*');
%end corner algorithm///////////////////////////////////////////////
Best Answer