Changeset 26625
- Timestamp:
- Jan 19, 2010, 1:29:50 PM (17 years ago)
- Location:
- branches/eam_branches/20091201/Ohana/src/kapa2/src
- Files:
-
- 3 edited
-
ColorHistogram.c (modified) (1 diff)
-
SetColorScale.c (modified) (4 diffs)
-
SetColormap.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/20091201/Ohana/src/kapa2/src/ColorHistogram.c
r16061 r26625 174 174 node->pixel = current[0]; 175 175 current[0] ++; 176 assert (current[0] < =Npixels);176 assert (current[0] < Npixels); 177 177 return TRUE; 178 178 } -
branches/eam_branches/20091201/Ohana/src/kapa2/src/SetColorScale.c
r25757 r26625 34 34 float slope; 35 35 float start; 36 unsigned short MaxValue ;36 unsigned short MaxValue, NANValue; 37 37 Matrix *matrix; 38 38 39 39 // define the color transform parameters 40 MaxValue = graphic[0].Npixels - 1; 40 NANValue = graphic[0].Npixels - 1; 41 MaxValue = graphic[0].Npixels - 2; 41 42 if (image[0].image[0].range != 0.0) { 42 slope = graphic[0].Npixels/ image[0].image[0].range;43 start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range;43 slope = (graphic[0].Npixels - 1) / image[0].image[0].range; 44 start = slope * image[0].image[0].zero; 44 45 } else { 45 46 slope = 1.0; … … 63 64 // convert pixel data values to pixel index values (0 - Npixel) 64 65 for (i = 0; i < nPixels; i++, iData++, oData++) { 66 if (isnan(*iData) || isinf(*iData)) { 67 *oData = NANValue; 68 continue; 69 } 65 70 value = *iData * slope - start; 66 if (value < 0) value = 0; 67 if (value > MaxValue) value = MaxValue; 71 if (value < 0) { 72 *oData = 0; 73 continue; 74 } 75 if (value > MaxValue) { 76 *oData = MaxValue; 77 continue; 78 } 68 79 *oData = value; 69 80 } … … 169 180 if (DX != image[0].channel[KAPA_CHANNEL_BLUE].matrix.Naxis[0]) return FALSE; 170 181 if (DY != image[0].channel[KAPA_CHANNEL_BLUE].matrix.Naxis[1]) return FALSE; 182 183 // XXX a bit bogus: we are going to store a special color at Npixels-1 for 184 // marking the NAN pixels. 185 { 186 // XXX set pure green for now 187 graphic[0].cmap[graphic[0].Npixels-1].red = 0; 188 graphic[0].cmap[graphic[0].Npixels-1].green = 0xffff; 189 graphic[0].cmap[graphic[0].Npixels-1].blue = 0; 190 } 171 191 172 192 // create the top-level cube … … 214 234 // convert histogram 3D values to cmap colors 215 235 Npixels = 0; 216 CCNodeSetColorMap (cube, graphic[0].cmap, graphic[0].Npixels , &Npixels);236 CCNodeSetColorMap (cube, graphic[0].cmap, graphic[0].Npixels - 1, &Npixels); 217 237 218 238 // store the colors -
branches/eam_branches/20091201/Ohana/src/kapa2/src/SetColormap.c
r25757 r26625 10 10 VAR = tmp; \ 11 11 } } 12 13 // the image arrives from the client program as an array of floats, stored in image->matrix. 14 // whenever we load a new image or change tv channels, we need to map the currently active 15 // image from float to pixel index (image->pixmap). When we actually display (or change the 16 // display of) an image, we simply remap the lit pixels (in Remap32.c, etc). 12 17 13 18 int SetColormap (char *name) { … … 26 31 } 27 32 33 // XXX a bit bogus: we are going to store a special color at Npixels-1 for 34 // marking the NAN pixels. 35 { 36 // XXX set pure green for now 37 graphic[0].cmap[graphic[0].Npixels-1].red = 0; 38 graphic[0].cmap[graphic[0].Npixels-1].green = 0xffff; 39 graphic[0].cmap[graphic[0].Npixels-1].blue = 0; 40 } 41 28 42 // very simple color model: evenly spaced cube 29 43 if (!strcasecmp (name, "ruffcolor")) { 30 44 graphic[0].nRed = pow (graphic[0].Npixels, 0.333); 31 45 graphic[0].nBlue = pow (graphic[0].Npixels, 0.333); 32 graphic[0].nGreen = graphic[0].Npixels/ (graphic[0].nRed * graphic[0].nBlue);46 graphic[0].nGreen = (graphic[0].Npixels - 1) / (graphic[0].nRed * graphic[0].nBlue); 33 47 34 48 // red,green,blue are values in range 0x0000 to 0xffff … … 48 62 } 49 63 } 64 fprintf (stderr, "ruff Npix: %d vs %d\n", i, graphic[0].Npixels); 50 65 51 66 // all other modes are 1D: set the flag: … … 58 73 59 74 // red,green,blue are values in range 0x0000 to 0xffff 60 scale = 0xffff / (graphic[0].Npixels - 1);75 scale = 0xffff / (graphic[0].Npixels - 2); 61 76 62 77 /* greyscale */ 63 78 if ((!strcasecmp (name, "grayscale")) || (!strcasecmp (name, "greyscale"))) { 64 for (i = 0; i < graphic[0].Npixels ; i++) {79 for (i = 0; i < graphic[0].Npixels - 1; i++) { 65 80 SETVALUE (graphic[0].cmap[i].red, 0xffff - i*scale, 0, 0xffff); 66 81 SETVALUE (graphic[0].cmap[i].green, 0xffff - i*scale, 0, 0xffff); … … 72 87 /* -grayscale */ 73 88 if ((!strcasecmp (name, "-grayscale")) || (!strcasecmp (name, "-greyscale"))) { 74 for (i = 0; i < graphic[0].Npixels ; i++) {89 for (i = 0; i < graphic[0].Npixels - 1; i++) { 75 90 SETVALUE (graphic[0].cmap[i].red, i*scale, 0, 0xffff); 76 91 SETVALUE (graphic[0].cmap[i].green, i*scale, 0, 0xffff); … … 102 117 graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue; 103 118 } 104 for (i = (int)(0.75*graphic[0].Npixels); i < graphic[0].Npixels ; i++) {119 for (i = (int)(0.75*graphic[0].Npixels); i < graphic[0].Npixels - 1; i++) { 105 120 graphic[0].cmap[i].red = 0xffff; 106 121 graphic[0].cmap[i].green = 0xffff; … … 134 149 } 135 150 blueRef = 0.75*graphic[0].Npixels*scale*4.0; 136 for (i = (int)(0.75*graphic[0].Npixels); i < graphic[0].Npixels ; i++) {151 for (i = (int)(0.75*graphic[0].Npixels); i < graphic[0].Npixels - 1; i++) { 137 152 graphic[0].cmap[i].red = 0xffff; 138 153 graphic[0].cmap[i].green = 0xffff;
Note:
See TracChangeset
for help on using the changeset viewer.
