IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9726


Ignore:
Timestamp:
Oct 24, 2006, 11:58:18 AM (20 years ago)
Author:
eugene
Message:

added mkrgb, fixed shift bug

Location:
trunk/Ohana/src/opihi
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/Makefile

    r8177 r9726  
    6464$(SDIR)/load.$(ARCH).o          \
    6565$(SDIR)/lookup.$(ARCH).o        \
     66$(SDIR)/mkrgb.$(ARCH).o \
    6667$(SDIR)/mcreate.$(ARCH).o       \
    6768$(SDIR)/medacc.$(ARCH).o        \
  • trunk/Ohana/src/opihi/cmd.data/init.c

    r8177 r9726  
    4949int load             PROTO((int, char **));
    5050int lookup           PROTO((int, char **));
     51int mkrgb            PROTO((int, char **));
    5152int mcreate          PROTO((int, char **));
    5253int medacc           PROTO((int, char **));
     
    160161  {"load",         load,             "load an SAOimage style overlay"},
    161162  {"lookup",       lookup,           "convert vector via lookup table (vector pair)"},
     163  {"mkrgb",        mkrgb,            "convert 3 images to rgb jpeg"},
    162164  {"mcreate",      mcreate,          "create a matrix"},
    163165  {"medacc",       medacc,           "accumulate vector values in another vector"},
  • trunk/Ohana/src/opihi/cmd.data/shift.c

    r7917 r9726  
    77  float *Vin, *Vot;
    88  double Dx, Dy, fdx, fdy;
    9   Buffer *buf;
     9  Buffer *in, *out;
    1010
    1111  ROLL = FALSE;
     
    1515  }
    1616
    17   if (argc != 4) {
    18     gprint (GP_ERR, "USAGE: shift <buffer> dx dy\n");
     17  if (argc != 5) {
     18    gprint (GP_ERR, "USAGE: shift (input) (output) dx dy\n");
    1919    return (FALSE);
    2020  }
    2121
    22   if ((buf = SelectBuffer (argv[1], OLDBUFFER, TRUE)) == NULL) return (FALSE);
     22  // define the input buffer and examine the shift
     23  if ((in  = SelectBuffer (argv[1], OLDBUFFER, TRUE)) == NULL) return (FALSE);
    2324
    24   Dx = -atof (argv[2]);
    25   Dy = -atof (argv[3]);
     25  Dx = atof (argv[3]);
     26  Dy = atof (argv[4]);
    2627
    2728  dx = Dx;
     
    2930  fdx = Dx - dx;
    3031  fdy = Dy - dy;
    31   if (fdx < -0.001) {dx -= 1; fdx += 1;}
    32   if (fdy < -0.001) {dy -= 1; fdy += 1;}
     32  if (fdx < -0.000001) {dx -= 1; fdx += 1;}
     33  if (fdy < -0.000001) {dy -= 1; fdy += 1;}
     34  // we always specify a positive fractional shift
     35  // the above choice defines a minimum fractional shift of 1e-5
    3336
    34   nx = buf[0].matrix.Naxis[0];
    35   ny = buf[0].matrix.Naxis[1];
     37  nx = in[0].matrix.Naxis[0];
     38  ny = in[0].matrix.Naxis[1];
    3639
    37   if ((dx > buf[0].matrix.Naxis[0]) || (dy > buf[0].matrix.Naxis[1])) {
     40  if ((dx > nx) || (dy > ny)) {
    3841    gprint (GP_ERR, "shifting data out of image\n");
    3942    return (FALSE);
    4043  }
    4144 
    42   if (dx < 0) {
    43     DXin = 0;
    44     DXot = -dx;
    45   } else {
    46     DXin = dx;
    47     DXot = 0;
     45  // define the output buffer
     46  if ((out = SelectBuffer (argv[2], ANYBUFFER, TRUE)) == NULL) return (FALSE);
     47
     48  gfits_free_matrix (&out[0].matrix);
     49  gfits_free_header (&out[0].header);
     50  CreateBuffer (out, nx, ny, -32, 0.0, 1.0);
     51
     52  DXin = (dx < 0) ? -dx : 0;
     53  DXot = (dx < 0) ?   0 : dx;
     54  DYin = (dy < 0) ? -dy : 0;
     55  DYot = (dy < 0) ?   0 : dy;
     56 
     57  for (j = 0; j < ny - abs(dy); j++) {
     58    Vin = (float *)(in[0].matrix.buffer)  + (j + DYin)*nx + DXin; 
     59    Vot = (float *)(out[0].matrix.buffer) + (j + DYot)*nx + DXot;
     60    for (i = 0; i < nx - abs(dx); i++, Vin++, Vot++) {
     61      *Vot = *Vin;
     62    }
     63    // fill in the exposed x-border with 0.0
     64    Vot = (dx > 0) ?
     65      (float *)(out[0].matrix.buffer) + (j + DYot)*nx :
     66      (float *)(out[0].matrix.buffer) + (j + DYot)*nx + nx - abs(dx);
     67    for (i = 0; i < abs(dx); i++, Vot++) {
     68      *Vot = 0.0;
     69    }   
    4870  }
    49   if (dy < 0) {
    50     DYin = 0;
    51     DYot = -dy;
    52   } else {
    53     DYin = dy;
    54     DYot = 0;
    55   }
    56  
    57   if ((dy > 0) || ((dy == 0) && (dx > 0))) {
    58     for (j = 0; j < ny - fabs(dy); j++) {
    59       Vin = (float *)(buf[0].matrix.buffer) + (j + DYin)*nx + DXin; 
    60       Vot = (float *)(buf[0].matrix.buffer) + (j + DYot)*nx + DXot;
    61       for (i = 0; i < nx - fabs(dx); i++, Vin++, Vot++) {
    62         *Vot = *Vin;
    63       }
    64       if (dx < 0)
    65         Vot = (float *)(buf[0].matrix.buffer) + (j + DYot)*nx;
    66       for (i = 0; i < fabs(dx); i++, Vot++) {
    67         *Vot = 0.0;
    68       }
    69     }
    70     Vot = (float *)(buf[0].matrix.buffer) + nx*(ny - abs(dy));
    71     for (j = 0; j < nx * fabs(dy); j++, Vot++) {
    72       *Vot = 0.0;
    73     }   
    74   } else {
    75     for (j = ny - fabs(dy) - 1; j >= 0; j--) {
    76       Vin = (float *)(buf[0].matrix.buffer) + (j + DYin)*nx + DXin + nx - abs(dx) - 1;
    77       Vot = (float *)(buf[0].matrix.buffer) + (j + DYot)*nx + DXot + nx - abs(dx) - 1;
    78       for (i = 0; i < nx - fabs(dx); i++, Vin--, Vot--) {
    79         *Vot = *Vin;
    80       }
    81       if (dx < 0)
    82         Vot = (float *)(buf[0].matrix.buffer) + (j + DYot)*nx;
    83       for (i = 0; i < fabs(dx); i++, Vot++) {
    84         *Vot = 0.0;
    85       }
    86     }
    87     Vot = (float *)(buf[0].matrix.buffer);
    88     for (j = 0; j < nx * fabs(dy); j++, Vot++) {
    89       *Vot = 0.0;
    90     }
    91   }
    9271
     72  // fill in the exposed y-border with 0.0
     73  Vot = (dy > 0) ?
     74    (float *)(out[0].matrix.buffer) :
     75    (float *)(out[0].matrix.buffer) + (ny - abs(dy))*nx;
     76
     77  for (j = 0; j < nx * abs(dy); j++, Vot++) {
     78    *Vot = 0.0;
     79  }   
     80
     81  // apply the fractional shift
    9382  gprint (GP_ERR, "%f %f\n", fdx, fdy);
    9483  if ((fdx > 0) || (fdy > 0)) {
     
    10190    f11 =    fdx *   fdy;
    10291
    103     Vin = (float *)buf[0].matrix.buffer;
    104     Vot = (float *)buf[0].matrix.buffer;
     92    Vin = (float *)out[0].matrix.buffer;
     93    Vot = (float *)out[0].matrix.buffer;
    10594    for (j = 0; j < ny - 1; j++) {
    10695      for (i = 0; i < nx - 1; i++, Vin++, Vot++) {
    10796        value  = Vin[   0] * f00;
    10897        value += Vin[   1] * f01;
    109         value += Vin[ny  ] * f10;
    110         value += Vin[ny+1] * f11;
     98        value += Vin[nx  ] * f10;
     99        value += Vin[nx+1] * f11;
    111100        *Vot = value;
    112101      }
  • trunk/Ohana/src/opihi/mana/Makefile

    r7917 r9726  
    1919# link flags
    2020LIBS    =       -L$(LIB) -L$(LLIB) -L$(XLIB)
    21 LIBS1   =       -lsocket -lnsl -lreadline $(TLIB) -ldvo -lkapa -lFITS -lohana -lX11 -lpthread -lm
     21LIBS1   =       -lsocket -lnsl -lreadline $(TLIB) -ljpeg -ldvo -lkapa -lFITS -lohana -lX11 -lpthread -lm
    2222# LIBS1   =       -lreadline $(TLIB) -ldvo -lkapa -lFITS -lohana -lX11 -lm
    2323LIBS2   =       -lbasiccmd -ldatacmd -lastrocmd -lshell -ldata
Note: See TracChangeset for help on using the changeset viewer.