IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8978


Ignore:
Timestamp:
Sep 25, 2006, 5:52:59 PM (20 years ago)
Author:
Paul Price
Message:

Subtract the median when we add the numbers, so we don't get numerical problems

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImageBackground.c

    r8974 r8978  
    4949        int iy = pixel / nx;
    5050
    51         if (mask && mask->data.U8[iy][ix] & maskValue) {
     51        if (!isfinite(image->data.F32[iy][ix]) || (mask && mask->data.U8[iy][ix] & maskValue)) {
    5252            continue;
    5353        }
     
    7272    }
    7373
     74    // Subtract the median when we add the numbers, so we don't get numerical problems
     75    float median = npts % 2 ? 0.5 * (values->data.F32[npts/2 - 1] + values->data.F32[npts/2]) :
     76                   values->data.F32[npts/2];
    7477    double value = 0;
    7578    for (long i = imin; (i <= imax) && (i < n); i++) {
    76         value += values->data.F32[i];
     79        value += values->data.F32[i] - median;
    7780    }
    78     value = value / npts;
     81    value = value / npts + median;
    7982
    8083    stats->robustMedian = value;
Note: See TracChangeset for help on using the changeset viewer.