Changeset 1670 for trunk/src


Ignore:
Timestamp:
12/28/09 22:19:00 (15 years ago)
Author:
Max Voronkov
Message:

increased robustness of the line detection algorithm by fixing a transient problem with not-a-numbers appear in the statistics due to round-off error

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STLineFinder.cpp

    r1644 r1670  
    304304void LFNoiseEstimator::add(float in)
    305305{
     306   if (isnan(in)) {
     307       // normally it shouldn't happen
     308       return;
     309   }
    306310   itsVariances[itsSampleNumber] = in;
    307311
     
    584588                (meanch2-square(meanch));
    585589      linmean=coeff*(Float(cur_channel)-meanch)+mean;
    586       linvariance=sqrt(sumf2/Float(box_chan_cntr)-square(mean)-
    587                     square(coeff)*(meanch2-square(meanch)));
     590      linvariance=sumf2/Float(box_chan_cntr)-square(mean)-
     591                    square(coeff)*(meanch2-square(meanch));
     592      if (linvariance<0.) {
     593          // this shouldn't happen normally, but could be due to round-off error
     594          linvariance = 0;
     595      } else {
     596          linvariance = sqrt(linvariance);
     597      }
    588598  }
    589599  need2recalculate=False;
Note: See TracChangeset for help on using the changeset viewer.