-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmultigrid_list.m
64 lines (56 loc) · 1.68 KB
/
multigrid_list.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
function [ list ] = multigrid_list( TI, tau, gridlevel)
%MULTIGRID_LIST
%
% TI: Training image (2D or 3D)
% tau: data template
% gridlevel: (integer) (2^n) n = 0,1,2...
%
cat = unique(TI(:))';
num_cat = length(cat);
list = [];
%2D or 3D
switch length(size(TI))
case 2 %2D
tau = tau(:,1:2);
template_length = size(tau,1);
if gridlevel == 1
list = populate_impala_list( TI, tau);
else
for x = 1:gridlevel
for y = 1:gridlevel
list = [list ; populate_impala_list(...
TI(x:gridlevel:end,y:gridlevel:end),tau)];
end
end
end
case 3 %3D
tau = tau(:,1:3);
template_length = size(tau,1);
if gridlevel == 1
list = populate_impala_list( TI, tau);
else
for x = 1:gridlevel
for y = 1:gridlevel
for z = 1:gridlevel
list = [list ; populate_impala_list(...
TI(x:gridlevel:end,y:gridlevel:end,...
z:gridlevel:end),tau)];
end
end
end
end
end
%Find unique patterns
[d,~,Id] = unique(cell2mat(list(:,1)),'rows');
list_length = length(d);
% Create count matrix
C = cell2mat(list(:,2));
%Preallocate final count matrix
c = zeros(list_length, num_cat);
%For each unique pattern
for i = 1:list_length
%Sum counts for each facies
c(i,:) = sum(C(Id == i,:),1);
%Had forgotten ",1) " in sum! :D
end
list = mat2cell([d c],ones(1,list_length),[template_length num_cat]);