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

Function brain_seg

examples/image_processing/brain_segmentation.cpp:84–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82}
83
84void brain_seg(bool console) {
85 af::Window wnd("Brain Segmentation Demo");
86 wnd.setColorMap(AF_COLORMAP_HEAT);
87
88 double time_total = 30; // run for N seconds
89
90 array B = loadImage(ASSETS_DIR "/examples/images/brain.png");
91 int slices = 256;
92
93 B = moddims(B, dim4(B.dims(0), B.dims(1) / slices, slices));
94 af::sync();
95
96 int N = 2 * slices - 1;
97
98 timer t = timer::start();
99 int iter = 0;
100
101 /* loop forward and backward for 100 frames
102 * exit if the user presses escape or the animation
103 * ends
104 */
105 for (int i = 0; !wnd.close(); i++) {
106 iter++;
107
108 int j = i % N;
109 int k = std::min(j, N - j);
110 array Bi = B(span, span, k);
111
112 /* process */
113 array Si = segment_volume(B, k);
114 array Ei = edges_slice(Si);
115 array Mi = meanShift(Bi, 10, 10, 5);
116
117 /* visualization */
118 if (!console) {
119 wnd.grid(2, 2);
120
121 wnd(0, 0).image(Bi / 255.f, "Input");
122 wnd(1, 0).image(Ei, "Edges");
123 wnd(0, 1).image(Mi / 255.f, "Meanshift");
124 wnd(1, 1).image(Si, "Segmented");
125
126 wnd.show();
127 } else {
128 /* sync the operations so that current
129 * iteration comptation finishes
130 * */
131 af::sync();
132 }
133
134 /* we have had ran throuh simlation results
135 * exit the rendering loop */
136 if (!progress(iter, t, time_total)) break;
137 if (!(i < 100 * N)) break;
138 }
139}
140
141int main(int argc, char* argv[]) {

Callers 1

mainFunction · 0.85

Calls 15

loadImageFunction · 0.85
moddimsFunction · 0.85
segment_volumeFunction · 0.85
edges_sliceFunction · 0.85
progressFunction · 0.85
setColorMapMethod · 0.80
closeMethod · 0.80
gridMethod · 0.80
imageMethod · 0.80
showMethod · 0.80
dim4Class · 0.50
syncFunction · 0.50

Tested by

no test coverage detected