IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19482


Ignore:
Timestamp:
Sep 10, 2008, 5:37:58 PM (18 years ago)
Author:
Paul Price
Message:

Merging in pap_branch_080908. Was originally going to use it for making stamps tolerant of masked pixels, but that's no longer necessary.

Location:
trunk/psModules/src/imcombine
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmStack.c

    r19336 r19482  
    88 *  @author GLG, MHPCC
    99 *
    10  *  @version $Revision: 1.38 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2008-09-03 19:42:54 $
     10 *  @version $Revision: 1.39 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2008-09-11 03:37:58 $
    1212 *  Copyright 2004-2007 Institute for Astronomy, University of Hawaii
    1313 *
     
    309309              }
    310310          }
    311           if (useVariance && safe && numIter > 0) {
     311          if (useVariance && numIter > 0) {
    312312              // Use variance to check that the two are consistent
    313313              float diff = pixelData->data.F32[0] - pixelData->data.F32[1];
    314               float sigma2 = pixelVariances->data.F32[0] + pixelVariances->data.F32[1];
     314              float sigma2 = pixelVariances->data.F32[0] * varFactors->data.F32[pixelSources->data.U16[0]] +
     315                  pixelVariances->data.F32[1] * varFactors->data.F32[pixelSources->data.U16[1]];
    315316              if (PS_SQR(diff) > PS_SQR(rej) * sigma2) {
    316317                  // Not consistent: mark both for inspection
     
    341342                  float rej2 = PS_SQR(rej); // Rejection level squared
    342343                  for (int i = 0; i < num; i++) {
    343                       pixelVariances->data.F32[i] *= rej2 * varFactors->data.F32[i];
     344                      pixelVariances->data.F32[i] *= rej2 * varFactors->data.F32[pixelSources->data.U16[i]];
    344345                  }
    345346              }
     
    348349          // The clipping that follows is solely to identify suspect pixels.
    349350          // These suspect pixels will be inspected in more detail by other functions.
    350           int numClipped = INT_MAX;       // Number of pixels clipped per iteration
    351           int totalClipped = 0;           // Total number of pixels clipped
     351          int numClipped = INT_MAX;     // Number of pixels clipped per iteration
     352          int totalClipped = 0;         // Total number of pixels clipped
    352353          for (int i = 0; i < numIter && numClipped > 0 && num - totalClipped > 2; i++) {
    353354              numClipped = 0;
    354355              float median, stdev;    // Median and stdev of the combination, for rejection
    355356
    356               if (!combinationMedianStdev(&median, useVariance ? NULL : &stdev, pixelData, pixelMasks, sort)) {
     357              if (!combinationMedianStdev(&median, useVariance ? NULL : &stdev,
     358                                          pixelData, pixelMasks, sort)) {
    357359                  psWarning("Bad median/stdev at %d,%d", x, y);
    358360                  break;
    359361              }
    360362
    361               float limit = NAN;        // Rejection limit, when rejecting based on data properties
    362               if (!useVariance) {
    363                   limit = rej * stdev;
    364               }
     363              float limit = rej * stdev; // Rejection limit, when rejecting based on data properties
    365364
    366365// Mask a pixel for inspection
     
    378377                  if (useVariance) {
    379378                      // Comparing squares --- cheaper than lots of sqrts
     379                      // pixelVariances includes the variance factor and the rejection limit, from above
    380380                      if (PS_SQR(diff) > pixelVariances->data.F32[j]) {
    381381                          MASK_PIXEL_FOR_INSPECTION();
  • trunk/psModules/src/imcombine/pmStackReject.c

    r19349 r19482  
    295295    }
    296296
    297     if (threaded) {
     297    // Harvest the jobs
     298    if (threaded) {
     299        psThreadJob *job;                   // Job to destroy
     300        while ((job = psThreadJobGetDone())) {
     301            psFree(job);
     302        }
     303
    298304        psMutexDestroy(source);
    299305    }
     306
    300307    psFree(source);
    301308    bad = psPixelsFromMask(bad, target, PM_STACK_MASK_ALL);
  • trunk/psModules/src/imcombine/pmSubtraction.c

    r19357 r19482  
    11411141                    psMutexLock(subMask);
    11421142                }
    1143                 psArrayAdd(args, 1, (psImage*)subMask); // Casting away const
     1143                psArrayAdd(args, 1, subMask);
    11441144                if (subMask) {
    11451145                    psMutexUnlock(subMask);
     
    11661166    }
    11671167
    1168     if (!psThreadPoolWait(true)) {
     1168    if (!psThreadPoolWait(false)) {
    11691169        psError(PS_ERR_UNKNOWN, false, "Error waiting for threads.");
    11701170        return false;
    11711171    }
    11721172
    1173     if (subMask && threaded) {
    1174         psMutexDestroy(subMask);
     1173    // We don't rely on psThreadPoolWait to harvest the jobs because the job contains a reference to the
     1174    // subMask, which is being changed on a thread, and psThreadPoolWait doesn't know that it needs to be
     1175    // locked before freeing.  After psThreadPoolWait, however, the jobs are completed, the threads are idle,
     1176    // and so there's no need to lock the subMask when we're blowing away the jobs.
     1177    if (threaded) {
     1178        psThreadJob *job;               // Completed job
     1179        while ((job = psThreadJobGetDone())) {
     1180            psFree(job);
     1181        }
     1182
     1183        if (subMask) {
     1184            psMutexDestroy(subMask);
     1185        }
    11751186    }
    11761187
  • trunk/psModules/src/imcombine/pmSubtractionMatch.c

    r19299 r19482  
    9898{
    9999    if (region) {
    100         varFactor *= (region->x1 - region->x1 + 1) * (region->y1 * region->y1 + 1) /
     100        varFactor *= (region->x1 - region->x0 + 1) * (region->y1 - region->y0 + 1) /
    101101            (ro->image->numCols * ro->image->numRows);
    102102    }
Note: See TracChangeset for help on using the changeset viewer.