IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 13351


Ignore:
Timestamp:
May 11, 2007, 7:42:38 AM (19 years ago)
Author:
rhl
Message:

Implement and use pmGrowFootprintArray

Location:
trunk/psphot/src
Files:
3 edited

Legend:

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

    r13349 r13351  
    863863/************************************************************************************************************/
    864864/*
     865 * Grow a psArray of pmFootprints isotropically by r pixels, returning a new psArray of new pmFootprints
     866 */
     867psArray *pmGrowFootprintArray(const psArray *footprints, // footprints to grow
     868                              int r) {  // how much to grow each footprint
     869    assert (footprints->n == 0 || pmIsFootprint(footprints->data[0]));
     870
     871    if (footprints->n == 0) {           // we don't know the size of the footprint's region
     872        return psArrayAlloc(0);
     873    }
     874    /*
     875     * We'll insert the footprints into an image, then convolve with a disk,
     876     * then extract a footprint from the result --- this is magically what we want.
     877     */
     878    psImage *idImage = pmSetFootprintArrayIDs(footprints, true);
     879    if (r <= 0) {
     880        r = 1;                          // r == 1 => no grow
     881    }
     882    psKernel *circle = psKernelAlloc(-r, r, -r, r);
     883    assert (circle->image->numRows == 2*r + 1 && circle->image->numCols == circle->image->numRows);
     884    for (int i = 0; i <= r; i++) {
     885        for (int j = 0; j <= r; j++) {
     886            if (i*i + j*j <= r*r) {
     887                circle->kernel[i][j] =
     888                    circle->kernel[i][-j] =
     889                    circle->kernel[-i][j] =
     890                    circle->kernel[-i][-j] = 1;
     891            }
     892        }
     893    }
     894
     895    psImage *grownIdImage = psImageConvolveDirect(idImage, circle);
     896    psFree(circle);     
     897
     898    psArray *grown = pmFindFootprints(grownIdImage, 0.5, 1);
     899    assert (grown != NULL);
     900    psFree(idImage); psFree(grownIdImage);
     901    /*
     902     * Now assign the peaks appropriately.  We could do this more efficiently
     903     * using idImage (which we just freed), but this is easy and probably fast enough
     904     */
     905    const psArray *peaks = pmFootprintArrayToPeaks(footprints);
     906    pmPeaksAssignToFootprints(grown, peaks);
     907    psFree((psArray *)peaks);
     908
     909    return grown;
     910   
     911}
     912
     913/************************************************************************************************************/
     914/*
    865915 * Merge together two psArrays of pmFootprints neither of which is damaged.
    866916 *
     
    911961    /*
    912962     * Now assign the peaks appropriately.  We could do this more efficiently
    913      * using idImage (which we just freed), but this is easy any probably fast enough
     963     * using idImage (which we just freed), but this is easy and probably fast enough
    914964     */
    915965    const psArray *peaks;
  • trunk/psphot/src/pmFootprint.h

    r13236 r13351  
    3535                                    int row, int col);
    3636
     37psArray *pmGrowFootprintArray(const psArray *footprints, int r);
    3738psArray *pmMergeFootprintArrays(const psArray *footprints1, const psArray *footprints2);
    3839
  • trunk/psphot/src/psphotReadout.c

    r13348 r13351  
    6565    if (useFootprints) {
    6666       psArray *footprints = psphotFindPeaks (readout, recipe, useFootprints, 1);
     67       int growRadius = psMetadataLookupS32(None, recipe, "FOOTPRINT_GROW_RADIUS");
     68       if (growRadius > 0) {
     69           psArray *tmp = pmGrowFootprintArray(footprints, growRadius);
     70           psFree(footprints);
     71           footprints = tmp;
     72       }
     73
    6774       peaks = pmFootprintArrayToPeaks(footprints);
    6875       psFree(footprints);
     
    170177       psArray *newFootprints = psphotFindPeaks (readout, recipe, useFootprints, 2);
    171178
     179       int growRadius = psMetadataLookupS32(None, recipe, "FOOTPRINT_GROW_RADIUS_2");
     180       if (growRadius > 0) {
     181           psArray *tmp = pmGrowFootprintArray(newFootprints, growRadius);
     182           psFree(newFootprints);
     183           newFootprints = tmp;
     184       }
     185
    172186       psphotCullPeaks(readout->image, readout->weight, recipe, newFootprints);
    173187
Note: See TracChangeset for help on using the changeset viewer.