MatLab: detect angles in a binary image

I am trying to find a way to find corner points on this binary image in MatLab

Binary image

I am trying to find a way to set a triangle over this image and find the vertices. I tried to find the angles, but the return values ​​are not always correct.
Is there a way I can sharpen my edges so that the angle function can return better results?

I appreciate any input! Thank!

enter image description here

Which strategy seems simpler and more efficient? What existing MatLab features can I use?

+4
source share
2 answers

.

- 2D- , ( ), .

,

img=imread('http://i.stack.imgur.com/DL2Cq.png'); %// read the image
bw = img(:,:,1) > 128;  %// convert to binary mask
[y x] = find(bw);  %// get the x-y coordinates of white pixels
n=numel(x);  %// how many do we have

- :

mm = mean([x y],1); 
mA = bsxfun(@minus, [x y], mm);

, (x, y), L(1)*x + L(2)*y = 1. , , (x,y) : L(1)*x + L(2)*y <= 1. L, , quadprog:

L1 = quadprog(eye(2), -ones(2,1), mA, ones(n,1));
L2 = quadprog(eye(2), ones(2,1), mA, ones(n,1));
L3 = quadprog(eye(2), [1; -1], mA, ones(n,1));  

, , f, , .

, ( mm):

x12=inv([L1';L2'])*ones(2,1)+mm';
x23=inv([L3';L2'])*ones(2,1)+mm';
x13=inv([L3';L1'])*ones(2,1)+mm';

imshow(bw,'border','tight'); 
hold all; 
%// plot the lines
ezplot(gca, @(x,y) L1(1)*(x-mm(1))+L1(2)*(y-mm(2))-1, [1 340 1 352]);
ezplot(gca, @(x,y) L2(1)*(x-mm(1))+L2(2)*(y-mm(2))-1, [1 340 1 352]);
ezplot(gca, @(x,y) L3(1)*(x-mm(1))+L3(2)*(y-mm(2))-1, [1 340 1 352]);
%// plot the intersection points
scatter([x12(1) x23(1) x13(1)],[x12(2) x23(2) x13(2)],50,'+r');

enter image description here

+2

.

blob.

, , .

enter image description here

0

All Articles