Changeset 4188
- Timestamp:
- Jun 9, 2005, 6:28:24 AM (21 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 3 edited
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 } -
trunk/psphot/src/psUtils.c
r4129 r4188 1 1 # include "psphot.h" 2 3 static psHash *timers = NULL;4 2 5 3 // set actual region based on image parameters … … 21 19 } 22 20 21 static psHash *timers = NULL; 23 22 24 23 // start/restart a named timer … … 110 109 } 111 110 return (TRUE); 111 } 112 113 // find the location of the specified argument 114 int psArgumentGet (int argc, char **argv, char *arg) { 115 116 int i; 117 118 for (i = 0; i < argc; i++) { 119 if (!strcmp(argv[i], arg)) 120 return (i); 121 } 122 123 return ((int)NULL); 124 } 125 126 // remove the specified argument (by location) 127 int psArgumentRemove (int N, int *argc, char **argv) { 128 129 int i; 130 131 if ((N != (int)NULL) && (N != 0)) { 132 (*argc)--; 133 for (i = N; i < *argc; i++) { 134 argv[i] = argv[i+1]; 135 } 136 } 137 138 return (N); 112 139 } 113 140 -
trunk/psphot/src/psphot.c
r4129 r4188 34 34 psf = choose_psf_model (image, config, sources); 35 35 36 psImage *zap = psImageAlloc (image->numCols, image->numRows, PS_TYPE_F32); 37 psImageInit (zap, 0); 38 find_defects (zap, sources, config, psf); 39 dump_image (zap, argv[2]); 40 exit (0); 36 if (0) { 37 psImage *zap = psImageAlloc (image->numCols, image->numRows, PS_TYPE_F32); 38 psImageInit (zap, 0); 39 find_defects (zap, sources, config, psf); 40 dump_image (zap, argv[2]); 41 exit (0); 42 } 41 43 42 44 // test PSF on all except SATURATE and DEFECT (artifacts)
Note:
See TracChangeset
for help on using the changeset viewer.
