IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 28, 2007, 12:52:30 PM (18 years ago)
Author:
eugene
Message:

modification to the grow algorithm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppMerge/src/ppMergeMaskGrow.c

    r15937 r15953  
    1818// Generate a mask
    1919bool ppMergeMaskGrow(ppMergeData *data,  // Data
    20                     ppMergeOptions *options, // Options
    21                     pmConfig *config    // Configuration
     20                     ppMergeOptions *options, // Options
     21                     pmConfig *config    // Configuration
    2222    )
    2323{
     
    3535            while ((roOut = pmFPAviewNextReadout(view, fpaOut, 1))) {
    3636
    37                 ppMergeMaskGrowReadout(roOut, options->combine->maskVal);
    38 
     37                // do this N iterations (XXX add to options)
     38                ppMergeMaskGrowReadout(roOut, options->combine->maskVal, options->growPixels);
     39                ppMergeMaskGrowReadout(roOut, options->combine->maskVal, options->growPixels);
    3940            }
    4041        }
     
    4647}
    4748
    48 # define NGROW 2
    49 
    50 bool ppMergeMaskGrowReadout (pmReadout *readout, psMaskType maskVal) {
     49bool ppMergeMaskGrowReadout (pmReadout *readout, psMaskType maskVal, int nPixels) {
    5150
    5251    if (!readout->mask) return true;
     
    6261    for (int iy = 0; iy < Ny; iy++) {
    6362        for (int ix = 0; ix < Nx; ix++) {
    64 
    65             if (oldMask->data.U8[iy][ix] && maskVal) {
    66 
    67                 for (int jy = -NGROW; jy <= +NGROW; jy++) {
    68                     int ny = iy + jy;
    69                     if (ny < 0) continue;
    70                     if (ny >= Ny) continue;
    71                     for (int jx = -NGROW; jx <= +NGROW; jx++) {
    72                         int nx = ix + jx;
    73                         if (nx < 0) continue;
    74                         if (nx >= Nx) continue;
    75                         newMask->data.U8[ny][nx] |= oldMask->data.U8[iy][ix];
     63            int nSum = 0;
     64            for (int jy = -1; jy <= +1; jy++) {
     65                int ny = iy + jy;
     66                if (ny < 0) continue;
     67                if (ny >= Ny) continue;
     68                for (int jx = -1; jx <= +1; jx++) {
     69                    if (!jx && !jy) continue;
     70                    int nx = ix + jx;
     71                    if (nx < 0) continue;
     72                    if (nx >= Nx) continue;
     73                    if (oldMask->data.U8[ny][nx] & maskVal) {
     74                        nSum ++;
    7675                    }
    7776                }
    7877            }
     78            if (nSum >= nPixels) {
     79                newMask->data.U8[iy][ix] = maskVal;
     80            } else {
     81                newMask->data.U8[iy][ix] = oldMask->data.U8[iy][ix];
     82            }
    7983        }
    8084    }
    81 
    8285    psFree (readout->mask);
    8386    readout->mask = newMask;
Note: See TracChangeset for help on using the changeset viewer.