-
Notifications
You must be signed in to change notification settings - Fork 0
/
m5.m
58 lines (47 loc) · 1.31 KB
/
m5.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
51
52
53
54
55
56
57
[Is,Ib] = ImageSegmentation(Ip);
Ig = rgb2gray(Is);
Ib = Ib(:,:,1);
Ib = RemoveExtraComp(Ib);
B = GreatestBoundary(Ib);
Ig(Ib == 0) = 0;
stats = regionprops(Ib,Ig,'MajorAxisLength','MinorAxisLength','Orientation',...
'Centroid','Solidity','ConvexArea', 'Extent','Perimeter','Area','MaxIntensity',...
'MinIntensity','MeanIntensity','WeightedCentroid');
C = stats.Centroid;
WC = stats.WeightedCentroid;
Dist = sqrt(sum(((WC - C).^2),2))
imshow(Is);
hold on;
plot(B(:,2),B(:,1),'r');
hold on;
plot(C(1,1),C(1,2),'g+','MarkerSize',30);
hold on;
plot(WC(1,1),WC(1,2),'c+','MarkerSize',35);
D = B-C;
D = D.^2;
D = sum(D,2);
D = sqrt(D);
F = fft(D);
F(1);
X = [F(1)];
MajorAxis = stats.MajorAxisLength;
MinorAxis = stats.MinorAxisLength;
Aspect = MajorAxis/MinorAxis;
X = [MajorAxis MinorAxis Aspect X];
%8. Extent
ExtentI = stats.Extent;
X = [ExtentI X];
%9.Convex Area
ConvexAreaI = stats.ConvexArea;
X = [ConvexAreaI X];
%10. Solidity
SolidityI = stats.Solidity;
X = [SolidityI X];
PerimeterI = stats.Perimeter;
AreaI = stats.Area;
%11. Roundness
RoundnessI = 4*pi*AreaI/(PerimeterI^2);
X = [RoundnessI X];
%12. Compactness
CompactnessI = sqrt(4*AreaI/pi)/MajorAxis;
X = [CompactnessI X];