Changeset 42857
- Timestamp:
- May 12, 2025, 2:52:42 PM (14 months ago)
- Location:
- trunk/extsrc/gpcsw/gpcsrc/fits/burntool
- Files:
-
- 2 edited
-
burnfix.c (modified) (2 diffs)
-
burntool.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/extsrc/gpcsw/gpcsrc/fits/burntool/burnfix.c
r42724 r42857 13 13 #include "burntool.h" 14 14 #include "burnparams.h" 15 16 17 #define DIFFERENT_STREAK_BURN 20 /* Proximity for union versus intersection */ 18 19 # define myMAXSIZE 20000 20 21 22 /****************************************************************/ 23 /* burn_merge(): Disentangle overlapping burns */ 24 STATIC int burn_merge(CELL *cell) 25 { 26 int i, j, k, n, nbox, xs, xe; 27 int jp, kp,xdiff; 28 int lapmax; 29 OBJBOX *box; 30 int xusage[myMAXSIZE], yctr[myMAXSIZE], boxid[myMAXSIZE]; 31 double zk, zj; 32 33 /* Look at all the boxes -- if not isolated then merge or sever */ 34 nbox = cell->nburn; 35 box = cell->burn; 36 37 /* Assess the clustering of all the streaks */ 38 for(i=0; i<myMAXSIZE; i++) xusage[i] = 0; 39 for(i=0; i<myMAXSIZE; i++) boxid[i] = -1; 40 for(k=0; k<nbox; k++) { 41 if(box[k].ex >= myMAXSIZE-1) continue; 42 for(i=box[k].sx; i<=box[k].ex; i++) xusage[i] += 1; 43 } 44 45 /* Identify clusters */ 46 for(xs=0; xs<myMAXSIZE-1; xs++) { 47 if(xusage[xs] == 0) continue; 48 for(xe=xs, lapmax=0; xe<myMAXSIZE-1; xe++) { 49 if(xusage[xe+1] == 0) break; 50 lapmax = MAX(lapmax, xusage[xe]); 51 } 52 if(lapmax == 1) { /* No overlap? No problem. */ 53 xs = xe + 1; /* Hop to next gap */ 54 continue; 55 } 56 57 /* Which boxes overlap this cluster? */ 58 for(k=n=0; k<nbox; k++) { 59 if(box[k].sx > xe || box[k].ex < xs) continue; 60 boxid[n] = k; 61 //yctr[n] = (box[k].y0m+box[k].y1m+box[k].y0p+box[k].y1p+2) / 4; 62 yctr[n] = (box[k].sy+box[k].ey+1) / 2; 63 n++; 64 } 65 66 for(kp=0; kp<n; kp++) { 67 k = boxid[kp]; 68 zk = 0.0; 69 if(box[k].nfit > 0) zk = box[k].zero[box[k].nfit/2]; 70 for(jp=kp+1; jp<n; jp++) { 71 j = boxid[jp]; 72 zj = 0.0; 73 if(box[j].nfit > 0) zj = box[j].zero[box[j].nfit/2]; 74 if(box[j].sx > box[k].sx) xdiff = box[j].sx - box[k].ex; 75 if(box[j].sx <= box[k].sx) xdiff = box[k].sx - box[j].ex; 76 77 /* CZW: Since I added the initialization statement above, */ 78 /* any box with boxid == -1 hasn't been set, and */ 79 /* therefore needs to be dropped, I think. */ 80 if ((k < 0)||(j < 0)) { continue; } 81 82 /*Tdb20220222: In the case of overlapping x-coords but not overlapping y-coords*/ 83 /*I fail to see the need to change the x-range of any streaks. That just spells disaster*/ 84 // Case 1: different y start => sever 85 if(ABS(yctr[jp]-yctr[kp]) > DIFFERENT_STREAK_BURN) { 86 // Trim back the feebler streak 87 if(zk > zj) { 88 /* 89 if(box[j].sxfit >= box[k].sxfit) 90 box[j].sxfit = MAX(box[j].sxfit, box[k].exfit+1); 91 if(box[j].exfit <= box[k].exfit) 92 box[j].exfit = MIN(box[j].exfit, box[k].sxfit-1); 93 */ 94 } else { 95 /* 96 if(box[k].sxfit >= box[j].sxfit) 97 box[k].sxfit = MAX(box[k].sxfit, box[j].exfit+1); 98 if(box[k].exfit <= box[j].exfit) 99 box[k].exfit = MIN(box[k].exfit, box[j].sxfit-1); 100 */ 101 } 102 } 103 104 /* Case 2: pretty much the same y start => union */ 105 if((ABS(yctr[jp]-yctr[kp]) <= DIFFERENT_STREAK_BURN) && (xdiff < 0) ) { 106 /* Merge k into j, trash k from further consideration */ 107 box[j].time = MAX(box[j].time, box[k].time); 108 box[j].sx = MIN(box[j].sx, box[k].sx); 109 box[j].ex = MAX(box[j].ex, box[k].ex); 110 box[j].sy = MIN(box[j].sy, box[k].sy); 111 box[j].ey = MAX(box[j].ey, box[k].ey); 112 box[j].y0m = MIN(box[j].y0m, box[k].y0m); 113 box[j].y0p = MAX(box[j].y0p, box[k].y0p); 114 box[j].x0m = MIN(box[j].x0m, box[k].x0m); 115 box[j].x0p = MAX(box[j].x0p, box[k].x0p); 116 box[j].y1m = MIN(box[j].y1m, box[k].y1m); 117 box[j].y1p = MAX(box[j].y1p, box[k].y1p); 118 box[j].x1m = MIN(box[j].x1m, box[k].x1m); 119 box[j].x1p = MAX(box[j].x1p, box[k].x1p); 120 box[j].sxfit = MIN(box[j].sxfit, box[k].sxfit); 121 box[j].exfit = MAX(box[j].exfit, box[k].exfit); 122 box[j].eyfit = MIN(box[j].eyfit, box[k].eyfit); 123 124 box[k].exfit = -999; 125 yctr[kp] = -2 * DIFFERENT_STREAK_BURN; 126 } 127 } 128 } 129 130 xs = xe + 1; /* Hop to next gap */ 131 132 } /* Cluster loop */ 133 134 /* Excise the boxes which have been eradicated (sxfit > exfit) */ 135 for(k=0; k<nbox; k++) { 136 if(box[k].exfit < 0) { 137 for(j=k; j<nbox-1; j++) memcpy(box+j, box+j+1, sizeof(OBJBOX)); 138 nbox--; 139 k--; 140 } 141 } 142 cell->nburn = nbox; 143 144 145 return(0); 146 } 15 147 16 148 /****************************************************************/ … … 47 179 if(!cell->burn[k].fiterr) sub_fit(nx, ny, NX, buf, cell->burn+k, 1); 48 180 } 181 182 183 /* Merge all overlapping streaks */ 184 burn_merge(cell); 49 185 50 186 /* For testing, blow away the data in favor of the mask */ -
trunk/extsrc/gpcsw/gpcsrc/fits/burntool/burntool.h
r42724 r42857 181 181 STATIC int persist_fix(int nx, int ny, int stride, IMTYPE *buf, CELL *cell,char *camera); 182 182 STATIC int persist_merge(CELL *cell); 183 STATIC int burn_merge(CELL *cell); 183 184 184 185 //fh_result persist_fits_read(CELL *cell, const char *filename, int apply);
Note:
See TracChangeset
for help on using the changeset viewer.
