IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 12, 2008, 10:07:26 PM (18 years ago)
Author:
eugene
Message:

re-org of psphotFindDetections into significance, peaks, footprints; find and cull footprints in one function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotFindDetections.c

    r17396 r17444  
    11# include "psphotInternal.h"
    22
    3 // XXX let's make a better distinction between 'pass' (used for counting intput / output
    4 // entries) and needing/having a PSF.  In this function, we smooth the image, then search for
    5 // the peaks
     3// smooth the image, search for peaks, optionally define footprints based on the peaks
    64pmDetections *psphotFindDetections (pmDetections *detections, pmReadout *readout, psMetadata *recipe) {
    75
     
    2725
    2826    // move the old peaks array (if it exists) to oldPeaks
     27    // XXX generically, we should be able to call this function an arbitrary number of times
    2928    assert (detections->oldPeaks == NULL);
    3029    detections->oldPeaks = detections->peaks;
    3130    detections->peaks = NULL;
    3231
    33     // if footprints are not requested, find the peaks and return them
    34     if (!useFootprints) {
    35         detections->peaks = psphotFindPeaks (readout, recipe, useFootprints, pass, maskVal);
    36         return detections;
     32    // generate the smoothed significance image
     33    psImage *significance = psphotSignificanceImage (readout, recipe, pass, maskVal);
     34
     35    // detect the peaks in the significance image
     36    detections->peaks = psphotFindPeaks (significance, readout, recipe, pass, maskVal);
     37
     38    // optionally merge peaks into footprints
     39    if (useFootprints) {
     40        psphotFindFootprints (detections, significance, readout, recipe, pass, maskVal);
    3741    }
    3842
    39     // psphotFindPeaks returns a different set of objects if useFootprints is true!
    40     // XXX fix this by splitting psphotFindPeaks into smooth / peaks / footprint stages?
    41     psArray *footprints = psphotFindPeaks (readout, recipe, useFootprints, pass, maskVal);
    42 
    43     int growRadius = 0;
    44     if (pass == 1) {
    45         growRadius = psMetadataLookupS32(NULL, recipe, "FOOTPRINT_GROW_RADIUS");
    46     } else {
    47         growRadius = psMetadataLookupS32(NULL, recipe, "FOOTPRINT_GROW_RADIUS_2");
    48     }
    49 
    50     if (growRadius > 0) {
    51         psArray *tmp = pmGrowFootprintArray(footprints, growRadius);
    52         psFree(footprints);
    53         footprints = tmp;
    54     }
    55 
    56     if (pass == 2) {
    57         // merge in old peaks;
    58         const int includePeaks = 0x0 | 0x2; // i.e. just from newFootprints
    59        
    60         psLogMsg ("psphot", PS_LOG_INFO, "merging %ld new footprints into %ld existing ones\n", footprints->n, detections->footprints->n);
    61         psArray *mergedFootprints = pmMergeFootprintArrays(detections->footprints, footprints, includePeaks);
    62         psFree(footprints);
    63         psFree(detections->footprints);
    64         detections->footprints = mergedFootprints;
    65     } else {
    66         detections->footprints = footprints;
    67     }
    68 
    69     psphotCullPeaks(readout->image, readout->weight, recipe, detections->footprints);
    70     detections->peaks = pmFootprintArrayToPeaks(detections->footprints);
    71     psLogMsg ("psphot", PS_LOG_INFO, "%ld peaks, %ld total footprints: %f sec\n", detections->peaks->n, detections->footprints->n, psTimerMark ("psphot"));
    72 
     43    psFree (significance);
    7344    return detections;
    7445}
Note: See TracChangeset for help on using the changeset viewer.