IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15935


Ignore:
Timestamp:
Dec 27, 2007, 6:43:57 AM (18 years ago)
Author:
eugene
Message:

splitting Remap functions into remap and rescale; defining simple 3d color table; adding flag to track 1d vs 3d colors

Location:
branches/eam_branch_20071222/Ohana/src/kapa2
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20071222/Ohana/src/kapa2/Makefile

    r15925 r15935  
    7777$(SRC)/bDrawOverlay.$(ARCH).o             $(SRC)/ButtonFunctions.$(ARCH).o    \
    7878$(SRC)/PSimage.$(ARCH).o                  $(SRC)/PSPixmap.$(ARCH).o           \
    79 $(SRC)/PSOverlay.$(ARCH).o                $(SRC)/SetChannel.$(ARCH).o
     79$(SRC)/PSOverlay.$(ARCH).o                $(SRC)/SetChannel.$(ARCH).o         \
     80$(SRC)/SetColorScale.$(ARCH).o
    8081
    8182OBJ  =  $(KAPA)
  • branches/eam_branch_20071222/Ohana/src/kapa2/include/constants.h

    r15925 r15935  
    3131# define LABEL_MAXLEN 128
    3232
     33typedef enum {
     34    KAPA_SCALE_1D,
     35    KAPA_SCALE_3D
     36} KapaColorScaleMode;
     37
    3338/* label names */
    34 # define LABELX0 0
    35 # define LABELY0 1
    36 # define LABELX1 2
    37 # define LABELY1 3
    38 # define LABELUL 4
    39 # define LABELUR 5
    40 # define LABELLL 6
    41 # define LABELLR 7
     39typedef enum {
     40  LABELX0,
     41  LABELY0,
     42  LABELX1,
     43  LABELY1,
     44  LABELUL,
     45  LABELUR,
     46  LABELLL,
     47  LABELLR
     48} KapaLabelMode;
    4249
    4350/* EVENT_MASK consists of:
  • branches/eam_branch_20071222/Ohana/src/kapa2/include/prototypes.h

    r15925 r15935  
    140140
    141141int           Center              PROTO(());
     142void          SetColorScale       PROTO((Graphic *graphic, KapaImageWidget *image));
     143void          SetColorScale1D     PROTO((Graphic *graphic, KapaImageWidget *image));
     144void          SetColorScale3D     PROTO((Graphic *graphic, KapaImageWidget *image));
    142145void          Remap               PROTO((Graphic *graphic, KapaImageWidget *image));
    143146void          Remap8              PROTO((Graphic *graphic, KapaImageWidget *image, Matrix *matrix));
  • branches/eam_branch_20071222/Ohana/src/kapa2/include/structures.h

    r15925 r15935  
    1717  Colormap       colormap;
    1818  unsigned long *color;      // graph plotting colors
    19   int Ncolors;
     19  int            Ncolors;
    2020
    21   unsigned long *pixels;     // image pixel colors
     21  unsigned long *pixels;      // image pixel colors
    2222  int Npixels;                // number of pixels
     23
     24  int            ColorScaleMode; // single colormap for all images??
     25  int nRed;
     26  int nBlue;
     27  int nGreen;
    2328
    2429  unsigned long  fore;        // basic foreground color
     
    171176
    172177  unsigned short   *pixmap;   // lookup table for image pixel value to pixel index
     178  int      nPixels;
     179 
    173180  KapaImageChannel *image;
    174181  KapaImageChannel channel[NCHANNELS];
  • branches/eam_branch_20071222/Ohana/src/kapa2/src/ButtonFunctions.c

    r15925 r15935  
    1818  SetColormap (name);
    1919  CreateColorbar (image, graphic);
     20  SetColorScale (graphic, image);
    2021  Remap (graphic, image);
    2122  CreateZoom (image, graphic, 0, 0);
     
    3031  SetColormap (name);
    3132  CreateColorbar (image, graphic);
     33  SetColorScale (graphic, image);
    3234  Remap (graphic, image);
    3335  CreateZoom (image, graphic, 0, 0);
     
    4042  char *name;
    4143  name = RAINBOW;
    42   SetColormap (name);
     44  SetColormap ("fullcolor");
    4345  CreateColorbar (image, graphic);
     46  SetColorScale (graphic, image);
    4447  Remap (graphic, image);
    4548  CreateZoom (image, graphic, 0, 0);
  • branches/eam_branch_20071222/Ohana/src/kapa2/src/Image.c

    r15925 r15935  
    3333  }
    3434  image[0].image = &image[0].channel[0];
     35
     36  image[0].nPixels = 0;
     37  ALLOCATE (image[0].pixmap, unsigned short, 1);  /* allocate so later free will not crash! */
     38
     39  // XXXX this has been moved to graphic, which may be wrong
     40  // image[0].ColorScaleMode = KAPA_SCALE_1D;
    3541
    3642  for (i = 0; i < NOVERLAYS; i++) {
     
    165171    free (image[0].overlay[i].objects);
    166172  }
    167   free (image[0].image[0].matrix.buffer);
     173  for (i = 0; i < NCHANNELS; i++) {
     174    free (image[0].channel[i].matrix.buffer);
     175  }
     176  free (image[0].pixmap);
    168177  free (image[0].picture.data);
    169178  free (image[0].cmapbar.data);
  • branches/eam_branch_20071222/Ohana/src/kapa2/src/LoadPicture.c

    r15925 r15935  
    6363  if (!USE_XWINDOW) return (TRUE);
    6464
     65  SetColorScale (graphic, image);
    6566  Remap (graphic, image);
    6667  if (DEBUG) fprintf (stderr, "remapped image\n");
  • branches/eam_branch_20071222/Ohana/src/kapa2/src/Remap32.c

    r15925 r15935  
    11# include "Ximage.h"
    2 
    3 static float slope = 1.0;
    4 static float start = 0.0;
    5 static int MaxValue = 255;
    6 
    7 // XXX inline this if needed
    8 # define PixelLookup(VALUE) (int)(MIN (MAX (slope * VALUE - start, 0), MaxValue))
    9 
    10 # if  (0)
    11 static int PixelLookup(float value) {
    12   int out;
    13   out = MIN (MAX (slope * value - start, 0), MaxValue);
    14   return (out);
    15 }
    16 # endif
    172
    183void Remap32 (Graphic *graphic, KapaImageWidget *image, Matrix *matrix) {
     
    2510  int expand_in, expand_out;
    2611  unsigned int *out_pix, *out_pix2;
    27   float *imdata, *in_pix, *in_pix2;
     12  unsigned short *in_pix, *in_pix2;
    2813  unsigned long *pixel, pixvalue;
    2914  unsigned long back;
     
    3621  }
    3722  back = graphic[0].back;
    38 
    39   // define the color transform parameters
    40   MaxValue = graphic[0].Npixels - 1;
    41   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;
    44   } else {
    45     slope = 1.0;
    46     start = image[0].image[0].zero;
    47   }
    4823
    4924  // set up expansions
     
    9873
    9974  out_pix = (unsigned int *) image[0].picture.data;
    100   imdata  = (float *) matrix[0].buffer;
    101   in_pix  = &imdata[DX*(int)MAX(Y,0) + (int)MAX(X,0)];
     75  in_pix  = &image[0].pixmap[DX*(int)MAX(Y,0) + (int)MAX(X,0)];
    10276
    10377  /********** below we do the mapping from buffer pixels (in) to picture pixels (out) **********/
     
    12296    if (expand_out == 1) {
    12397      for (i = i_start; i < i_end; i++, in_pix2+= expand_in, out_pix++) {
    124         pixelN = PixelLookup(*in_pix2);
    125         *out_pix = pixel[pixelN];
     98        *out_pix = pixel[*in_pix2];
    12699      }
    127     }
    128     else {
     100    } else {
    129101      for (i = i_start; i < i_end; i+= expand_out, in_pix2++, out_pix+= expand_out) {
    130         pixelN   = PixelLookup(*in_pix2);
    131         pixvalue = pixel[pixelN];
     102        pixvalue = pixel[*in_pix2];
    132103        out_pix2 = out_pix;
    133104        for (jj = 0; jj < expand_out; jj++, out_pix2+=(dx-expand_out)) {
     
    148119    }
    149120    out_pix += (dx - i_end);
    150    
    151121  }
    152122 
  • branches/eam_branch_20071222/Ohana/src/kapa2/src/Reorient.c

    r15925 r15935  
    44
    55  if (image[0].expand == 0) image[0].expand = 1;
     6
     7  if ((image[0].X == X) && (image[0].Y == Y) && (mode == 0)) {
     8    Refresh ();
     9    XFlush (graphic[0].display);
     10    return;
     11  }
    612
    713  switch (mode) {
  • branches/eam_branch_20071222/Ohana/src/kapa2/src/SetChannel.c

    r15925 r15935  
    2525  if (!USE_XWINDOW) return (TRUE);
    2626
     27  SetColorScale (graphic, image);
    2728  Remap (graphic, image);
    2829  if (DEBUG) fprintf (stderr, "remapped image\n");
  • branches/eam_branch_20071222/Ohana/src/kapa2/src/SetColormap.c

    r15925 r15935  
    1313int SetColormap (char *name) {
    1414
    15   int i, ref1, ref2;
     15  int i, red, blue, green;
    1616  float scale, blueRef, redRef, greenRef;
    1717  Graphic *graphic;
    1818
    1919  graphic = GetGraphic();
     20
     21  // very simple color model: evenly spaced cube
     22  if (!strcasecmp (name, "fullcolor")) {
     23      graphic[0].nRed  = pow (graphic[0].Npixels, 0.333);
     24      graphic[0].nBlue = pow (graphic[0].Npixels, 0.333);
     25      graphic[0].nGreen = graphic[0].Npixels / (graphic[0].nRed * graphic[0].nBlue);
     26
     27      // red,green,blue are values in range 0x0000 to 0xffff
     28      float redScale = 0xffff / (graphic[0].nRed - 1);
     29      float blueScale = 0xffff / (graphic[0].nBlue - 1);
     30      float greenScale = 0xffff / (graphic[0].nGreen - 1);
     31
     32      i = 0;
     33      for (red = 0; red < graphic[0].nRed; red++) { 
     34          for (blue = 0; blue < graphic[0].nBlue; blue++) { 
     35              for (green = 0; green < graphic[0].nGreen; green++, i++) { 
     36                  SETVALUE (graphic[0].cmap[i].red,   red*redScale, 0, 0xffff);
     37                  SETVALUE (graphic[0].cmap[i].blue,  blue*blueScale, 0, 0xffff);
     38                  SETVALUE (graphic[0].cmap[i].green, green*greenScale, 0, 0xffff);
     39                  graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
     40              }
     41          }
     42      }
     43
     44      // all other modes are 1D: set the flag:
     45      graphic[0].ColorScaleMode = KAPA_SCALE_3D;
     46      goto store_colors;
     47  }
     48
     49  // all other modes are 1D: set the flag:
     50  graphic[0].ColorScaleMode = KAPA_SCALE_1D;
    2051
    2152  // red,green,blue are values in range 0x0000 to 0xffff
Note: See TracChangeset for help on using the changeset viewer.