IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18867


Ignore:
Timestamp:
Aug 1, 2008, 3:29:09 PM (18 years ago)
Author:
Paul Price
Message:

Use separable mask convolution to grow the footprints.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmFootprintArrayGrow.c

    r18828 r18867  
    33 * @author RHL, Princeton & IfA; EAM, IfA
    44 *
    5  * @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    6  * @date $Date: 2008-08-01 00:00:17 $
     5 * @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     6 * @date $Date: 2008-08-02 01:29:09 $
    77 * Copyright 2006 Institute for Astronomy, University of Hawaii
    88 */
     
    2626 */
    2727psArray *pmFootprintArrayGrow(const psArray *footprints, // footprints to grow
    28                               int r) {  // how much to grow each footprint
     28                              int r) {  // how much to grow each footprint
    2929    assert (footprints->n == 0 || pmFootprintTest(footprints->data[0]));
    3030
    3131    psTimerStart ("grow");
    3232
    33     if (footprints->n == 0) {           // we don't know the size of the footprint's region
    34         return psArrayAlloc(0);
     33    if (footprints->n == 0) {           // we don't know the size of the footprint's region
     34        return psArrayAlloc(0);
    3535    }
    3636    /*
     
    4141    psLogMsg ("psphot", PS_LOG_DETAIL, "set footprint array IDs: %f sec\n", psTimerMark ("grow"));
    4242
     43#if 1
     44    // Use a separable convolution: should be faster
     45    idImage = (psImage*)psBinaryOp(idImage, idImage, "MAX", psScalarAlloc(1, PS_TYPE_S32));
     46    psImage *maskImage = psImageCopy(NULL, idImage, PS_TYPE_MASK);
     47    psImage *grownIdImage = psImageConvolveMask(NULL, maskImage, 0xff, 0xff, -1, 1, -1, 1);
     48    psFree(maskImage);
     49#else
    4350    if (r <= 0) {
    44         r = 1;                          // r == 1 => no grow
     51        r = 1;                          // r == 1 => no grow
    4552    }
    4653    psKernel *circle = psKernelAlloc(-r, r, -r, r);
    4754    assert (circle->image->numRows == 2*r + 1 && circle->image->numCols == circle->image->numRows);
    4855    for (int i = 0; i <= r; i++) {
    49         for (int j = 0; j <= r; j++) {
    50             if (i*i + j*j <= r*r) {
    51                 circle->kernel[i][j] =
    52                     circle->kernel[i][-j] =
    53                     circle->kernel[-i][j] =
    54                     circle->kernel[-i][-j] = 1;
    55             }
    56         }
     56        for (int j = 0; j <= r; j++) {
     57            if (i*i + j*j <= r*r) {
     58                circle->kernel[i][j] =
     59                    circle->kernel[i][-j] =
     60                    circle->kernel[-i][j] =
     61                    circle->kernel[-i][-j] = 1;
     62            }
     63        }
    5764    }
    5865
    59 # if (USE_FFTS_TO_CONVOLVE)   
     66# if (USE_FFTS_TO_CONVOLVE)
    6067    psImage *f32ImageIn = psImageCopy (NULL, idImage, PS_TYPE_F32);
    6168    psImage *f32ImageOut = psImageConvolveFFT(NULL, f32ImageIn, NULL, 0, circle);
     
    6370    psFree (f32ImageIn);
    6471    psFree (f32ImageOut);
    65 # else
     72#else
    6673    psImage *grownIdImage = psImageConvolveDirect(NULL, idImage, circle); // Here's the actual grow step
    67 # endif
     74#endif // USE_FFTS_TO_CONVOLVE
     75    psFree(circle);
     76#endif // Don't bother at all
     77
     78    psFree(idImage);
    6879
    6980    psLogMsg ("psphot", PS_LOG_DETAIL, "convolved with grow disc: %f sec\n", psTimerMark ("grow"));
    70     psFree(circle);     
    7181
    7282    psArray *grown = pmFootprintsFind(grownIdImage, 0.5, 1); // and here we rebuild the grown footprints
     
    7484
    7585    assert (grown != NULL);
    76     psFree(idImage);
    7786    psFree(grownIdImage);
    7887
     
    8897
    8998    return grown;
    90    
     99
    91100}
    92101
Note: See TracChangeset for help on using the changeset viewer.