Changeset 4188 for trunk/psphot/src/find_defects.c
- Timestamp:
- Jun 9, 2005, 6:28:24 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/find_defects.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/find_defects.c
r4129 r4188 10 10 float gradx, grady, gradlim; 11 11 float N0, N1, peak, sky; 12 int x, y; 12 int x, y, Nzap; 13 14 psTimerStart ("psphot"); 13 15 14 16 // measure the x and y max gradients … … 56 58 57 59 // search for pixels with (dfdy > grady) or (dfdx > gradx) allowing for Nsigma outliers 60 Nzap = 0; 58 61 for (int i = 0; i < sources->n; i++) { 59 62 psSource *source = sources->data[i]; … … 66 69 sky = source->moments->Sky; 67 70 peak = source->moments->Peak - sky; 71 if (peak < 0) continue; 68 72 if (peak < peak*PS_MIN(gradx, grady) + NSIGMA*sqrt(2*sky + peak)) continue; 69 73 psTrace (".psphot.defects", 4, "peak: %f, SN: %f\n", peak, source->moments->SN); … … 74 78 N0 = image->data.F32[iy][ix]; 75 79 N1 = image->data.F32[iy][ix + 1]; 76 gradlim = fabs(N1 - N0 - NSIGMA*(sqrt(N1) + sqrt(N0))) / peak; 77 // XXX this line is wrong: we should use the appropriate noise from the noise map 80 gradlim = fabs(N1 - N0) - NSIGMA*(sqrt(N1 + N0)); 81 // gradient - N*sigma 82 gradlim = gradlim / peak; 78 83 79 84 // if gradient is too large, zap the high pixel 80 85 if (gradlim < gradx) continue; 81 if (N1 > N0) { 86 if (N0 > N1) { 87 zap->data.U8[iy][ix] = 1; 88 } else { 82 89 zap->data.U8[iy][ix + 1] = 1; 83 } else {84 zap->data.U8[iy][ix] = 1;85 90 } 86 91 } … … 92 97 N0 = image->data.F32[iy][ix]; 93 98 N1 = image->data.F32[iy + 1][ix]; 94 gradlim = fabs(N1 - N0 - NSIGMA*(sqrt(N1) + sqrt(N0))) / peak;95 // XXX this line is wrong: we should use the appropriate noise from the noise map99 gradlim = fabs(N1 - N0) - NSIGMA*(sqrt(N1 + N0)); 100 gradlim = gradlim / peak; 96 101 97 102 // if gradient is too large, zap the high pixel 98 103 // note the inefficiency: we are re-testing known zapped entries 99 if (gradlim > grady) continue; 100 if (N1 > N0) { 104 if (gradlim < grady) continue; 105 if (N0 > N1) { 106 zap->data.U8[iy][ix] = 1; 107 } else { 101 108 zap->data.U8[iy + 1][ix] = 1; 102 } else {103 zap->data.U8[iy][ix] = 1;104 109 } 105 110 } 106 111 } 107 psFree (zap);108 112 109 113 // mask & zero the zapped pixels … … 114 118 y = iy + image->row0; 115 119 zapmask->data.F32[y][x] = 1; 120 Nzap ++; 116 121 } 117 122 } 123 psFree (zap); 118 124 119 125 } 126 psLogMsg ("psphot", 3, "zap: %f sec, %d pixels\n", psTimerMark ("psphot"), Nzap); 127 120 128 return (true); 121 129 }
Note:
See TracChangeset
for help on using the changeset viewer.
