IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 29, 2019, 5:06:07 AM (7 years ago)
Author:
eugene
Message:

add -mean option to medimage

File:
1 edited

Legend:

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

    r40623 r40654  
    5858int medimage_calc (int argc, char **argv) {
    5959
    60   int ix, iy, n;
     60  int ix, iy, n, N;
    6161  Buffer *output;
    6262
    63   if (argc != 3) {
    64     gprint (GP_ERR, "USAGE: medimage calc (name) (output)\n");
     63  int CALC_MEAN = FALSE;
     64  if ((N = get_argument (argc, argv, "-mean"))) {
     65    CALC_MEAN = TRUE;
     66    remove_argument (N, &argc, argv);
     67  }
     68
     69  if (argc != 3) {
     70    gprint (GP_ERR, "USAGE: medimage calc (name) (output) [-mean]\n");
    6571    gprint (GP_ERR, "       calculate the median image for the median image set\n");
    6672    return FALSE;
     
    101107      if (N == 0) continue;
    102108
    103       fsort (value, N);
    104       outvalue[Npix] = value[(int)(0.5*N)];
     109      if (CALC_MEAN) {
     110        float sum = 0.0;
     111        for (n = 0; n < N; n++) {
     112          sum += value[n];
     113        }
     114        outvalue[Npix] = sum / (float) N;
     115      } else {
     116        fsort (value, N);
     117        outvalue[Npix] = value[(int)(0.5*N)];
     118      }
    105119    }
    106120  }
Note: See TracChangeset for help on using the changeset viewer.