-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.m
50 lines (43 loc) · 1.11 KB
/
test.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
clear all;
close all;
img2=imread('PropsImg\ShapesSimple\3star1.png');
img3=imread('PropsImg\ShapesSimple\5star1.png');
img4=imread('PropsImg\ShapesSimple\6star1.png');
bn2=im2bw(img2);
bn3=im2bw(img3);
bn4=im2bw(img4);
[L2, Ne2]=bwlabel(bn2);
[L3, Ne3]=bwlabel(bn3);
[L4, Ne4]=bwlabel(bn4);
prop2=regionprops(L2,'all');
prop3=regionprops(L3,'all');
prop4=regionprops(L4,'all');
same = 0;
for i = 1:8
x=prop4.Extrema(i,1);
y=prop4.Extrema(i,2);
for j = 1+i:8
minX = x - prop4.Extrema(j,1);
minY = y - prop4.Extrema(j,2);
if((minX>=-2 && minX<=2) && (minY>=-2 && minY<=2))
else
same = same + 1;
end
end
end
same
%
% img=imread('PropsImg\Ex\Shapes1bit.png');
% bn=im2bw(img);
% [L, Ne]=bwlabel(bn);
% prop=regionprops(L,'all');
% imshow(bn);
%
%
% for k=1:length(prop)
% centroid = prop(k).Centroid;
%
% text(centroid(1), centroid(2),string(prop(k).Solidity), ...
% 'HorizontalAlignment', 'center', ...
% 'VerticalAlignment', 'middle', 'color', 'r');
% end