#include <string.h>
#include <stdio.h>
#include <math.h>
#include "../common/progress.h"
const float h_sx_kernel[] = { 1, 2, 1,
0, 0, 0,
-1, -2, -1
};
const float h_sy_kernel[] = { -1, 0, 1,
-2, 0, 2,
-1, 0, 1
};
{
}
{
return f * e;
}
{
float mx = max<float>(I1);
float mn = min<float>(I1);
float u0 = 0.9 * mx;
float s0 = (mx - mn) / 2;
float u1 = 1.1 * mn;
float s1 = (mx - mn) / 2;
array L0 = gauss(I1, u0, s0);
array L11 = gauss(I1, u1, s1);
if (k == 0) {
L10 = L11;
} else {
L10 = L11_old;
L11 = L12_old;
}
L12 = gauss(A(
span,
span, k + 1), u1, s1);
} else {
L12 = L11;
}
L11_old = L11;
L12_old = L12;
array L1 = (L10 + L11 + L12) / 3;
}
void brain_seg(bool console)
{
double time_total = 30;
int slices = 256;
int N = 2 * slices - 1;
int iter = 0;
for (
int i = 0; !wnd.
close(); i++) {
iter++;
int j = i % N;
array Si = segment_volume(B, k);
array Ei = edges_slice(Si);
if (!console) {
wnd(0, 0).
image(Bi/255.f,
"Input");
wnd(1, 0).
image(Ei,
"Edges");
wnd(0, 1).
image(Mi/255.f,
"Meanshift");
wnd(1, 1).
image(Si,
"Segmented");
} else {
}
if (!progress(iter, t, time_total))
break;
if (!(i<100*N))
break;
}
}
int main(int argc, char* argv[])
{
int device = argc > 1 ? atoi(argv[1]) : 0;
bool console = argc > 2 ? argv[2][0] == '-' : false;
try {
printf("Brain segmentation example\n");
brain_seg(console);
fprintf(stderr,
"%s\n", e.
what());
}
return 0;
}