Changeset 42395 for trunk/ppImage
- Timestamp:
- Feb 14, 2023, 12:59:09 PM (3 years ago)
- Location:
- trunk/ppImage/src
- Files:
-
- 3 edited
-
burntool.h (modified) (4 diffs)
-
ppImageBurntoolApply.c (modified) (16 diffs)
-
ppImageBurntoolMask.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/burntool.h
r35685 r42395 70 70 #define STAR_RADIUS 4 /* Radius over which a star ctr must be max */ 71 71 #define SKY_MARG 3 /* Horiz offset from burn area for sky */ 72 #define FIT_EDGE 10/* How far beyond saturation to start fit? */72 #define FIT_EDGE 5 /* How far beyond saturation to start fit? */ 73 73 #define Y_SCALE 0.01 /* Scale factor for y in fits */ 74 74 … … 102 102 103 103 /* Fit parameters */ 104 #define FIT_MIN_SLOPE -5.0 /* minimum slope which is a credible fit */104 #define FIT_MIN_SLOPE -10.0 /* minimum slope which is a credible fit */ 105 105 #define FIT_MAX_SLOPE 0.0 /* maximum slope which is a credible fit */ 106 106 … … 144 144 int sxfit; /* starting column for fits */ 145 145 int exfit; /* ending column for fits */ 146 int eyfit; /* y-coord ending column for fits */ 146 147 int nfit; /* how many columns were corrected? */ 147 148 IMTYPE *stamp; /* postage stamp of this object */ … … 176 177 STATIC int burn_restore(int nx, int ny, int NX, IMTYPE *buf, CELL *cell); 177 178 STATIC int burn_apply(int nx, int ny, int NX, IMTYPE *buf, CELL *cell); 178 STATIC int persist_read(CELL *cell, const char *infile, int apply );179 STATIC int persist_write(CELL *cell, const char *outfile );179 STATIC int persist_read(CELL *cell, const char *infile, int apply, int oldfile); 180 STATIC int persist_write(CELL *cell, const char *outfile, int oldfile); 180 181 STATIC int persist_fix(int nx, int ny, int stride, IMTYPE *buf, CELL *cell); 181 182 STATIC int persist_merge(CELL *cell); -
trunk/ppImage/src/ppImageBurntoolApply.c
r35685 r42395 49 49 psF32 satVal = psMetadataLookupF32(NULL, readout->parent->concepts, "CELL.SATURATION"); 50 50 51 /* The new burntool tables and method coming into play in 2022 has a slightly different format (an extra column). Need to differentiate */ 52 psS16 BURNTOOL_STATE_GOOD = psMetadataLookupS16(NULL, config->camera, "BURNTOOL.STATE.GOOD"); 53 51 54 for (int p = 0; p < burntoolData->npersist; p++) { 52 55 OBJBOX *box = &(burntoolData->persist[p]); … … 61 64 62 65 y0 = box->y0; 63 y1 = (box->up) ? ny-1 : 0; 64 dy = (y0<y1) ? +1 : -1; 65 if(box->up) { 66 ys = box->sy; 66 if (BURNTOOL_STATE_GOOD >= 15) { 67 y1 = box->eyfit; 67 68 } else { 68 ys = box->ey; 69 y1 = (box->up) ? ny-1 : 0; 70 } 71 dy = (box->up) ? +1 : -1; 72 if (BURNTOOL_STATE_GOOD >= 15) { 73 ys = (box->up) ? box->sy : box->y0; 74 } else { 75 ys = (box->up) ? box->y1m : box->y1p; 69 76 } 70 77 … … 91 98 for(k=0; k<box->nfit; k++) { 92 99 i = box->xfit[k]; 93 for(j= box->yfit[k]; dy*j<=dy*y1; j+=dy) {100 for(j=ys; dy*j<=dy*y1; j+=dy) { 94 101 psF32 inputPixel = image->data.F32[j][i]; 95 102 if (false && inputPixel >= satVal) { … … 150 157 return NULL; 151 158 } 152 if (persist_read(OTA, burntoolFileName, 1)) { 159 160 /* The new burntool tables and method coming into play in 2022 has a slightly different format (an extra column). Need to differentiate */ 161 psS16 BURNTOOL_STATE_GOOD = psMetadataLookupS16(NULL, config->camera, "BURNTOOL.STATE.GOOD"); 162 int oldfile = 1; 163 if (BURNTOOL_STATE_GOOD >= 15) oldfile = 0; 164 165 if (persist_read(OTA, burntoolFileName, 1,oldfile)) { 153 166 psError(PS_ERR_UNKNOWN, "true", "failed to read burntool file"); 154 167 return NULL; … … 174 187 /* Set the maskValue from the recipes. */ 175 188 psImageMaskType maskValue = options->burntoolMask; 189 190 /* The new burntool tables and method coming into play in 2022 has a slightly different format (an extra column). Need to differentiate */ 191 psS16 BURNTOOL_STATE_GOOD = psMetadataLookupS16(NULL, config->camera, "BURNTOOL.STATE.GOOD"); 176 192 177 193 burntool_cell = (view->cell % 8) * 8 + (view->cell - (view->cell % 8)) / 8; … … 206 222 ); 207 223 #endif 224 225 226 /* do separate masking strategy for old (14 and lower) and new burntool tables*/ 227 if (BURNTOOL_STATE_GOOD >= 15) { 228 printf("DET: New burntool style %d\n",BURNTOOL_STATE_GOOD); 208 229 for (int i = box->sxfit; i<= box->exfit; i++) { 209 230 if (box->up == 0) { 231 for (int j = box->eyfit; j <= box->y0; j++) { 232 #if PPIMAGE_BURNTOOL_DEBUG 233 psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n", 234 i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue); 235 #endif 236 image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue; 237 } 238 } else { 239 for (int j = box->sy; j < box->eyfit ; j++) { 240 #if PPIMAGE_BURNTOOL_DEBUG 241 psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n", 242 i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue); 243 #endif 244 image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue; 245 } 246 } 247 } 248 249 } else { 250 printf("DET: Old burntool style %d\n",BURNTOOL_STATE_GOOD); 251 for (int i = box->sxfit; i<= box->exfit; i++) { 210 252 if (box->up == 0) { 211 253 for (int j = 0; j <= box->y1p; j++) { 212 #if PPIMAGE_BURNTOOL_DEBUG254 #if PPIMAGE_BURNTOOL_DEBUG 213 255 psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n", 214 256 i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue); 215 #endif257 #endif 216 258 image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue; 217 259 } 218 260 } else { 219 261 for (int j = box->y1m; j < image->numRows ; j++) { 220 #if PPIMAGE_BURNTOOL_DEBUG262 #if PPIMAGE_BURNTOOL_DEBUG 221 263 psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n", 222 264 i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue); 223 #endif265 #endif 224 266 image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue; 225 } 226 } 227 } 267 } 268 } 269 } 270 } 271 272 228 273 } 229 274 } … … 235 280 /****************************************************************/ 236 281 /* persist_read(): Read all the persistence trails from a file */ 237 STATIC int persist_read(CELL *cell, const char *infile, int apply )282 STATIC int persist_read(CELL *cell, const char *infile, int apply, int oldfile) 238 283 { 239 284 int i, k, nbox=0; … … 257 302 while(fgets(line, 1024, fp) != NULL) { 258 303 if(line[0] == '#') continue; 259 sscanf(line, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %lf %d %d %d %d", 304 305 /* read-in of new burntool tables (including the eyfit column)*/ 306 if(!oldfile) { 307 sscanf(line, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %lf %d %d %d %d %d", 308 &boxbuf[nbox].cell, &boxbuf[nbox].time, 309 &boxbuf[nbox].cx, &boxbuf[nbox].cy, 310 &boxbuf[nbox].max, &boxbuf[nbox].y0, 311 &boxbuf[nbox].sx, &boxbuf[nbox].sy, 312 &boxbuf[nbox].ex, &boxbuf[nbox].ey, 313 &boxbuf[nbox].y0m, &boxbuf[nbox].y0p, 314 &boxbuf[nbox].y1m, &boxbuf[nbox].y1p, 315 &boxbuf[nbox].x0m, &boxbuf[nbox].x0p, 316 &boxbuf[nbox].x1m, &boxbuf[nbox].x1p, 317 &boxbuf[nbox].func, &boxbuf[nbox].up, 318 &boxbuf[nbox].slope, &boxbuf[nbox].nfit, 319 &boxbuf[nbox].sxfit, &boxbuf[nbox].exfit, 320 &boxbuf[nbox].fiterr,&boxbuf[nbox].eyfit); 321 322 } else { 323 sscanf(line, "%d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %lf %d %d %d %d", 260 324 &boxbuf[nbox].cell, &boxbuf[nbox].time, 261 325 &boxbuf[nbox].cx, &boxbuf[nbox].cy, … … 271 335 &boxbuf[nbox].sxfit, &boxbuf[nbox].exfit, 272 336 &boxbuf[nbox].fiterr); 337 } 338 273 339 if(boxbuf[nbox].nfit > 0) { 274 340 boxbuf[nbox].zero = (double *)calloc(boxbuf[nbox].nfit, sizeof(double)); … … 431 497 box[j].sxfit = MIN(box[j].sxfit, box[k].sxfit); 432 498 box[j].exfit = MAX(box[j].exfit, box[k].exfit); 499 box[j].eyfit = MIN(box[j].eyfit, box[k].eyfit); 433 500 434 501 box[k].exfit = box[k].sxfit - 1; … … 459 526 /****************************************************************/ 460 527 /* persist_write(): Write all the persistence data for the next image */ 461 STATIC int persist_write(CELL *cell, const char *outfile )528 STATIC int persist_write(CELL *cell, const char *outfile, int oldfile) 462 529 { 463 530 int i, k, j, err=0; … … 474 541 fprintf(fp, "# Cell: %d sky= %d rms= %d bias= %d\n", 475 542 cell[0].cell, cell[0].sky, cell[0].rms, cell[0].bias); 476 fprintf(fp, "#Cell time cx cy max y0 sx sy ex ey y0m y0p y1m y1p x0m x0p x1m x1p F up slope nfit sxf exf\n"); 543 544 /*write new burntool tables (including the eyfit column)*/ 545 if(!oldfile) { 546 fprintf(fp, "#Cell time cx cy max y0 sx sy ex ey y0m y0p y1m y1p x0m x0p x1m x1p F up slope nfit sxf exf fiterr eyf\n"); 547 } else { 548 fprintf(fp, "#Cell time cx cy max y0 sx sy ex ey y0m y0p y1m y1p x0m x0p x1m x1p F up slope nfit sxf exf fiterr\n"); 549 } 477 550 478 551 for(j=0; j<MAXCELL; j++) { … … 494 567 if(cell[j].persist[k].nfit <= 0) continue; 495 568 } 496 fprintf(fp, "%3d %7d %3d %3d %5d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %1d %1d %9.6f %3d %3d %3d %d\n", 569 570 /*write new burntool tables (including the eyfit column)*/ 571 if(!oldfile) { 572 fprintf(fp, "%3d %7d %3d %3d %5d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %1d %1d %9.6f %3d %3d %3d %d %3d\n", 573 j, cell[j].persist[k].time, 574 cell[j].persist[k].cx, cell[j].persist[k].cy, 575 cell[j].persist[k].max, cell[j].persist[k].y0, 576 cell[j].persist[k].sx, cell[j].persist[k].sy, 577 cell[j].persist[k].ex, cell[j].persist[k].ey, 578 cell[j].persist[k].y0m, cell[j].persist[k].y0p, 579 cell[j].persist[k].y1m, cell[j].persist[k].y1p, 580 cell[j].persist[k].x0m, cell[j].persist[k].x0p, 581 cell[j].persist[k].x1m, cell[j].persist[k].x1p, 582 cell[j].persist[k].func, cell[j].persist[k].up, 583 cell[j].persist[k].slope, cell[j].persist[k].nfit, 584 cell[j].persist[k].sxfit, cell[j].persist[k].exfit, 585 cell[j].persist[k].fiterr, cell[j].persist[k].eyfit); 586 } else { 587 fprintf(fp, "%3d %7d %3d %3d %5d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %1d %1d %9.6f %3d %3d %3d %d\n", 497 588 j, cell[j].persist[k].time, 498 589 cell[j].persist[k].cx, cell[j].persist[k].cy, … … 508 599 cell[j].persist[k].sxfit, cell[j].persist[k].exfit, 509 600 cell[j].persist[k].fiterr); 601 } 602 510 603 for(i=0; i<cell[j].persist[k].nfit; i++) { 511 604 fprintf(fp, "%3d %3d %8.4f\n", cell[j].persist[k].xfit[i], … … 531 624 532 625 i = (cell[j].burn[k].ex - cell[j].burn[k].sx + 1) / 2; 533 fprintf(fp, "%3d %7d %3d %3d %5d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %1d %1d %9.6f %3d %3d %3d %d\n", 626 627 if(!oldfile) { 628 fprintf(fp, "%3d %7d %3d %3d %5d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %1d %1d %9.6f %3d %3d %3d %d %3d\n", 629 j, cell[j].burn[k].time, 630 cell[j].burn[k].cx, cell[j].burn[k].cy, 631 cell[j].burn[k].max, cell[j].burn[k].y0, 632 cell[j].burn[k].sx, cell[j].burn[k].sy, 633 cell[j].burn[k].ex, cell[j].burn[k].ey, 634 cell[j].burn[k].y0m, cell[j].burn[k].y0p, 635 cell[j].burn[k].y1m, cell[j].burn[k].y1p, 636 cell[j].burn[k].x0m, cell[j].burn[k].x0p, 637 cell[j].burn[k].x1m, cell[j].burn[k].x1p, 638 cell[j].burn[k].func, cell[j].burn[k].up, 639 cell[j].burn[k].slope, cell[j].burn[k].nfit, 640 cell[j].burn[k].sxfit, cell[j].burn[k].exfit, 641 cell[j].burn[k].fiterr, cell[j].burn[k].eyfit); 642 } else { 643 fprintf(fp, "%3d %7d %3d %3d %5d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %1d %1d %9.6f %3d %3d %3d %d\n", 534 644 j, cell[j].burn[k].time, 535 645 cell[j].burn[k].cx, cell[j].burn[k].cy, … … 545 655 cell[j].burn[k].sxfit, cell[j].burn[k].exfit, 546 656 cell[j].burn[k].fiterr); 657 } 658 547 659 for(i=0; i<cell[j].burn[k].nfit; i++) { 548 660 fprintf(fp, "%3d %3d %8.4f\n", cell[j].burn[k].xfit[i], -
trunk/ppImage/src/ppImageBurntoolMask.c
r26895 r42395 24 24 } 25 25 long Nrows = psFitsTableSize(fits); 26 27 26 long row = 0; 28 27 29 28 psLogMsg ("ppImageBurntoolMask", 4, "Inside burntool mask %ld", Nrows); 30 29 30 /* The new burntool tables and method coming into play in 2022 has a slightly different format (an extra column). Need to differentiate */ 31 psS16 BURNTOOL_STATE_GOOD = psMetadataLookupS16(NULL, config->camera, "BURNTOOL.STATE.GOOD"); 32 31 33 /* Redirects and Memory juggling. */ 32 34 view->readout = 0; 33 35 psImage *image = mask->mask; 34 35 36 36 37 /* Set the maskValue from the recipes. */ … … 64 65 ); 65 66 #endif 66 for (int i = psMetadataLookupS32(&status,rowMD,"sxfit"); 67 68 /* do separate masking strategy for old (14 and lower) and new burntool tables*/ 69 if (BURNTOOL_STATE_GOOD >= 15) { 70 for (int i = psMetadataLookupS32(&status,rowMD,"sxfit"); 67 71 i <= psMetadataLookupS32(&status,rowMD,"exfit"); 68 72 i++) { 69 73 70 if (psMetadataLookupS32(&status,rowMD,"up") == 0) {71 for (int j = 0; j <= psMetadataLookupS32(&status,rowMD,"y1p"); j++) {72 #if PPIMAGE_BURNTOOL_DEBUG73 psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n",74 if (psMetadataLookupS32(&status,rowMD,"up") == 0) { 75 for (int j = psMetadataLookupS32(&status,rowMD,"eyfit"); j <= psMetadataLookupS32(&status,rowMD,"y0"); j++) { 76 #if PPIMAGE_BURNTOOL_DEBUG 77 psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n", 74 78 i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue); 75 #endif 76 image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue; 79 #endif 80 image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue; 81 } 82 } else { 83 for (int j = psMetadataLookupS32(&status,rowMD,"sy"); j < psMetadataLookupS32(&status,rowMD,"eyfit") ; j++) { 84 #if PPIMAGE_BURNTOOL_DEBUG 85 psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n", 86 i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue); 87 #endif 88 image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue; 89 } 77 90 } 78 91 } 79 else { 80 for (int j = psMetadataLookupS32(&status,rowMD,"y1m"); j < image->numRows ; j++) { 81 #if PPIMAGE_BURNTOOL_DEBUG 82 psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n", 92 } else { 93 for (int i = psMetadataLookupS32(&status,rowMD,"sxfit"); 94 i <= psMetadataLookupS32(&status,rowMD,"exfit"); 95 i++) { 96 97 if (psMetadataLookupS32(&status,rowMD,"up") == 0) { 98 for (int j = 0; j <= psMetadataLookupS32(&status,rowMD,"y1p"); j++) { 99 #if PPIMAGE_BURNTOOL_DEBUG 100 psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n", 83 101 i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue); 84 #endif 85 image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue; 102 #endif 103 image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue; 104 } 105 } 106 else { 107 for (int j = psMetadataLookupS32(&status,rowMD,"y1m"); j < image->numRows ; j++) { 108 #if PPIMAGE_BURNTOOL_DEBUG 109 psLogMsg("ppImageBurntoolMask", 4, "Noisy!: %d %d %d %d\n", 110 i,j,image->data.PS_TYPE_IMAGE_MASK_DATA[j][i],maskValue); 111 #endif 112 image->data.PS_TYPE_IMAGE_MASK_DATA[j][i] |= maskValue; 113 } 86 114 } 87 115 } 116 88 117 } 118 89 119 90 120 }
Note:
See TracChangeset
for help on using the changeset viewer.
