- Timestamp:
- 02/05/07 13:29:55 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Geom/shared/GTGeometry/src/libs/vmi/src/saliency.cpp
r983 r2090 23 23 24 24 void VMI::computeSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras) { 25 GLuint i = 0; 26 double sal; 27 28 maxSal = minSal = computeTriangleSaliency(mesh, histogram, numCameras, 0); 29 30 mesh->triangles[0].saliency = maxSal; 31 32 for (i=1; i<mesh->numTriangles; i++) { 33 34 sal = computeTriangleSaliency(mesh, histogram, numCameras, i); 35 36 if (sal > maxSal) maxSal = sal; 37 if (sal < minSal) minSal = sal; 38 39 mesh->triangles[i].saliency = sal; 40 } 41 42 printf("\nMax Sal: %f Min Sal: %f\n", maxSal, minSal); 43 44 percentile = computePercentile(alpha, mesh->triangles, mesh->numTriangles); 45 printf("\n%dth percentile: %f\n", alpha, percentile); 25 GLuint i = 0; 26 double sal; 27 28 maxSal = minSal = computeTriangleSaliency(mesh, histogram, numCameras, 0); 29 30 mesh->triangles[0].saliency = maxSal; 31 32 for (i=1; i<mesh->numTriangles; i++) { 33 34 sal = computeTriangleSaliency(mesh, histogram, numCameras, i); 35 36 if (sal > maxSal) maxSal = sal; 37 if (sal < minSal) minSal = sal; 38 39 mesh->triangles[i].saliency = sal; 40 } 41 42 printf("\nMax Sal: %f Min Sal: %f\n", maxSal, minSal); 43 44 percentile = computePercentile(alpha, mesh->triangles, mesh->numTriangles); 45 printf("\n%dth percentile: %f\n", alpha, percentile); 46 } 47 48 void updateTriangleSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras, int v) { 49 int i, t; 50 51 for(i=0; i<(int)mesh->vertices[v].numTriangles; i++) { 52 53 t = mesh->vertices[v].triangles[i]; 54 55 mesh->triangles[t].saliency = computeTriangleSaliency(mesh, histogram, numCameras, t); 56 } 46 57 } 47 58 48 59 double VMI::computeTriangleSaliency(Mesh *mesh, GLuint **histogram, GLuint numCameras, GLuint k) { 49 GLuint i, l, v0, v1, v2;50 int triangles[MAX_NUM_TRI], n = 0;60 GLuint i, l, v0, v1, v2; 61 int *triangles = NULL, n = 0; 51 62 double sal = 0.0; 52 63 … … 55 66 v2 = mesh->triangles[k].indices[2]; 56 67 68 /* Allocating memory */ 69 triangles = (int *)malloc((mesh->vertices[v0].numTriangles + 70 mesh->vertices[v1].numTriangles + 71 mesh->vertices[v2].numTriangles) * sizeof(int)); 72 57 73 for(i=0; i<mesh->vertices[v0].numTriangles; i++) { 58 74 l = mesh->vertices[v0].triangles[i]; … … 86 102 //getchar(); 87 103 104 free(triangles); 105 88 106 return (sal /*/ n*/); 89 107 } … … 150 168 if((fp= fopen(filename, "rt"))== NULL) { 151 169 printf("Can't open file %s\n", filename); 152 exit(1); 170 getchar(); 171 exit(1); 153 172 } 154 173 … … 219 238 void VMI::computeRGB(double min, double max,double value,float *r,float *g,float *b) 220 239 { 221 //Dados el valor máximo, el mínimo y el valor que le quieres calcular el color te devuelve el respectivo RGB. 222 if(value>max) value=max; 223 if(value<min) value=min; 224 225 if(max==min) value=1; 226 else value=(float)(value-min)/(float)(max-min); 227 228 if (value<=0.25) 229 { 230 (*r)=0; 231 (*g)=4*value; 232 (*b)=1; 233 } 234 else if (value<=0.50) 235 { 236 (*r)=0; 237 (*g)=1; 238 (*b)=2-4*value; 239 } 240 else if (value<=0.75) 241 { 242 (*r)=4*value-2; 243 (*g)=1; 244 (*b)=0; 245 } 246 else 247 { 248 (*r)=1; 249 (*g)=4-4*value; 250 (*b)=0; 251 } 240 /* Given the maximum, the minimum value and the demanded color value returns 241 * the respective RGB color 242 */ 243 if(value>max) value=max; 244 if(value<min) value=min; 245 246 if(max==min) value=1; 247 else value=(float)(value-min)/(float)(max-min); 248 249 if (value<=0.25) 250 { 251 (*r)=0; 252 (*g)=4*value; 253 (*b)=1; 254 } 255 else if (value<=0.50) 256 { 257 (*r)=0; 258 (*g)=1; 259 (*b)=2-4*value; 260 } 261 else if (value<=0.75) 262 { 263 (*r)=4*value-2; 264 (*g)=1; 265 (*b)=0; 266 } 267 else 268 { 269 (*r)=1; 270 (*g)=4-4*value; 271 (*b)=0; 272 } 252 273 } 253 274
Note: See TracChangeset
for help on using the changeset viewer.