This repository has been archived by the owner on Feb 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTexturas.m
174 lines (148 loc) · 3.41 KB
/
Texturas.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
clear all, close all;
zap(:,:,1)=[
255 255 0 255 0 255 0 0;
1 2 3 4 5 6 7 8;
8 7 6 5 4 3 2 1;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
255 255 0 255 0 255 0 0;
];
zap(:,:,2)=[
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
1 2 3 4 5 6 7 8;
255 255 0 255 0 255 0 0;
1 2 3 4 5 6 7 8;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
];
zap(:,:,3)=[
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
0 0 0 0 0 0 0 0;
1 2 3 4 5 6 7 8;
255 255 0 255 0 255 0 0;
];
%%
%f = imread('/Users/gsantiagom/Desktop/1.jpg');
f = zap;
%f = rgb2gray(img1);
[m,n] = size(f);
% construcción de la matriz A
A = zeros(3);
for i=2:1:m %dese j = 2 por lo de la derecha
for j=1:1:n-1 %hasta m-1 porque la ultima fila no se explora (por encima)
val1 = f(i,j);
val2 = f(i-1,j+1); % un pixel por encima y a la derecha del dado
switch val1
case 0
switch val2
case 0
A(1,1) = A(1,1) + 1;
case 1
A(2,1) = A(2,1) + 1;
case 2
A(3,1) = A(3,1) + 1;
end
case 1
switch val2
case 0
A(1,2) = A(1,2) + 1;
case 1
A(2,2) = A(2,2) + 1;
case 2
A(3,2) = A(3,2) + 1;
end
case 2
switch val2
case 0
A(1,3) = A(1,3) + 1;
case 1
A(2,3) = A(2,3) + 1;
case 2
A(3,3) = A(3,3) + 1;
end
end
end
end
c = sum(sum(A));
C = A./c;
% propiedades descriptivas
%%%%%%%%%%%%%%%%%%%%%%%%%%%
pmax = max(max(C));
Energia = sum(sum(C.^2));
k = 3;
[m,n] = size(C);
Momentok = 0; Momentoinvk = 0; Entropia = 0;
Uniformidad = 0; Inercia = 0; HomogLocal = 0;
for i=1:1:m
for j=1:1:n
Momentok = Momentok + (i-j)^k*C(i,j);
Inercia = Inercia + (i-j)^2*C(i,j);
if i ~= j
Momentoinvk = Momentoinvk + C(i,j)/(i-j)^k;
end
if C(i,j) ~= 0
Entropia = Entropia - C(i,j)*log10(C(i,j));
end
Uniformidad = Uniformidad + C(i,j)^2;
HomogLocal = HomogLocal + (1/(1+(i-j)^2))*C(i,j);
end
end
% Correlacion
% calculo de mux
mux = 0;
for i=1:1:m
cx = 0;
for j=1:1:n
cx = cx + C(i,j);
end
mux = mux + i*cx;
end
% calculo de muy
muy = 0;
for j=1:1:n
cy = 0;
for i=1:1:m
cy = cy + C(i,j);
end
muy = muy + j*cy;
end
% calculo de sigmax
sgx = 0;
for i=1:1:m
scx = 0;
for j=1:1:n
scx = scx + C(i,j);
end
sgx = sgx + (i-mux)^2*scx;
end
% calculo de sigmay
sgy = 0;
for j=1:1:n
scy = 0;
for i=1:1:m
scy = scy + C(i,j);
end
sgy = sgy + (j-muy)^2*scy;
end
sgx = sqrt(sgx); sgy = sqrt(sgy);
Correlacion = 0;
for i=1:1:m
for j=1:1:n
Correlacion = Correlacion + (j-mux)*(i-muy)*C(i,j);
end
end
Correlacion = Correlacion/(sgx*sgy);
disp('Probabilidad máxima:'); disp(pmax);
disp('Energía:'); disp(Energia);
disp('Momento directo de orden k:'); disp(Momentok);
disp('Momento inverso de orden k:'); disp(Momentoinvk);
disp('Uniformidad:'); disp(Uniformidad);
disp('Entropía: '); disp(Entropia);
disp('Correlación: '); disp(Correlacion);
disp('Inercia: '); disp(Inercia);
disp('Homogeneidad Local: '); disp(HomogLocal);