Changeset 3574 for trunk/packages/vizservers/nanovis/ReaderCommon.cpp
 Timestamp:
 Mar 25, 2013, 4:17:55 PM (7 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/packages/vizservers/nanovis/ReaderCommon.cpp
r3502 r3574 31 31 32 32 void 33 normalizeScalar(float * fdata, int count, float min, floatmax)33 normalizeScalar(float *data, int count, int stride, double vmin, double vmax) 34 34 { 35 float v = max  min; 36 if (v != 0.0f) { 37 for (int i = 0; i < count; ++i) { 38 if (fdata[i] != 1.0) { 39 fdata[i] = (fdata[i]  min)/ v; 40 } 35 double dv = vmax  vmin; 36 dv = (dv == 0.0) ? 1.0 : 0.0; 37 for (int pt = 0, i = 0; pt < count; ++pt, i += stride) { 38 double v = data[i]; 39 if (isnan(v)) { 40 data[i] = 1.0f; 41 } else if (data[i] >= min) { 42 data[i] = (float)((v  vmin)/ dv); 41 43 } 42 44 } … … 48 50 * This technique is fairly expensive in terms of memory and 49 51 * running time due to the filter extent. 52 * 53 * \param data Data array with X the fastest running, stride of 54 * 1 float 55 * \param nx number of values in X direction 56 * \param ny number of values in Y direction 57 * \param nz number of values in Z direction 58 * \param dx Size of voxels in X direction 59 * \param dy Size of voxels in Y direction 60 * \param dz Size of voxels in Z direction 61 * \param min Minimum value in data 62 * \param max Maximum value in data 63 * \return Returns a float array with stride of 4 floats 64 * containing the normalized scalar and the x,y,z components of 65 * the (normalized) gradient vector 50 66 */ 51 67 float * 52 computeGradient(float * fdata,53 int width, int height, int depth,68 computeGradient(float *data, 69 int nx, int ny, int nz, 54 70 float dx, float dy, float dz, 55 71 float min, float max) 56 72 { 57 float *gradients = (float *)malloc(width * height * depth * 3 * 58 sizeof(float)); 59 float *tempGradients = (float *)malloc(width * height * depth * 3 * 60 sizeof(float)); 61 int sizes[3] = { width, height, depth }; 73 int npts = nx * ny * nz; 74 float *gradients = (float *)malloc(npts * 3 * sizeof(float)); 75 float *tempGradients = (float *)malloc(npts * 3 * sizeof(float)); 76 int sizes[3] = { nx, ny, nz }; 62 77 float spacing[3] = { dx, dy, dz }; 63 computeGradients(tempGradients, fdata, sizes, spacing, DATRAW_FLOAT);78 computeGradients(tempGradients, data, sizes, spacing, DATRAW_FLOAT); 64 79 filterGradients(tempGradients, sizes); 65 80 quantizeGradients(tempGradients, gradients, sizes, DATRAW_FLOAT); 66 81 free(tempGradients); 67 normalizeScalar( fdata, width * height * depth, min, max);68 float *data = merge(fdata, gradients, width * height * depth);82 normalizeScalar(data, npts, 1, min, max); 83 float *dataOut = merge(data, gradients, npts); 69 84 free(gradients); 70 return data ;85 return dataOut; 71 86 } 72 87 … … 92 107 */ 93 108 void 94 computeSimpleGradient(float *data, int nx, int ny, int nz, 109 computeSimpleGradient(float *data, 110 int nx, int ny, int nz, 95 111 float dx, float dy, float dz) 96 112 {
Note: See TracChangeset
for help on using the changeset viewer.