Changeset 11186
- Timestamp:
- Jan 19, 2007, 12:16:23 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotFindPeaks.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotFindPeaks.c
r11169 r11186 2 2 3 3 // In this function, we smooth the image, then search for the peaks 4 psArray *psphotFindPeaks (pmReadout *readout, psMetadata *recipe ) {4 psArray *psphotFindPeaks (pmReadout *readout, psMetadata *recipe, int pass) { 5 5 6 float SIGMA_SMTH, NSIGMA_SMTH, NSIGMA_PEAK; 6 7 bool status = false; 7 8 … … 9 10 psTimerStart ("psphot"); 10 11 11 float SIGMA = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_SIGMA"); 12 float NSIGMA = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA"); 12 if (pass == 1) { 13 SIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_SIGMA"); 14 NSIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA"); 15 } else { 16 bool status_x, status_y; 17 float FWHM_X = psMetadataLookupF32 (&status_x, recipe, "FWHM_X"); 18 float FWHM_Y = psMetadataLookupF32 (&status_y, recipe, "FWHM_Y"); 19 if (!status_x | !status_y) psAbort ("psphotFindPeaks", "FWHM_X or FWHM_Y not defined"); 20 SIGMA_SMTH = 0.5*(FWHM_X + FWHM_Y) / (2.0*sqrt(2.0*log(2.0))); 21 NSIGMA_SMTH = psMetadataLookupF32 (&status, recipe, "PEAKS_SMOOTH_NSIGMA"); 22 } 13 23 14 24 // smooth the image, applying the mask as we go 15 25 psImage *smooth_im = psImageCopy (NULL, readout->image, PS_TYPE_F32); 16 psImageSmoothMaskF32 (smooth_im, readout->mask, 0xff, SIGMA , NSIGMA);26 psImageSmoothMaskF32 (smooth_im, readout->mask, 0xff, SIGMA_SMTH, NSIGMA_SMTH); 17 27 psLogMsg ("psphot", PS_LOG_MINUTIA, "smooth image: %f sec\n", psTimerMark ("psphot")); 18 28 19 29 // smooth the weight, applying the mask as we go 20 30 psImage *smooth_wt = psImageCopy (NULL, readout->weight, PS_TYPE_F32); 21 psImageSmoothMaskF32 (smooth_wt, readout->mask, 0xff, SIGMA /sqrt(2), NSIGMA);31 psImageSmoothMaskF32 (smooth_wt, readout->mask, 0xff, SIGMA_SMTH/sqrt(2), NSIGMA_SMTH); 22 32 psLogMsg ("psphot", PS_LOG_MINUTIA, "smooth weight: %f sec\n", psTimerMark ("psphot")); 23 33 … … 52 62 53 63 // signal/noise limit for the detected peaks 54 NSIGMA = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT"); 55 56 // we need to define the threshold based on the value of NSIGMA and the applied smoothing 64 if (pass == 1) { 65 NSIGMA_PEAK = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT"); 66 } else { 67 NSIGMA_PEAK = psMetadataLookupF32 (&status, recipe, "PEAKS_NSIGMA_LIMIT_2"); 68 } 69 70 // we need to define the threshold based on the value of NSIGMA_PEAK and the applied smoothing 57 71 // gaussian SIGMA. a peak in the significance image has an effective S/N for faint sources 58 72 // of (S = Io*2pi*sigma_eff^2) / sqrt(Var), where sigma_eff^2 = sigma_obs^2 + sigma_sm^2. … … 64 78 // S/N = sqrt(Io)*4*pi*sigma_sm^2 65 79 // thus, the threshold is: 66 float effArea = 4.0*M_PI*PS_SQR(SIGMA );67 float threshold = PS_SQR(NSIGMA ) / effArea;80 float effArea = 4.0*M_PI*PS_SQR(SIGMA_SMTH); 81 float threshold = PS_SQR(NSIGMA_PEAK) / effArea; 68 82 69 83 // find the peaks in the smoothed image
Note:
See TracChangeset
for help on using the changeset viewer.
