MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / segment_volume

Function segment_volume

examples/image_processing/brain_segmentation.cpp:41–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41array segment_volume(array A, int k) {
42 array I1 = A(span, span, k);
43
44 float mx = max<float>(I1);
45 float mn = min<float>(I1);
46
47 float u0 = 0.9 * mx;
48 float s0 = (mx - mn) / 2;
49
50 float u1 = 1.1 * mn;
51 float s1 = (mx - mn) / 2;
52
53 array L0 = gauss(I1, u0, s0);
54 array L11 = gauss(I1, u1, s1);
55 array L10;
56 array L12;
57 static array kernel = constant(1, 3, 3) / 9;
58 static array L11_old;
59 static array L12_old;
60
61 if (k == 0) {
62 L11 = convolve(L11, kernel);
63 L10 = L11;
64 } else {
65 L10 = L11_old;
66 L11 = L12_old;
67 }
68
69 if (k < A.dims(2) - 1) {
70 L12 = gauss(A(span, span, k + 1), u1, s1);
71 L12 = convolve(L12, kernel);
72 } else {
73 L12 = L11;
74 }
75
76 L11_old = L11;
77 L12_old = L12;
78
79 array L1 = (L10 + L11 + L12) / 3;
80 array S = (L0 > L1);
81 return S.as(A.type());
82}
83
84void brain_seg(bool console) {
85 af::Window wnd("Brain Segmentation Demo");

Callers 1

brain_segFunction · 0.85

Calls 6

gaussFunction · 0.85
constantFunction · 0.85
asMethod · 0.80
typeMethod · 0.80
convolveFunction · 0.50
dimsMethod · 0.45

Tested by

no test coverage detected