IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37404 for trunk/psLib


Ignore:
Timestamp:
Sep 19, 2014, 4:33:54 PM (12 years ago)
Author:
eugene
Message:

do not include masked elements when finding rescaling sigma

Location:
trunk/psLib/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/math/psMinimizePolyFit.c

    r36296 r37404  
    700700
    701701    // Define values that may be used by PS_POLYNOMIAL_ORD form.
     702    // these scaling values put the dynamic range of the data into some vaguely sensible location
    702703    bool scale = false;
    703704    double median = 0.0;
    704705    double sigma = 1.0;
    705     psVector *sorted = NULL;
    706     psVector *z64 = NULL;
    707    
     706
    708707    switch (poly->type) {
    709708    case PS_POLYNOMIAL_ORD:
    710709      if ((f64->n < 10000)&&(poly->nX > 1)) {
    711710        scale = true;
    712         sorted = psVectorSort(NULL,x64);
     711
     712        // generate a subset of the unmasked values:
     713        psVector *tmp = psVectorAllocEmpty (x64->n, PS_TYPE_F64);
     714        for (int itmp = 0; itmp < x64->n; itmp++) {
     715          if (mask && (mask->data.PS_TYPE_VECTOR_MASK_DATA[itmp] && maskValue)) continue;
     716          psVectorAppend (tmp, x64->data.F64[itmp]);
     717        }
     718        psVector *sorted = psVectorSort(NULL,tmp);
    713719        median = sorted->data.F64[sorted->n / 2];
    714720        // CZW: I'm not bothering to scale this because it doesn't really matter.
    715721        sigma  = (sorted->data.F64[3 * sorted->n / 4] - sorted->data.F64[sorted->n / 4]);
    716722        psFree(sorted);
     723        psFree(tmp);
    717724
    718725        if ((!isfinite(median))||
     
    725732        }
    726733        // I can't see a way to not clobber x if it's already F64, so make a copy.x
    727         z64 = psVectorCopy(NULL,x64,PS_TYPE_F64);
     734        psVector *z64 = psVectorCopy(NULL,x64,PS_TYPE_F64);
    728735        psBinaryOp(z64,z64,"-",psScalarAlloc(median,PS_TYPE_F64));
    729736        psBinaryOp(z64,z64,"/",psScalarAlloc(sigma,PS_TYPE_F64));
  • trunk/psLib/src/mathtypes/psImage.c

    r23443 r37404  
    9191    }
    9292
    93     long numBytes = numRows * numCols * elementSize;
     93    size_t numBytes = (size_t) numRows * (size_t) numCols * (size_t) elementSize;
    9494
    9595    psImage* image = (psImage* ) p_psAlloc(file, lineno, func, sizeof(psImage));
Note: See TracChangeset for help on using the changeset viewer.