Auto filter of 'background'

This commit is contained in:
Sebastian Piwell
2016-05-17 16:11:57 -04:00
parent 08f0204a66
commit ff39239b0f
11 changed files with 83 additions and 43 deletions

View File

@@ -116,6 +116,7 @@ bool Histogram::add(float value, float repeat) {
_data[binIndex] += repeat;
_numValues += repeat;
return true;
}
@@ -281,4 +282,25 @@ void Histogram::print() const {
std::cout << std::endl << std::endl << std::endl<< "==============" << std::endl;
}
float Histogram::highestBinValue(bool equalized){
int highestBin = 0;
for(int i=0; i<_numBins; i++){
if(_data[i] > _data[highestBin])
highestBin = i;
}
float low = _minValue + float(highestBin) / _numBins * (_maxValue - _minValue);
float high = low + (_maxValue - _minValue) / float(_numBins);
if(!equalized){
return (high+low)/2.0;
}else{
return equalize((high+low)/2.0);
}
}
float Histogram::binWidth(){
return (_maxValue-_minValue)/_numBins;
}
}