IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 10, 2010, 7:24:46 PM (17 years ago)
Author:
eugene
Message:

updates from eam_branches/20091201

Location:
trunk/Ohana/src/kapa2
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/kapa2/include/constants.h

    r25757 r26891  
    1111
    1212# define NCHANNELS 3
    13 # define NPIXELS_DYNAMIC 4600
     13# define NPIXELS_DYNAMIC 128
    1414
    1515// XXX for the moment, this is set to match the values in SetColorScale3D_CC
    16 # define NPIXELS_STATIC 4600
     16# define NPIXELS_STATIC 128
    1717
    1818# define PAD1  3
  • trunk/Ohana/src/kapa2/src/ColorHistogram.c

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

    r14590 r26891  
    88  KapaImageWidget *image;
    99
     10  // We have to accept the incoming message even if we cannot perform the action
     11  KiiScanCommand (sock, 16, "%*s %d", &N);
     12
    1013  graphic = GetGraphic();
    1114  section = GetActiveSection();
    1215  image = section->image;
    1316  if (image == NULL) return (TRUE);
    14 
    15   KiiScanCommand (sock, 16, "%*s %d", &N);
    1617
    1718  if (N > NOVERLAYS) {
  • trunk/Ohana/src/kapa2/src/LoadPicture.c

    r25757 r26891  
    7373    if (status == 0) {  /* No more pipe */
    7474      fprintf (stderr, "error: pipe closed\n");
     75      fcntl (sock, F_SETFL, !O_NONBLOCK); 
    7576      return (FALSE);
    7677    }
     
    9293  SetColorScale (graphic, image);
    9394
    94   SetColorScale (graphic, image);
    95 
    9695  if (!USE_XWINDOW) return (TRUE);
    9796
  • trunk/Ohana/src/kapa2/src/PNGit.c

    r13479 r26891  
    1616
    1717  /* expect a line telling the number of bytes and a filename */
    18   status = read (sock, filename, 16);
    19   filename[16] = 0;
    20   sscanf (filename, "%*s %d", &Nbytes);
    21   status = read (sock, filename, Nbytes);
    22   filename[status] = 0; /* make the string easy to parse */
     18  KiiScanMessage (sock, "%s", filename);
    2319
    2420  f = fopen (filename, "w");
  • trunk/Ohana/src/kapa2/src/PPMit.c

    r13479 r26891  
    1313
    1414  /* expect a line telling the number of bytes and a filename */
    15   status = read (sock, filename, 16);
    16   filename[16] = 0;
    17   sscanf (filename, "%*s %d", &Nbytes);
    18   status = read (sock, filename, Nbytes);
    19   filename[status] = 0; /* make the string easy to parse */
     15  KiiScanMessage (sock, "%s", filename);
    2016
    2117  f = fopen (filename, "w");
  • trunk/Ohana/src/kapa2/src/Resize.c

    r21153 r26891  
    1111  graphic = GetGraphic();
    1212
     13  // must scan the message before possible return
    1314  KiiScanMessage (sock, "%d %d", &NX, &NY);
    1415
  • trunk/Ohana/src/kapa2/src/SaveOverlay.c

    r13479 r26891  
    99  KapaImageWidget *image;
    1010
     11  KiiScanMessage (sock, "%*s %d %s", &N, filename);
     12 
    1113  section = GetActiveSection();
    1214  image   = section->image;
    1315  if (image == NULL) return (TRUE);
    1416
    15   KiiScanMessage (sock, "%*s %d %s", &N, filename);
    16  
    1717  f = fopen (filename, "w");
    1818  if (f == NULL) {
  • trunk/Ohana/src/kapa2/src/SetColorScale.c

    r25757 r26891  
    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
  • trunk/Ohana/src/kapa2/src/SetColormap.c

    r25757 r26891  
    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.