IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 15, 2024, 10:57:32 AM (21 months ago)
Author:
tdeboer
Message:

updated working for gpc2 burntool, inclduing adding camera keyword

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/extsrc/gpcsw/gpcsrc/fits/burntool/burnfix.c

    r42392 r42724  
    1717/* burn_fix(): Find and fix all the burned patches in a cell */
    1818STATIC int burn_fix(int nx, int ny, int NX, int NY, IMTYPE *buf,
    19                     CELL *cell, int cellnum)
     19                    CELL *cell, int cellnum, char *camera)
    2020{
    2121   int k, err;
    2222
    2323/* Find all the burned patches and bright stars */
    24    err = star_detect(nx, ny, NX, NY, imbuf, mbuf, msbuf, cell, cellnum);
    25 
    26    err = burn_check(nx, ny, NX, NY, imbuf, mbuf, cell);
     24   err = star_detect(nx, ny, NX, NY, imbuf, mbuf, msbuf, cell, cellnum, camera);
     25
     26   err = burn_check(nx, ny, NX, NY, imbuf, mbuf, cell, camera);
    2727
    2828//   fprintf(stderr, "Got through burn_check\n");
    2929
    3030/* Expand the masks; burns asymmetrically, stars symmetrically */
    31 //   err = grow_mask(nx, ny, NX, mbuf, YMASK_GROW, YMASK_GROW, cell->nstar, cell->star);
    32 //   err = grow_mask(nx, ny, NX, mbuf, XMASK_GROW, YMASK_GROW, cell->nburn, cell->burn);
    3331   err = grow_mask(nx, ny, NX, mbuf, BMASK_GROW, RMASK_GROW,
    3432                   MASK_SAT_HALO, cell->nburn, cell->burn);
     
    4442//      fprintf(stderr, "Fitting trail %d\n", k);
    4543      fit_trail(nx, ny, NX, imbuf, mbuf, cell->burn+k, 1,
    46              cell->sky+cell->bias, cell->rms, BURN_PWR);
     44             cell->sky+cell->bias, cell->rms, BURN_PWR, camera);
    4745/* Subtract the fit from the image */
    4846//      fprintf(stderr, "Subtracting trail %d\n", k);
     
    5452      for(k=0; k<NX*ny; k++) buf[k] = mbuf[k] - BZERO;
    5553   }
     54   
    5655   return(err);
    5756}
     
    106105/****************************************************************/
    107106/* burn_restore(): Restore the fitted trails back to the image */
    108 STATIC int burn_restore(int nx, int ny, int NX, IMTYPE *buf, CELL *cell)
     107STATIC int burn_restore(int nx, int ny, int NX, IMTYPE *buf, CELL *cell, char *camera)
    109108{
    110109   int k;
     
    124123/****************************************************************/
    125124/* burn_apply(): Subtract the trail fits from the image */
    126 STATIC int burn_apply(int nx, int ny, int NX, IMTYPE *buf, CELL *cell)
     125STATIC int burn_apply(int nx, int ny, int NX, IMTYPE *buf, CELL *cell, char *camera)
    127126{
    128127   int k;
     
    143142/* burn_check(): Find all the burned patches in a cell */
    144143STATIC int burn_check(int nx, int ny, int NX, int NY, DTYPE *data,
    145                        MTYPE *mask, CELL *cell)
     144                       MTYPE *mask, CELL *cell, char *camera)
    146145{
    147146   int err,k;
     
    153152         continue;
    154153      }
    155       err = burn_test(nx, ny, NX, data, cell->rms, mask, cell->burn+k);
     154      err = burn_test(nx, ny, NX, data, cell->rms, mask, cell->burn+k, camera);
    156155   }
    157156
     
    240239 */
    241240STATIC int burn_test(int nx, int ny, int NX, DTYPE *data, int rms,
    242                        MTYPE *mask, OBJBOX *box)
     241                       MTYPE *mask, OBJBOX *box, char *camera)
    243242{
    244243   int i, j, nburn, nref, nmed;
    245    int y0, y1, ymid, xburn, xref, dx=0, dy=0;
     244   int y0, y1, x0, x1, xwidth, ymid, xburn, xref, dx=0, dy=0;
    246245
    247246   /*introduce a maximum to the burn contrast check, to avoid a very large number in crowded regions*/
     
    275274      y0 = ymid + MAX(box->ey-ymid, FIT_EDGE);
    276275      y1 = MIN(y0+100, ny-1);
     276      x0 = box->sx;
     277      x1 = box->ex;
    277278
    278279      if(2*box->ex - box->sx + 1 < nx-1) {      /* Work right? */
     
    294295      dx = 0;
    295296      dy = MAX(ymid-box->sy, box->ey-ymid);
     297     
     298      if(!strcmp(camera,"gpc2")) {
     299        /*start right at the edge of the star box might not be the best*/
     300        /*add 20% of box size on top, with a maximum of ten pixels*/
     301        dy = dy + MIN((box->ey-box->sy)/5,10);
     302
     303        /*Use the inner third of the star width for this test. Should be brightest there*/
     304        xwidth = MAX((box->ex-box->sx)/3,10);     
     305        x0 = box->sx + (box->ex-box->sx)/2 - xwidth/2;
     306        x1 = box->sx + (box->ex-box->sx)/2 + xwidth/2;
     307      } else {
     308        //regular gpc1 setup
     309        x0 = box->sx;
     310        x1 = box->ex;
     311      }
     312     
    296313      if(dy < FIT_EDGE) dy = FIT_EDGE;
    297314      y0 = ymid + dy;
    298315      y1 = y0 + MIN(ny-1-y0, 2*ymid-y0-1);
    299316      if(y1-y0 > test_box) y1 = y0 + test_box;
     317     
     318   }
     319   if(VERBOSE & VERB_BOXGROW) {
     320     printf("test input dx,dy,x0,x1, y0, y1, test_box, ymid: %8d %8d %8d %8d %8d %8d %8d %8d\n", dx,dy,x0,x1, y0, y1, test_box, ymid);
    300321   }
    301322
     
    305326      xburn = xref = 0;
    306327      nburn = nref = 0;
    307       for(i=box->sx; i<=box->ex; i++) {
     328      for(i=x0; i<=x1; i++) {
    308329             if(mask[i+j*NX] == MASK_NONE) {
    309330               xburn += data[i+j*NX];
     
    326347      if(nref > 0 && nburn > 0) median_buf[nmed++] = xburn - xref;
    327348      if(VERBOSE & VERB_BOXGROW) {
    328         printf("contrast: %8d %8d %8d %8d %8d\n", j, xburn, (2*ymid-j), xref, xburn - xref);
     349        printf("contrast: %8d %8d %8d %8d %8d %8d %8d\n", j, xburn,nburn, (2*ymid-j), xref,nref, xburn - xref);
    329350      }
    330351
     
    332353   box->diff = int_median(nmed, median_buf);
    333354   box->burned = (box->diff > burn_contrast);
     355   if(VERBOSE & VERB_BOXGROW) {
     356     printf("test output: %8d %8d %8d\n", box->burned, burn_contrast, box->diff);
     357   }
     358
    334359   return(0);
    335360}
     
    344369/* burn_test() tests whether a box is burned or not */
    345370STATIC int burn_test(int nx, int ny, int NX, DTYPE *data, int rms,
    346                        MTYPE *mask, OBJBOX *box)
     371                       MTYPE *mask, OBJBOX *box, char *camera)
    347372{
    348373   int i, j, n, nrow, nmed;
Note: See TracChangeset for help on using the changeset viewer.