IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26625


Ignore:
Timestamp:
Jan 19, 2010, 1:29:50 PM (17 years ago)
Author:
eugene
Message:

setting NAN values to bright green

Location:
branches/eam_branches/20091201/Ohana/src/kapa2/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20091201/Ohana/src/kapa2/src/ColorHistogram.c

    r16061 r26625  
    174174    node->pixel = current[0];
    175175    current[0] ++;
    176     assert (current[0] <= Npixels);
     176    assert (current[0] < Npixels);
    177177    return TRUE;
    178178  }
  • branches/eam_branches/20091201/Ohana/src/kapa2/src/SetColorScale.c

    r25757 r26625  
    3434  float slope;
    3535  float start;
    36   unsigned short MaxValue;
     36  unsigned short MaxValue, NANValue;
    3737  Matrix *matrix;
    3838
    3939  // define the color transform parameters
    40   MaxValue = graphic[0].Npixels - 1;
     40  NANValue = graphic[0].Npixels - 1;
     41  MaxValue = graphic[0].Npixels - 2;
    4142  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;
    4445  } else {
    4546    slope = 1.0;
     
    6364  // convert pixel data values to pixel index values (0 - Npixel)
    6465  for (i = 0; i < nPixels; i++, iData++, oData++) {
     66    if (isnan(*iData) || isinf(*iData)) {
     67      *oData = NANValue;
     68      continue;
     69    }
    6570    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    }
    6879    *oData = value;
    6980  }
     
    169180  if (DX != image[0].channel[KAPA_CHANNEL_BLUE].matrix.Naxis[0]) return FALSE;
    170181  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  } 
    171191
    172192  // create the top-level cube
     
    214234  // convert histogram 3D values to cmap colors
    215235  Npixels = 0;
    216   CCNodeSetColorMap (cube, graphic[0].cmap, graphic[0].Npixels, &Npixels);
     236  CCNodeSetColorMap (cube, graphic[0].cmap, graphic[0].Npixels - 1, &Npixels);
    217237
    218238  // store the colors
  • branches/eam_branches/20091201/Ohana/src/kapa2/src/SetColormap.c

    r25757 r26625  
    1010    VAR = tmp; \
    1111  } }   
     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).
    1217
    1318int SetColormap (char *name) {
     
    2631  }
    2732
     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
    2842  // very simple color model: evenly spaced cube
    2943  if (!strcasecmp (name, "ruffcolor")) {
    3044      graphic[0].nRed  = pow (graphic[0].Npixels, 0.333);
    3145      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);
    3347
    3448      // red,green,blue are values in range 0x0000 to 0xffff
     
    4862          }
    4963      }
     64      fprintf (stderr, "ruff Npix: %d vs %d\n", i, graphic[0].Npixels);
    5065
    5166      // all other modes are 1D: set the flag:
     
    5873
    5974  // red,green,blue are values in range 0x0000 to 0xffff
    60   scale = 0xffff / (graphic[0].Npixels - 1);
     75  scale = 0xffff / (graphic[0].Npixels - 2);
    6176
    6277  /* greyscale */
    6378  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++) { 
    6580      SETVALUE (graphic[0].cmap[i].red,   0xffff - i*scale, 0, 0xffff);
    6681      SETVALUE (graphic[0].cmap[i].green, 0xffff - i*scale, 0, 0xffff);
     
    7287  /* -grayscale */
    7388  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++) { 
    7590      SETVALUE (graphic[0].cmap[i].red,   i*scale, 0, 0xffff);
    7691      SETVALUE (graphic[0].cmap[i].green, i*scale, 0, 0xffff);
     
    102117      graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
    103118    }
    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++) { 
    105120      graphic[0].cmap[i].red   = 0xffff;
    106121      graphic[0].cmap[i].green = 0xffff;
     
    134149    }
    135150    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++) { 
    137152      graphic[0].cmap[i].red   = 0xffff;
    138153      graphic[0].cmap[i].green = 0xffff;
Note: See TracChangeset for help on using the changeset viewer.