- Timestamp:
- Dec 6, 2024, 1:28:47 PM (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20230313/extsrc/gpcsw/gpcsrc/fits/burntool/burnfix.c
r42392 r42753 17 17 /* burn_fix(): Find and fix all the burned patches in a cell */ 18 18 STATIC 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) 20 20 { 21 21 int k, err; 22 22 23 23 /* 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); 27 27 28 28 // fprintf(stderr, "Got through burn_check\n"); 29 29 30 30 /* 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);33 31 err = grow_mask(nx, ny, NX, mbuf, BMASK_GROW, RMASK_GROW, 34 32 MASK_SAT_HALO, cell->nburn, cell->burn); … … 44 42 // fprintf(stderr, "Fitting trail %d\n", k); 45 43 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); 47 45 /* Subtract the fit from the image */ 48 46 // fprintf(stderr, "Subtracting trail %d\n", k); … … 54 52 for(k=0; k<NX*ny; k++) buf[k] = mbuf[k] - BZERO; 55 53 } 54 56 55 return(err); 57 56 } … … 106 105 /****************************************************************/ 107 106 /* 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 )107 STATIC int burn_restore(int nx, int ny, int NX, IMTYPE *buf, CELL *cell, char *camera) 109 108 { 110 109 int k; … … 124 123 /****************************************************************/ 125 124 /* burn_apply(): Subtract the trail fits from the image */ 126 STATIC int burn_apply(int nx, int ny, int NX, IMTYPE *buf, CELL *cell )125 STATIC int burn_apply(int nx, int ny, int NX, IMTYPE *buf, CELL *cell, char *camera) 127 126 { 128 127 int k; … … 143 142 /* burn_check(): Find all the burned patches in a cell */ 144 143 STATIC 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) 146 145 { 147 146 int err,k; … … 153 152 continue; 154 153 } 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); 156 155 } 157 156 … … 240 239 */ 241 240 STATIC 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) 243 242 { 244 243 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; 246 245 247 246 /*introduce a maximum to the burn contrast check, to avoid a very large number in crowded regions*/ … … 275 274 y0 = ymid + MAX(box->ey-ymid, FIT_EDGE); 276 275 y1 = MIN(y0+100, ny-1); 276 x0 = box->sx; 277 x1 = box->ex; 277 278 278 279 if(2*box->ex - box->sx + 1 < nx-1) { /* Work right? */ … … 294 295 dx = 0; 295 296 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 296 313 if(dy < FIT_EDGE) dy = FIT_EDGE; 297 314 y0 = ymid + dy; 298 315 y1 = y0 + MIN(ny-1-y0, 2*ymid-y0-1); 299 316 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); 300 321 } 301 322 … … 305 326 xburn = xref = 0; 306 327 nburn = nref = 0; 307 for(i= box->sx; i<=box->ex; i++) {328 for(i=x0; i<=x1; i++) { 308 329 if(mask[i+j*NX] == MASK_NONE) { 309 330 xburn += data[i+j*NX]; … … 326 347 if(nref > 0 && nburn > 0) median_buf[nmed++] = xburn - xref; 327 348 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); 329 350 } 330 351 … … 332 353 box->diff = int_median(nmed, median_buf); 333 354 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 334 359 return(0); 335 360 } … … 344 369 /* burn_test() tests whether a box is burned or not */ 345 370 STATIC 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) 347 372 { 348 373 int i, j, n, nrow, nmed;
Note:
See TracChangeset
for help on using the changeset viewer.
