-
Notifications
You must be signed in to change notification settings - Fork 6
/
contour_moments.m
executable file
·62 lines (59 loc) · 1.29 KB
/
contour_moments.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
58
59
60
61
62
function fv_con = contour_moments(F)
% close all
% clear all
% subimage_index =imread('0 (8).png');
% subimage_index1 = imresize(subimage_index,[15 12],'bicubic');
% F=subimage_index1;
F=double(F);
[M,N]=size(F);
[x,y]=meshgrid(1:N,1:M);
x=x(:);
y=y(:);
F=F(:);
m.m00=sum(F);
m.m10=sum(x.*F);
m.m01=sum(y.*F);
m.m10=sum(x.*F);
m.m11=sum(x.*y.*F);
m.m20=sum(x.^2.*F);
m.m02=sum(y.^2.*F);
m.m30=sum(x.^3.*F);
m.m03=sum(y.^3.*F);
m.m12=sum(x.*y.^2.*F);
m.m21=sum(x.^2.*y.*F);
nContour=M*N;
xc=m.m10/m.m00;
yc=m.m01/m.m00;
for n=1:5
for j=1:M
for i=1:N
ed(j,i)=sqrt(power(i-xc,2)+power(j-yc,2));
end
end
end
for n=1:5
sums=0;
for j=1:M
for i=1:N
sums=sums+power(ed(j,i),n);
end
end
rMoment(n)=1/nContour*sums;
end
for n=1:5
sums=0;
for j=1:M
for i=1:N
sums=sums+power(ed(j,i)-rMoment(1),n);
end
end
rCentralMoment(n)=1/nContour*sums;
end
con(1)=power(rCentralMoment(2),0.5)/rMoment(1);
con(2)=rCentralMoment(3)/power(rCentralMoment(2),1.5);
con(3)=rCentralMoment(4)/power(rCentralMoment(2),2);
con(4)=rCentralMoment(5)/power(rCentralMoment(2),2.5);
fv_con=con;
%display(con);
%[fv_con,PS] = mapminmax(con);
%display(fv_con);