IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14930


Ignore:
Timestamp:
Sep 20, 2007, 1:58:02 PM (19 years ago)
Author:
eugene
Message:

fixed extrapolation error in histograms with large dynamic range

File:
1 edited

Legend:

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

    r12434 r14930  
    55 *  @author GLG (MHPCC), EAM (IfA)
    66 *
    7  *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2007-03-14 02:36:28 $
     7 *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2007-09-20 23:58:02 $
    99 *
    1010 *  Copyright 2006 IfA, University of Hawaii
     
    282282                out->maxNum++;
    283283            } else {
    284                 // If this is a uniform histogram, determining the correct
    285                 // number is trivial.
     284                // If this is a uniform histogram, determining the correct bin
     285                // number is almost trivial.  start with a guess from the uniform scale.
    286286                if (out->uniform == true) {
    287                     float binSize = out->bounds->data.F32[1] - out->bounds->data.F32[0]; // Histogram bin size
     287                    double binSize = out->bounds->data.F32[1] - out->bounds->data.F32[0]; // Histogram bin size
    288288                    binNum = (inF32->data.F32[i] - out->bounds->data.F32[0]) / binSize;
     289                    binNum = PS_MAX (binNum, 0);
     290                    binNum = PS_MIN (binNum, numBins - 1);
     291
     292                    // we may slightly overshoot or undershoot.  creep up or down on the true bin
     293                    if (inF32->data.F32[i] < out->bounds->data.F32[binNum]) {
     294                        psTrace("psLib.math", 6, "missed target bin, adjusting: %f vs %f to %f\n", inF32->data.F32[i], out->bounds->data.F32[binNum], out->bounds->data.F32[binNum+1]);
     295                        while ((inF32->data.F32[i] < out->bounds->data.F32[binNum]) && (binNum > 0)) {
     296                            binNum --;
     297                        }
     298                       
     299                    }
     300                    if (inF32->data.F32[i] > out->bounds->data.F32[binNum+1]) {
     301                        psTrace("psLib.math", 6, "missed target bin, adjusting: %f vs %f to %f\n", inF32->data.F32[i], out->bounds->data.F32[binNum], out->bounds->data.F32[binNum+1]);
     302                        while ((inF32->data.F32[i] > out->bounds->data.F32[binNum+1]) && (binNum < numBins - 1)) {
     303                            binNum ++;
     304                        }
     305                    }
     306
    289307                    if (errorsF32) {
    290308                        if (!UpdateHistogramBins(binNum, out, inF32->data.F32[i], errorsF32->data.F32[i])) {
Note: See TracChangeset for help on using the changeset viewer.