28 void Equalize::EqualizeHistogram (
int dimx,
int dimy,
int dimz,
29 unsigned short *volume,
int nbitsalloc,
30 unsigned int umax,
unsigned int **histogram)
35 int L = pow(2,nbitsalloc);
36 int *tmp =
new int[L];
37 int *cdf =
new int[L];
40 memset(tmp, 0x00, L*
sizeof(
int));
43 int intensidade, iz, iy, ix;
44 for (iz = 0; iz < dimz; iz++) {
45 for (iy =0; iy < dimy; iy++) {
46 for (ix =0; ix < dimx; ix++) {
47 intensidade = (int)(volume[iz*dimx*dimy+iy*dimx+ix]);
53 int volSize = dimx*dimy*dimz;
60 if (cdf[0]) cdfmin = cdf[0];
61 for(i = 1; i < L; i++) {
62 cdf[i] = cdf[i-1] + tmp[i];
63 if (cdfmin == -1 && cdf[i]) cdfmin = cdf[i];
69 *histogram =
new unsigned int[umax];
70 memset(*histogram, 0x00, umax*
sizeof(
unsigned int));
72 for (i=0; i<umax; i++) {
73 (*histogram)[i] = (
unsigned int)(((1.0*(cdf[i]-cdfmin))/(volSize-cdfmin))*(L-1));