Download this file

62 lines (53 with data), 2.2 kB

 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
%% Quantification of Trabeculae Inside the Heart from MRI Using Fractal Analysis
%% This code is written by-
%Md. Kamrul Hasan, M1 MAIA
%Md. Fakrul Islam Tushar, M1 MAIA
%%
function c=boxdiv3(c,p)
siz = length(c);
if siz==1
c=true;
else
siz2 = round(siz/2);
% sub-cube top-left front
c(1:siz2,1:siz2,1:siz2) = c(1:siz2,1:siz2,1:siz2) & (rand<p);
if c(1,1,1)
c(1:siz2,1:siz2,1:siz2) = boxdiv3(c(1:siz2,1:siz2,1:siz2),p);
end
% sub-cube top-right front
c((1+siz2):siz,1:siz2,1:siz2) = c((1+siz2):siz,1:siz2,1:siz2) & (rand<p);
if c(1+siz2,1,1)
c((1+siz2):siz,1:siz2,1:siz2) = boxdiv3(c((1+siz2):siz,1:siz2,1:siz2),p);
end
% sub-cube bottom-left front
c(1:siz2,(1+siz2):siz,1:siz2) = c(1:siz2,(1+siz2):siz,1:siz2) & (rand<p);
if c(1,1+siz2,1)
c(1:siz2,(1+siz2):siz,1:siz2) = boxdiv3(c(1:siz2,(1+siz2):siz,1:siz2),p);
end
% sub-cube bottom-right front
c((1+siz2):siz,(1+siz2):siz,1:siz2) = c((1+siz2):siz,(1+siz2):siz,1:siz2) & (rand<p);
if c(1+siz2,1+siz2,1)
c((1+siz2):siz,(1+siz2):siz,1:siz2) = boxdiv3(c((1+siz2):siz,(1+siz2):siz,1:siz2),p);
end
% sub-cube top-left bottom
c(1:siz2,1:siz2,(1+siz2):siz) = c(1:siz2,1:siz2,(1+siz2):siz) & (rand<p);
if c(1,1,1+siz2)
c(1:siz2,1:siz2,(1+siz2):siz) = boxdiv3(c(1:siz2,1:siz2,(1+siz2):siz),p);
end
% sub-cube top-right bottom
c((1+siz2):siz,1:siz2,(1+siz2):siz) = c((1+siz2):siz,1:siz2,(1+siz2):siz) & (rand<p);
if c(1+siz2,1,1+siz2)
c((1+siz2):siz,1:siz2,(1+siz2):siz) = boxdiv3(c((1+siz2):siz,1:siz2,(1+siz2):siz),p);
end
% sub-cube bottom-left bottom
c(1:siz2,(1+siz2):siz,(1+siz2):siz) = c(1:siz2,(1+siz2):siz,(1+siz2):siz) & (rand<p);
if c(1,1+siz2,1+siz2)
c(1:siz2,(1+siz2):siz,(1+siz2):siz) = boxdiv3(c(1:siz2,(1+siz2):siz,(1+siz2):siz),p);
end
% sub-cube bottom-right bottom
c((1+siz2):siz,(1+siz2):siz,(1+siz2):siz) = c((1+siz2):siz,(1+siz2):siz,(1+siz2):siz) & (rand<p);
if c(1+siz2,1+siz2,1+siz2)
c((1+siz2):siz,(1+siz2):siz,(1+siz2):siz) = boxdiv3(c((1+siz2):siz,(1+siz2):siz,(1+siz2):siz),p);
end
end
%% END