Hi Mobeen
I calculated the grad mag(its are right, I finish check it) by central difference,
Vector3 sample1, sample2; //typedef vector (x,y,z)
for (int z = 0; z < dim[Z]; z++) {
for (int y = 0; y < dim[Y]; y++) {
for (int x = 0; x < dim[X]; x++) {
sample1.x = SampleVol8(data, x - 1, y, z);
sample2.x = SampleVol8(data, x + 1, y, z);
sample1.y = SampleVol8(data, x, y - 1, z);
sample2.y = SampleVol8(data, x, y + 1, z);
sample1.z = SampleVol8(data, x, y, z - 1);
sample2.z = SampleVol8(data, x, y, z + 1);
vec = vec_sub(sample2, sample1); //difference
vec = vec_mul(0.5, vec); //div by 2.0
gradMag[index] = vec_mag(vec); //magnitud
index++;
}
}
}
but I, at the moment, don’t perform any compute of histogram (simply, i just plot scalar versus grad mag), the result was the plot that I send.
for (int z = 0; z < dim[Z]; z++) {
for (int y = 0; y < dim[Y]; y++) {
for (int x = 0; x < dim[X]; x++) {
//histogram graphics
posx = data[x + (y * dim[X]) + (z *dim[X]
* dim[Y])];
posy = gradMag[index];
glBegin(GL_POINTS);
glColor3f(0.5, 0.5, 0.5);
glVertex3f( posx, posy, 0.0f);
glEnd();
index++;
}
}
}
Now, I am thinking how to “increment” it, as you said. What will be the axis X, will be the scalar data ? and the axis y will be frequency of grad mag ? i’m sorry, don’t understand it. By instance, a scalar 20 in foot data set has 2836 ocurrences and has very different grad mag, ex. 0.477121 (3), 0.539591 (2), 0.615224 (7), 0.80103(5)…, so on.
You mean in some way accumulate it and plot this values?
Thanks,
Kal