IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30903


Ignore:
Timestamp:
Mar 14, 2011, 3:07:22 PM (15 years ago)
Author:
eugene
Message:

psphotSignificanceImage now returns a pmReadout so we can keep the smoothed signal image as well as the S/N image; psphotCullPeaks (and pmFootprintCullPeaks) now uses the smooted image to cull the peaks -- this deals better with low-significance detections are large, low-surface brightness areas

Location:
branches/eam_branches/ipp-20110213/psphot/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110213/psphot/src/psphot.h

    r30883 r30903  
    173173
    174174// used by psphotFindDetections
    175 psImage        *psphotSignificanceImage (pmReadout *readout, psMetadata *recipe, psImageMaskType maskVal);
     175pmReadout      *psphotSignificanceImage (pmReadout *readout, psMetadata *recipe, psImageMaskType maskVal);
    176176psArray        *psphotFindPeaks (psImage *significance, pmReadout *readout, psMetadata *recipe, const float threshold, const int nMax);
    177 bool            psphotFindFootprints (pmDetections *detections, psImage *significance, pmReadout *readout, psMetadata *recipe, const float threshold, const int pass, psImageMaskType maskVal);
    178 psErrorCode     psphotCullPeaks(const pmReadout *readout, const psMetadata *recipe, psArray *footprints);
     177bool            psphotFindFootprints (pmDetections *detections, pmReadout *significance, pmReadout *readout, psMetadata *recipe, const float threshold, const int pass, psImageMaskType maskVal);
     178psErrorCode     psphotCullPeaks(const pmReadout *readout, const pmReadout *signifRO, const psMetadata *recipe, psArray *footprints);
    179179
    180180// in psphotApResid.c:
  • branches/eam_branches/ipp-20110213/psphot/src/psphotCullPeaks.c

    r30869 r30903  
    66psErrorCode
    77psphotCullPeaks(const pmReadout *readout,   // the image wherein lives the footprint
     8                const pmReadout *signifR, // smoothed image and significance
    89                const psMetadata *recipe,
    910                psArray *footprints) {  // array of pmFootprints
     
    2627    psAssert (status, "cannot find SKY_STDEV in readout->analysis");
    2728
    28     const float MIN_THRESHOLD = nsigma_min*skyStdev;
     29    // the sky has been smoothed, so we need to scale down the raw sky stdev by this amount:
     30    float scaleFactor = psMetadataLookupF32(&status, readout->analysis, "SIGNIFICANCE_SCALE_FACTOR");
     31    if (!status) scaleFactor = 1.0;
     32
     33    const float MIN_THRESHOLD = nsigma_min*skyStdev / sqrt(scaleFactor);
    2934   
    3035    // for saturated stars, we should be somewhat more agressive about culling: instead of
     
    3641    // fStdev = 0.005, stdev_pad = 0.011*40k = 400
    3742    // threshold = 40k - 4*400 = 38400
    38 
    39     // in practice, we should make the threshold in such a case more like 0.5 * saturation...
     43    // this gives too tight of a tolerance on the bright stars
     44    // in practice, we should make the threshold much lower. 
     45    // below I am using 0.05 * saturation (eg, 2000 DN above sky in a GPC1 image)
    4046
    4147    float SATURATION = NAN;
     
    7278        }
    7379
    74         if (pmFootprintCullPeaks(readout->image, readout->variance, fp, nsigma_delta, fPadding, MIN_THRESHOLD, max_threshold) != PS_ERR_NONE) {
     80        // if we cull using the significance image, then the thresholds are different
     81# if (0)
     82        if (pmFootprintCullPeaks(signifR->image, readout->variance, fp, nsigma_delta, fPadding, MIN_THRESHOLD, max_threshold, true) != PS_ERR_NONE) {
    7583            return psError(PS_ERR_UNKNOWN, false, "Culling pmFootprint %d", fp->id);
    7684        }
     85# endif
     86# if (1)
     87        if (pmFootprintCullPeaks(signifR->image, signifR->variance, fp, nsigma_delta, fPadding, MIN_THRESHOLD, max_threshold, false) != PS_ERR_NONE) {
     88            return psError(PS_ERR_UNKNOWN, false, "Culling pmFootprint %d", fp->id);
     89        }
     90# endif
     91# if (0)
     92        if (pmFootprintCullPeaks(readout->image, readout->variance, fp, nsigma_delta, fPadding, MIN_THRESHOLD, max_threshold, true) != PS_ERR_NONE) {
     93             return psError(PS_ERR_UNKNOWN, false, "Culling pmFootprint %d", fp->id);
     94        }
     95# endif
     96
    7797        float dtime = psTimerMark ("psphot.cull.footprints");
    7898        if (dtime > 1.0) {
  • branches/eam_branches/ipp-20110213/psphot/src/psphotFindDetections.c

    r30624 r30903  
    8484
    8585    // generate the smoothed significance image
    86     psImage *significance = psphotSignificanceImage (readout, recipe, maskVal);
     86    pmReadout *significance = psphotSignificanceImage (readout, recipe, maskVal);
    8787
    8888    // display the log significance image
    89     psphotVisualShowLogSignificance (significance, 0.0, 4.5);
     89    psphotVisualShowLogSignificance (significance->variance, 0.0, 4.5);
    9090
    9191    // display the significance image
    92     psphotVisualShowSignificance (significance, 0.98*threshold, 1.02*threshold);
     92    psphotVisualShowSignificance (significance->variance, 0.98*threshold, 1.02*threshold);
    9393
    9494    // detect the peaks in the significance image
    95     detections->peaks = psphotFindPeaks (significance, readout, recipe, threshold, NMAX);
     95    detections->peaks = psphotFindPeaks (significance->variance, readout, recipe, threshold, NMAX);
    9696    psMetadataAddF32  (readout->analysis, PS_LIST_TAIL, "PEAK_THRESHOLD", PS_META_REPLACE, "Peak Detection Threshold", threshold);
    9797    if (!detections->peaks) {
  • branches/eam_branches/ipp-20110213/psphot/src/psphotFindFootprints.c

    r30624 r30903  
    11# include "psphotInternal.h"
    22
    3 bool psphotFindFootprints (pmDetections *detections, psImage *significance, pmReadout *readout, psMetadata *recipe, const float threshold, const int pass, psImageMaskType maskVal) {
     3bool psphotFindFootprints (pmDetections *detections, pmReadout *significance, pmReadout *readout, psMetadata *recipe, const float threshold, const int pass, psImageMaskType maskVal) {
    44
    55    bool status;
     
    1818    PS_ASSERT (status, false);
    1919
    20     // find the raw footprints & assign the peaks to those footprints
    21     psArray *footprints = pmFootprintsFind (significance, threshold, npixMin);
     20    // find the raw footprints in the smoothed significance image & assign the peaks to those footprints
     21    psArray *footprints = pmFootprintsFind (significance->variance, threshold, npixMin);
    2222
    2323    if (pmFootprintsAssignPeaks(footprints, detections->peaks) != PS_ERR_NONE) {
     
    5656    }
    5757
    58     psphotCullPeaks(readout, recipe, detections->footprints);
     58    psphotCullPeaks(readout, significance, recipe, detections->footprints);
    5959    detections->peaks = pmFootprintArrayToPeaks(detections->footprints);
    6060    psLogMsg ("psphot", PS_LOG_INFO, "%ld peaks, %ld total footprints: %f sec\n", detections->peaks->n, detections->footprints->n, psTimerMark ("psphot.footprints"));
  • branches/eam_branches/ipp-20110213/psphot/src/psphotSignificanceImage.c

    r30750 r30903  
    44// (S/N)^2.  If FWMH_X,Y have been recorded, use them, otherwise use PEAKS_SMOOTH_SIGMA for the
    55// smoothing kernel.
    6 psImage *psphotSignificanceImage (pmReadout *readout, psMetadata *recipe, psImageMaskType maskVal) {
     6pmReadout *psphotSignificanceImage (pmReadout *readout, psMetadata *recipe, psImageMaskType maskVal) {
    77
    88    float SIGMA_SMTH, NSIGMA_SMTH;
     
    9494    psMetadataAddF32(readout->analysis, PS_LIST_TAIL, "SIGNIFICANCE_SCALE_FACTOR", PS_META_REPLACE, "Signicance scale factor", factor);
    9595
    96     // XXX multithread this if needed
     96    // we are going to return both the image and the weight here: the image contains the signal
     97    // while the 'weight' will contain the significance (NOTE the deviation from the usual
     98    // definition)
     99
     100    // save the smoothed significance image in the weight array
    97101    for (int j = 0; j < smooth_im->numRows; j++) {
    98102        for (int i = 0; i < smooth_im->numCols; i++) {
    99103            float value = smooth_im->data.F32[j][i];
    100104            if (value < 0 || smooth_wt->data.F32[j][i] <= 0 || (mask->data.PS_TYPE_IMAGE_MASK_DATA[j][i] & maskVal)) {
    101                 smooth_im->data.F32[j][i] = 0.0;
     105                smooth_wt->data.F32[j][i] = 0.0;
    102106            } else {
    103107                // XXX the value of 100 here (or 1000 before) must depend on the FWHM of the smoothing kernel, right??
    104108                float v2 = value + PS_SQR(value/100.0);
    105                 smooth_im->data.F32[j][i] = factor * PS_SQR(v2) / smooth_wt->data.F32[j][i];
     109                smooth_wt->data.F32[j][i] = factor * PS_SQR(v2) / smooth_wt->data.F32[j][i];
    106110            }
    107111        }
     
    115119        static int pass = 0;
    116120        sprintf (name, "snsmooth.v%d.fits", pass);
    117         psphotSaveImage (NULL, smooth_im, name);
     121        psphotSaveImage (NULL, smooth_wt, name);
    118122        pass ++;
    119123    }
    120 
    121     psFree(smooth_wt);
    122 
    123124    psImageConvolveSetThreads(oldThreads);
    124125
    125     return smooth_im;
     126    pmReadout *significanceRO = pmReadoutAlloc(NULL);
     127    significanceRO->variance = smooth_wt;   
     128    significanceRO->image = smooth_im;   
     129
     130    return significanceRO;
    126131}
    127132
Note: See TracChangeset for help on using the changeset viewer.