IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 16009


Ignore:
Timestamp:
Jan 4, 2008, 4:00:13 PM (18 years ago)
Author:
eugene
Message:

more work on rgb colors

Location:
branches/eam_branch_20071222/Ohana/src
Files:
1 added
13 edited

Legend:

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

    r15996 r16009  
    1414
    1515// XXX for the moment, this is set to match the values in SetColorScale3D_CC
    16 # define NPIXELS_STATIC 3000
     16# define NPIXELS_STATIC 4600
    1717
    1818# define PAD1  3
  • branches/eam_branch_20071222/Ohana/src/kapa2/include/prototypes.h

    r15996 r16009  
    7171int           GetImageCoords      PROTO((int sock));
    7272int           GetImageRange       PROTO((int sock));
     73int           SetChannel (int sock);
     74int           SetColormapFromPipe (int sock);
    7375
    7476int           LoadVectorData      PROTO((int sock, KapaGraphWidget *graph, int N, char *type));
  • branches/eam_branch_20071222/Ohana/src/kapa2/src/CheckPipe.c

    r15925 r16009  
    274274  }
    275275
     276  if (!strcmp (word, "CMAP")) {
     277    status = SetColormapFromPipe (sock);
     278    KiiSendCommand (sock, 4, "DONE");
     279    FINISHED (status);
     280  }
     281
    276282  if (!strcmp (word, "SAVE")) {
    277283    status = SaveOverlay (sock);
  • branches/eam_branch_20071222/Ohana/src/kapa2/src/CreateZoom32.c

    r15925 r16009  
    11# include "Ximage.h"
    22# define FRAC(a) ((a) - (int)(a))
    3 
    4 static float slope = 1.0;
    5 static float start = 0.0;
    6 static int MaxValue = 255;
    7 
    8 // XXX inline this if needed
    9 static int PixelLookup(float value) {
    10   int out;
    11   out = MIN (MAX (slope * value - start, 0), MaxValue);
    12   return (out);
    13 }
    143
    154void CreateZoom32 (KapaImageWidget *image, Graphic *graphic, double x, double y) {
     
    2211  int expand_in, expand_out;
    2312  unsigned int *out_pix, *out_pix2;
    24   float *imdata, *in_pix, *in_pix2;
    25   unsigned long pixel[256], pixvalue;
     13  unsigned short *in_pix, *in_pix2;
     14  unsigned long *pixel, pixvalue;
    2615  unsigned long back;
    2716
     
    3322  }
    3423
    35   for (i = 0; i < 256; i++) { /* set up pixel array */
     24  ALLOCATE (pixel, unsigned long, graphic[0].Npixels);
     25
     26  // local array for pixel values
     27  for (i = 0; i < graphic[0].Npixels; i++) {
    3628    pixel[i] = graphic[0].cmap[i].pixel;
    3729  }
    3830  back = graphic[0].back;
    39 
    40   // define the color transform parameters
    41   MaxValue = graphic[0].Npixels - 1;
    42   if (image[0].image[0].range != 0.0) {
    43     slope = graphic[0].Npixels / image[0].image[0].range;
    44     start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range;
    45   } else {
    46     slope = 1.0;
    47     start = image[0].image[0].zero;
    48   }
    4931
    5032  zoomscale = MAX (5, image[0].expand + 5);
     
    5739  DX = image[0].image[0].matrix.Naxis[0];
    5840  DY = image[0].image[0].matrix.Naxis[1];
     41 
     42  /* Rx,Ry are the screen coordinates of the first image pixel */
    5943  Rx = x - expand*(int)(0.5*(dx + 1)) + 1;
    6044  Ry = y - expand*(int)(0.5*(dy + 1)) + 1;
     
    6448  i_end   = MAX (MIN ((DX-Rx) / expand, dx - expand_out + 1), 0);
    6549  j_end   = MAX (MIN ((DY-Ry) / expand, dy - expand_out + 1), 0);
     50
    6651  dropback = expand_out - (i_end - i_start) % expand_out;
    6752  if ((i_end - i_start) % expand_out == 0) dropback = 0;
    6853
    6954  out_pix = (unsigned int *) image[0].zoom.data;
    70   imdata  = (float *) image[0].image[0].matrix.buffer;
    71   in_pix  = &imdata[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)];
     55  in_pix  = &image[0].pixmap[DX*(int)MAX(Ry,0) + (int)MAX(Rx,0)];
    7256
    7357  /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/
     
    7862    return;
    7963  }
    80   
     64 
    8165
    8266  /**** fill in bottom area ****/
    8367  for (j = 0; j < dx*j_start; j++, out_pix++) {
    84     out_pix[0] = back;
     68    *out_pix = back;
    8569  }
    8670
     
    8872
    8973    /**** fill in area to the left of the picture ****/
    90     for (jj = 0; jj < expand_out; jj++) {
     74    for (jj = 0; (i_start > 0) && (jj < expand_out); jj++) {
    9175      out_pix2 = out_pix + jj*dx;
    9276      for (i = 0; i < i_start; i++, out_pix2++) {
    93         out_pix[0] = back;
     77        *out_pix2 = back;
    9478      }
    9579    }
     
    10084    if (expand_out == 1) {
    10185      for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) {
    102         pixelN = PixelLookup(*in_pix2);
    103         out_pix[0] = pixel[pixelN];
     86        *out_pix = pixel[*in_pix2];
    10487      }
    105     }
    106     else {
     88    } else {
    10789      for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) {
    108         pixelN   = PixelLookup(*in_pix2);
    109         pixvalue = pixel[pixelN];
     90        pixvalue = pixel[*in_pix2];
    11091        out_pix2 = out_pix;
    11192        for (jj = 0; jj < expand_out; jj++, out_pix2+=(dx-expand_out)) {
    11293          for (ii = 0; ii < expand_out; ii++, out_pix2++) {
    113             out_pix2[0] = pixvalue;
     94            *out_pix2 = pixvalue;
    11495          }
    11596        }
     
    11798    }
    11899    out_pix -= dropback;
    119 
    120100   
    121101    /**** fill in area to the right of the picture ****/
     
    123103      out_pix2 = out_pix + jj*dx;
    124104      for (i = i_end; i < dx; i++, out_pix2++) {
    125         out_pix2[0] = back;
     105        *out_pix2 = back;
    126106      }
    127107    }
     
    134114  /**** fill in top area ****/
    135115  for (j = 0; (j < dx*(dy - j_end)) && (out_pix - (unsigned int *)image[0].zoom.data < dx*dy); j++, out_pix++) {
    136     out_pix[0] = back;
     116    *out_pix = back;
    137117  }
    138118
    139   out_pix = (unsigned int *)image[0].zoom.data;
    140119  image[0].zoom.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0,
    141120                                        image[0].zoom.data, image[0].zoom.dx, image[0].zoom.dy, 32, 0);
    142121 
     122  free (pixel);
    143123}
  • branches/eam_branch_20071222/Ohana/src/kapa2/src/JPEGit24.c

    r15925 r16009  
    3737  double expand, Rx, Ry, X, Y;
    3838  unsigned char *out_pix;
    39   float *imdata, *in_pix, *in_pix_ref;
    40   unsigned char pixel1[256], pixel2[256], pixel3[256];
     39  unsigned short *in_pix, *in_pix_ref;
     40  unsigned char *pixel1, *pixel2, *pixel3;
    4141  char filename[1024];
    4242  FILE *f;
     
    7575  jpeg_start_compress (&cinfo, TRUE);
    7676
     77  ALLOCATE (pixel1, unsigned char, graphic[0].Npixels);
     78  ALLOCATE (pixel2, unsigned char, graphic[0].Npixels);
     79  ALLOCATE (pixel3, unsigned char, graphic[0].Npixels);
     80
    7781  /** cmap[i].pixel must be defined even if X is not used **/
    78   for (i = 0; i < 256; i++) { /* set up pixel array */
     82  for (i = 0; i < graphic[0].Npixels; i++) { /* set up pixel array */
    7983    pixel1[i] = graphic[0].cmap[i].red >> 8;
    8084    pixel2[i] = graphic[0].cmap[i].green >> 8;
    8185    pixel3[i] = graphic[0].cmap[i].blue >> 8;
    82   }
    83 
    84   // define the color transform parameters
    85   MaxValue = graphic[0].Npixels - 1;
    86   if (image[0].image[0].range != 0.0) {
    87     slope = graphic[0].Npixels / image[0].image[0].range;
    88     start = graphic[0].Npixels * image[0].image[0].zero / image[0].image[0].range;
    89   } else {
    90     slope = 1.0;
    91     start = image[0].image[0].zero;
    9286  }
    9387
     
    145139  ALLOCATE (line_buffer, JSAMPLE, 3*dx);
    146140
    147   imdata = (float *) image[0].image[0].matrix.buffer;
    148   in_pix_ref = &imdata[DX*(int)MAX(Y,0) + (int)MAX(X,0)];
     141  in_pix_ref  = &image[0].pixmap[DX*(int)MAX(Y,0) + (int)MAX(X,0)];
    149142
    150143  /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/
     
    177170    /*** fill in the picture region ***/
    178171    for (i = i_start; i < i_end; i+=expand_out, in_pix+=expand_in) {
    179       pixelN = PixelLookup(*in_pix);
    180172      for (ii = 0; ii < expand_out; ii++, out_pix+=3) {
    181         out_pix[0] = pixel1[pixelN];
    182         out_pix[1] = pixel2[pixelN];
    183         out_pix[2] = pixel3[pixelN];
     173        out_pix[0] = pixel1[*in_pix];
     174        out_pix[1] = pixel2[*in_pix];
     175        out_pix[2] = pixel3[*in_pix];
    184176      }
    185177    }
  • branches/eam_branch_20071222/Ohana/src/kapa2/src/PSPixmap.c

    r15925 r16009  
    143143  return;
    144144}
     145
     146# if (0)
     147// XXX needs work!
     148void PSPixmap32_RGB (Graphic *graphic, KapaImageWidget *image, FILE *f) {
     149
     150  int i, k, m, val;
     151  double Nchar, Npix, start, slope, frac;
     152  unsigned int *buff;
     153  unsigned long back;
     154  unsigned char
     155
     156  ALLOCATE (pixelR, unsigned char, graphic[0].Npixels);
     157  ALLOCATE (pixelG, unsigned char, graphic[0].Npixels);
     158  ALLOCATE (pixelB, unsigned char, graphic[0].Npixels);
     159
     160  /** cmap[i].pixel must be defined even if X is not used **/
     161  for (i = 0; i < graphic[0].Npixels; i++) { /* set up pixel array */
     162    pixelR[i] = graphic[0].cmap[i].red >> 8;
     163    pixelG[i] = graphic[0].cmap[i].green >> 8;
     164    pixelB[i] = graphic[0].cmap[i].blue >> 8;
     165  }
     166
     167  for (i = 0; i < image[0].picture.dy; i++) {
     168    for (k = 0; k < image[0].picture.dx; k++, buff++) {
     169      if (*buff == back)
     170        val = Nchar;
     171      else {
     172        for (m = 0; (graphic[0].cmap[m].pixel != *buff) && (m < Npix); m++);
     173        val = Nchar - frac * MIN (MAX (start + m * slope, 0), Npix);
     174      }
     175      fprintf (f, "%02x", val);
     176      if (!((k+1) % 40)) fprintf (f, "\n");
     177    }
     178    fprintf (f, "\n");
     179    buff -= 2*image[0].picture.dx;
     180  }
     181  return;
     182}
     183# endif
  • branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap32.c

    r15935 r16009  
    4242  DX = matrix[0].Naxis[0];
    4343  DY = matrix[0].Naxis[1];
     44
    4445  /* X,Y are the image coordinates of the first image pixel */
    4546  X = MAX(0.5*(DX - dx*expand) - image[0].X, 0);
     
    7879
    7980  /**** fill in bottom area ****/
    80   for (j = 0; j < dx*j_start; j++, out_pix++)
     81  for (j = 0; j < dx*j_start; j++, out_pix++) {
    8182    *out_pix = back;
     83  }
    8284 
    8385  for (j = j_start; j < j_end; j+= expand_out, out_pix+=(expand_out-1)*dx, in_pix += expand_in*DX) {
     
    128130    *out_pix = back;
    129131  }
     132
    130133  image[0].picture.pix = XCreateImage (graphic[0].display, graphic[0].visual, graphic[0].depth, ZPixmap, 0,
    131134                                        image[0].picture.data, image[0].picture.dx, image[0].picture.dy, 32, 0);
     
    133136  free (pixel);
    134137}
    135 
  • branches/eam_branch_20071222/Ohana/src/kapa2/src/SetChannel.c

    r15935 r16009  
    3434  return (TRUE);
    3535}
     36
     37int SetColormapFromPipe (int sock) {
     38 
     39  Graphic *graphic;
     40  Section *section;
     41  KapaImageWidget *image;
     42  char colormap[256];
     43  int status;
     44
     45  graphic = GetGraphic ();
     46  section = GetActiveSection();
     47  if (section->image == NULL) {
     48    section->image = InitImageWidget ();
     49    SetSectionSizes (section);
     50  }
     51  image = section->image;
     52
     53  KiiScanMessage (sock, "%s", colormap);
     54
     55  status = SetColormap (colormap);
     56  if (!status) fprintf (stderr, "unknown colormap %s\n", colormap);
     57
     58  SetColorScale (graphic, image);
     59  Remap (graphic, image);
     60  Refresh ();
     61  XFlush (graphic[0].display);
     62
     63  return (TRUE);
     64}
  • branches/eam_branch_20071222/Ohana/src/kapa2/src/SetColorScale.c

    r15996 r16009  
    170170  CCSplitNodeIterate (cube, 0, 2);
    171171
    172   // need to allocate at least 1184 pixels
    173   // 64, 288, 512, 736, 960, 1184
    174   for (i = 0; i < 8; i++) {
     172  // need to allocate at least 64 + NPASS*7*NSPLIT pixels (overestimate if 64 < NSPLIT)
     173# define NPASS 5
     174# define NSPLIT 128
     175
     176  for (i = 0; i < NPASS; i++) {
    175177    // generate histogram
    176178    ColorHistogram (image, cube);
     
    186188
    187189    // split nodes with more than value[n]
    188     Nmin = MAX (0, Nvalues - 50);
     190    Nmin = MAX (0, Nvalues - NSPLIT);
    189191    CCNodeDivideLimit (cube, values[Nmin]);
    190192    free (values);
  • branches/eam_branch_20071222/Ohana/src/libkapa/include/kapa.h

    r15926 r16009  
    125125/* KiiPicture.c */
    126126int KiiSetChannel (int fd, int channel);
     127int KiiSetColormap (int fd, char *colormap);
    127128int KiiNewPicture1D (int fd, KiiImage *image, KapaImageData *data, Coords *coords);
    128129int KiiNewPicture2D (int fd, KiiImage *image, KapaImageData *data, Coords *coords);
  • branches/eam_branch_20071222/Ohana/src/libkapa/src/KiiPicture.c

    r15926 r16009  
    55  KiiSendCommand (fd, 4, "CHAN"); /* tell kapa to look for the incoming image */
    66  KiiSendMessage (fd, "%1d", channel);
     7 
     8  KiiWaitAnswer (fd, "DONE");
     9  return (TRUE);
     10}
     11
     12int KiiSetColormap (int fd, char *colormap) {
     13
     14  KiiSendCommand (fd, 4, "CMAP"); /* tell kapa to look for the incoming image */
     15  KiiSendMessage (fd, "%s", colormap);
    716 
    817  KiiWaitAnswer (fd, "DONE");
  • branches/eam_branch_20071222/Ohana/src/opihi/cmd.data/Makefile

    r15927 r16009  
    114114$(SRC)/tv.$(ARCH).o                \
    115115$(SRC)/tvchannel.$(ARCH).o         \
     116$(SRC)/tvcolors.$(ARCH).o          \
    116117$(SRC)/tvcontour.$(ARCH).o         \
    117118$(SRC)/tvgrid.$(ARCH).o    \
  • branches/eam_branch_20071222/Ohana/src/opihi/cmd.data/init.c

    r15927 r16009  
    9797int tv               PROTO((int, char **));
    9898int tvchannel        PROTO((int, char **));
     99int tvcolors         PROTO((int, char **));
    99100int tvcontour        PROTO((int, char **));
    100101int tvgrid           PROTO((int, char **));
     
    216217  {"tv",           tv,               "display an image on the Kii window"},
    217218  {"tvchannel",    tvchannel,        "set the current tv channel"},
     219  {"tvcolors",     tvcolors,         "set the tv colormap"},
    218220  {"tvcontour",    tvcontour,        "send contour to overlay"},
    219221  {"tvgrid",       tvgrid,           "wait until return is typed"},
Note: See TracChangeset for help on using the changeset viewer.