mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-24 05:18:59 -05:00
solve merge conflict
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
{"cdfgroups" : [{
|
||||
"group" : "CCMC-3D-CDF",
|
||||
"fieldlinefile" : "${OPENSPACE_DATA}/scene/iswa/cdf/fieldlines.json",
|
||||
"cdfs" : [
|
||||
{
|
||||
"name" : "CCMC-00:00:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-000000-000.out.cdf"
|
||||
"time" : "2000-01-01T00:00:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-00:30:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-003000-000.out.cdf"
|
||||
"time" : "2000-01-01T00:00:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-01:00:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-010000-000.out.cdf"
|
||||
"time" : "2000-01-01T10:00:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-01:30:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-013000-000.out.cdf"
|
||||
"time" : "2000-01-01T01:30:00.00"
|
||||
},
|
||||
{
|
||||
"name" : "CCMC-02:00:00",
|
||||
"path" : "../../GM_CDF/3d__var_1_e20000101-020000-000.out.cdf"
|
||||
"time" : "2000-01-01T02:00:00.00"
|
||||
},
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
CCMC-3D-CDF
|
||||
${OPENSPACE_DATA}/scene/iswa/cdf/fieldlines.json
|
||||
CCMC-00:00:00 ../../GM_CDF/3d__var_1_e20000101-000000-000.out.cdf 2000-01-01T00:00:00.00
|
||||
CCMC-00:30:00 ../../GM_CDF/3d__var_1_e20000101-003000-000.out.cdf 2000-01-01T00:30:00.00
|
||||
CCMC-01:00:00 ../../GM_CDF/3d__var_1_e20000101-010000-000.out.cdf 2000-01-01T01:00:00.00
|
||||
CCMC-01:30:00 ../../GM_CDF/3d__var_1_e20000101-013000-000.out.cdf 2000-01-01T01:30:00.00
|
||||
CCMC-02:00:00 ../../GM_CDF/3d__var_1_e20000101-020000-000.out.cdf 2000-01-01T02:00:00.00
|
||||
File diff suppressed because it is too large
Load Diff
+1
-1
Submodule ext/ghoul updated: 5ef066647c...9bb5ce6bf4
@@ -67,7 +67,7 @@ public:
|
||||
|
||||
void normalize();
|
||||
void print() const;
|
||||
void generateEqualizer();
|
||||
void generateEqualizer(bool withoutHighestBin = false);
|
||||
Histogram equalize();
|
||||
float equalize (float);
|
||||
|
||||
|
||||
@@ -41,18 +41,18 @@ DataCygnet::DataCygnet(const ghoul::Dictionary& dictionary)
|
||||
:IswaCygnet(dictionary)
|
||||
,_dataProcessor(nullptr)
|
||||
,_dataOptions("dataOptions", "Data Options")
|
||||
,_useLog("useLog","Use Logarithm", false)
|
||||
// ,_useLog("useLog","Use Logarithm", false)
|
||||
,_useHistogram("useHistogram", "Auto Contrast", false)
|
||||
,_autoFilter("autoFilter", "Auto Filter", true)
|
||||
,_normValues("normValues", "Normalize Values", glm::vec2(1.0,1.0), glm::vec2(0), glm::vec2(5.0))
|
||||
,_backgroundValues("backgroundValues", "Background Values", glm::vec2(0.0), glm::vec2(0), glm::vec2(1.0))
|
||||
,_transferFunctionsFile("transferfunctions", "Transfer Functions", "${SCENE}/iswa/tfs/default.tf")
|
||||
//FOR TESTING
|
||||
,_numOfBenchmarks(0)
|
||||
,_avgBenchmarkTime(0.0f)
|
||||
// ,_numOfBenchmarks(0)
|
||||
// ,_avgBenchmarkTime(0.0f)
|
||||
{
|
||||
addProperty(_dataOptions);
|
||||
addProperty(_useLog);
|
||||
// addProperty(_useLog);
|
||||
addProperty(_useHistogram);
|
||||
addProperty(_autoFilter);
|
||||
addProperty(_normValues);
|
||||
@@ -241,10 +241,10 @@ void DataCygnet::setPropertyCallbacks(){
|
||||
updateTexture();
|
||||
});
|
||||
|
||||
_useLog.onChange([this](){
|
||||
_dataProcessor->useLog(_useLog.value());
|
||||
updateTexture();
|
||||
});
|
||||
// _useLog.onChange([this](){
|
||||
// _dataProcessor->useLog(_useLog.value());
|
||||
// updateTexture();
|
||||
// });
|
||||
|
||||
_useHistogram.onChange([this](){
|
||||
_dataProcessor->useHistogram(_useHistogram.value());
|
||||
@@ -266,6 +266,8 @@ void DataCygnet::setPropertyCallbacks(){
|
||||
_autoFilter.onChange([this](){
|
||||
if(_autoFilter.value())
|
||||
_backgroundValues.setValue(_dataProcessor->filterValues());
|
||||
else
|
||||
_backgroundValues.setValue(glm::vec2(0.f));
|
||||
updateTexture();
|
||||
});
|
||||
}
|
||||
@@ -305,10 +307,10 @@ void DataCygnet::subscribeToGroup(){
|
||||
_transferFunctionsFile.setValue(dict.value<std::string>("transferFunctions"));
|
||||
});
|
||||
|
||||
groupEvent->subscribe(name(), "useLogChanged", [&](const ghoul::Dictionary& dict){
|
||||
LDEBUG(name() + " Event useLogChanged");
|
||||
_useLog.setValue(dict.value<bool>("useLog"));
|
||||
});
|
||||
// groupEvent->subscribe(name(), "useLogChanged", [&](const ghoul::Dictionary& dict){
|
||||
// LDEBUG(name() + " Event useLogChanged");
|
||||
// _useLog.setValue(dict.value<bool>("useLog"));
|
||||
// });
|
||||
|
||||
groupEvent->subscribe(name(), "useHistogramChanged", [&](ghoul::Dictionary dict){
|
||||
LDEBUG(name() + " Event useHistogramChanged");
|
||||
@@ -329,8 +331,20 @@ void DataCygnet::subscribeToGroup(){
|
||||
}
|
||||
|
||||
void DataCygnet::getGroupPropertyValues(){
|
||||
if(!_group)
|
||||
if(!_group){
|
||||
_backgroundValues.onChange([this]{
|
||||
glm::vec2 bv = _backgroundValues.value();
|
||||
|
||||
if(bv.x > bv.y){
|
||||
float y = bv.y;
|
||||
bv.y = bv.x;
|
||||
bv.x = y;
|
||||
|
||||
_backgroundValues.setValue(bv);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
std::unique_ptr<ghoul::Dictionary> properties = _group->propertyValues();
|
||||
|
||||
|
||||
@@ -103,7 +103,7 @@ protected:
|
||||
properties::StringProperty _transferFunctionsFile;
|
||||
properties::Vec2Property _backgroundValues;
|
||||
properties::Vec2Property _normValues;
|
||||
properties::BoolProperty _useLog;
|
||||
// properties::BoolProperty _useLog;
|
||||
properties::BoolProperty _useHistogram;
|
||||
properties::BoolProperty _autoFilter;
|
||||
|
||||
@@ -112,8 +112,8 @@ protected:
|
||||
glm::size3_t _textureDimensions;
|
||||
|
||||
//FOR TESTING
|
||||
int _numOfBenchmarks;
|
||||
double _avgBenchmarkTime;
|
||||
// int _numOfBenchmarks;
|
||||
// double _avgBenchmarkTime;
|
||||
|
||||
private:
|
||||
bool readyToRender() const override;
|
||||
|
||||
@@ -50,7 +50,7 @@ bool DataPlane::initialize(){
|
||||
_dataProcessor = _group->dataProcessor();
|
||||
subscribeToGroup();
|
||||
}else{
|
||||
OsEng.gui()._iswa.registerProperty(&_useLog);
|
||||
// OsEng.gui()._iswa.registerProperty(&_useLog);
|
||||
OsEng.gui()._iswa.registerProperty(&_useHistogram);
|
||||
OsEng.gui()._iswa.registerProperty(&_autoFilter);
|
||||
OsEng.gui()._iswa.registerProperty(&_normValues);
|
||||
@@ -158,25 +158,25 @@ std::vector<float*> DataPlane::textureData(){
|
||||
}
|
||||
// _textureDimensions = _dataProcessor->dimensions();
|
||||
|
||||
// FOR TESTING
|
||||
// ===========
|
||||
std::chrono::time_point<std::chrono::system_clock> start, end;
|
||||
start = std::chrono::system_clock::now();
|
||||
// ===========
|
||||
std::vector<float*> d = _dataProcessor->processData(_dataBuffer, _dataOptions, _textureDimensions);
|
||||
// // FOR TESTING
|
||||
// // ===========
|
||||
// std::chrono::time_point<std::chrono::system_clock> start, end;
|
||||
// start = std::chrono::system_clock::now();
|
||||
// // ===========
|
||||
// std::vector<float*> d = _dataProcessor->processData(_dataBuffer, _dataOptions, _textureDimensions);
|
||||
|
||||
// FOR TESTING
|
||||
// ===========
|
||||
end = std::chrono::system_clock::now();
|
||||
_numOfBenchmarks++;
|
||||
std::chrono::duration<double> elapsed_seconds = end-start;
|
||||
_avgBenchmarkTime = ( (_avgBenchmarkTime * (_numOfBenchmarks-1)) + elapsed_seconds.count() ) / _numOfBenchmarks;
|
||||
std::cout << " processData() " << name() << std::endl;
|
||||
std::cout << "avg elapsed time: " << _avgBenchmarkTime << "s\n";
|
||||
std::cout << "num Benchmarks: " << _numOfBenchmarks << "\n";
|
||||
// // FOR TESTING
|
||||
// // ===========
|
||||
// end = std::chrono::system_clock::now();
|
||||
// _numOfBenchmarks++;
|
||||
// std::chrono::duration<double> elapsed_seconds = end-start;
|
||||
// _avgBenchmarkTime = ( (_avgBenchmarkTime * (_numOfBenchmarks-1)) + elapsed_seconds.count() ) / _numOfBenchmarks;
|
||||
// std::cout << " processData() " << name() << std::endl;
|
||||
// std::cout << "avg elapsed time: " << _avgBenchmarkTime << "s\n";
|
||||
// std::cout << "num Benchmarks: " << _numOfBenchmarks << "\n";
|
||||
// ===========
|
||||
|
||||
return d;
|
||||
return _dataProcessor->processData(_dataBuffer, _dataOptions, _textureDimensions);
|
||||
}
|
||||
|
||||
}// namespace openspace
|
||||
@@ -69,7 +69,7 @@ bool DataSphere::initialize(){
|
||||
subscribeToGroup();
|
||||
//getGroupPropertyValues();
|
||||
}else{
|
||||
OsEng.gui()._iswa.registerProperty(&_useLog);
|
||||
// OsEng.gui()._iswa.registerProperty(&_useLog);
|
||||
OsEng.gui()._iswa.registerProperty(&_useHistogram);
|
||||
OsEng.gui()._iswa.registerProperty(&_autoFilter);
|
||||
OsEng.gui()._iswa.registerProperty(&_normValues);
|
||||
|
||||
@@ -41,8 +41,7 @@ namespace {
|
||||
namespace openspace{
|
||||
IswaDataGroup::IswaDataGroup(std::string name, std::string type)
|
||||
:IswaBaseGroup(name, type)
|
||||
,_useLog("useLog","Use Logarithm", false)
|
||||
|
||||
// ,_useLog("useLog","Use Logarithm", false)
|
||||
,_useHistogram("useHistogram", "Auto Contrast", false)
|
||||
,_autoFilter("autoFilter", "Auto Filter", true)
|
||||
,_normValues("normValues", "Normalize Values", glm::vec2(1.0,1.0), glm::vec2(0), glm::vec2(5.0))
|
||||
@@ -50,7 +49,7 @@ IswaDataGroup::IswaDataGroup(std::string name, std::string type)
|
||||
,_transferFunctionsFile("transferfunctions", "Transfer Functions", "${SCENE}/iswa/tfs/default.tf")
|
||||
,_dataOptions("dataOptions", "Data Options")
|
||||
{
|
||||
addProperty(_useLog);
|
||||
// addProperty(_useLog);
|
||||
addProperty(_useHistogram);
|
||||
addProperty(_autoFilter);
|
||||
addProperty(_normValues);
|
||||
@@ -65,7 +64,7 @@ IswaDataGroup::IswaDataGroup(std::string name, std::string type)
|
||||
IswaDataGroup::~IswaDataGroup(){}
|
||||
|
||||
void IswaDataGroup::registerProperties(){
|
||||
OsEng.gui()._iswa.registerProperty(&_useLog);
|
||||
// OsEng.gui()._iswa.registerProperty(&_useLog);
|
||||
OsEng.gui()._iswa.registerProperty(&_useHistogram);
|
||||
OsEng.gui()._iswa.registerProperty(&_autoFilter);
|
||||
OsEng.gui()._iswa.registerProperty(&_normValues);
|
||||
@@ -75,10 +74,10 @@ void IswaDataGroup::registerProperties(){
|
||||
OsEng.gui()._iswa.registerProperty(&_backgroundValues);
|
||||
|
||||
|
||||
_useLog.onChange([this]{
|
||||
LDEBUG("Group " + name() + " published useLogChanged");
|
||||
_groupEvent->publish("useLogChanged", ghoul::Dictionary({{"useLog", _useLog.value()}}));
|
||||
});
|
||||
// _useLog.onChange([this]{
|
||||
// LDEBUG("Group " + name() + " published useLogChanged");
|
||||
// _groupEvent->publish("useLogChanged", ghoul::Dictionary({{"useLog", _useLog.value()}}));
|
||||
// });
|
||||
|
||||
_useHistogram.onChange([this]{
|
||||
LDEBUG("Group " + name() + " published useHistogramChanged");
|
||||
@@ -95,6 +94,7 @@ void IswaDataGroup::registerProperties(){
|
||||
OsEng.gui()._iswa.unregisterProperty(&_backgroundValues);
|
||||
// else if autofilter is turned off, register backgroundValues
|
||||
} else {
|
||||
_backgroundValues.setValue(glm::vec2(0.f));
|
||||
OsEng.gui()._iswa.registerProperty(&_backgroundValues, &_autoFilter);
|
||||
}
|
||||
_groupEvent->publish("autoFilterChanged", ghoul::Dictionary({{"autoFilter", _autoFilter.value()}}));
|
||||
@@ -106,6 +106,16 @@ void IswaDataGroup::registerProperties(){
|
||||
});
|
||||
|
||||
_backgroundValues.onChange([this]{
|
||||
glm::vec2 bv = _backgroundValues.value();
|
||||
|
||||
if(bv.x > bv.y){
|
||||
float y = bv.y;
|
||||
bv.y = bv.x;
|
||||
bv.x = y;
|
||||
|
||||
_backgroundValues.setValue(bv);
|
||||
}
|
||||
|
||||
LDEBUG("Group " + name() + " published backgroundValuesChanged");
|
||||
_groupEvent->publish("backgroundValuesChanged", ghoul::Dictionary({{"backgroundValues", _backgroundValues.value()}}));
|
||||
});
|
||||
|
||||
@@ -43,7 +43,7 @@ protected:
|
||||
void registerProperties();
|
||||
void createDataProcessor();
|
||||
|
||||
properties::BoolProperty _useLog;
|
||||
// properties::BoolProperty _useLog;
|
||||
properties::BoolProperty _useHistogram;
|
||||
properties::BoolProperty _autoFilter;
|
||||
properties::Vec2Property _normValues;
|
||||
|
||||
@@ -105,7 +105,7 @@ bool KameleonPlane::initialize(){
|
||||
_dataProcessor = _group->dataProcessor();
|
||||
subscribeToGroup();
|
||||
}else{
|
||||
OsEng.gui()._iswa.registerProperty(&_useLog);
|
||||
// OsEng.gui()._iswa.registerProperty(&_useLog);
|
||||
OsEng.gui()._iswa.registerProperty(&_useHistogram);
|
||||
OsEng.gui()._iswa.registerProperty(&_autoFilter);
|
||||
OsEng.gui()._iswa.registerProperty(&_normValues);
|
||||
|
||||
@@ -60,18 +60,17 @@ Fragment getFragment() {
|
||||
v /= numTextures;
|
||||
|
||||
vec4 color = texture(transferFunctions[0], vec2(v,0));
|
||||
if((v<(x+y)) && v>(x-y))
|
||||
if(v >= x && v <= y)
|
||||
color = transparent;
|
||||
// color = mix(transparent, color, clamp(1,0,abs(v-x)));
|
||||
|
||||
diffuse = color;
|
||||
}else{
|
||||
for(int i=0; i<numTextures; i++){
|
||||
v = texture(textures[i], vs_st).r;
|
||||
vec4 color = texture(transferFunctions[i], vec2(v,0));
|
||||
if((v<(x+y)) && v>(x-y))
|
||||
if(v >= x && v <= y)
|
||||
color = transparent;
|
||||
// color = mix(transparent, color, clamp(1,0,abs(v-x)));
|
||||
|
||||
diffuse += color;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,16 +60,16 @@ Fragment getFragment() {
|
||||
v /= numTextures;
|
||||
|
||||
vec4 color = texture(transferFunctions[0], vec2(v,0));
|
||||
if((v<(x+y)) && v>(x-y))
|
||||
color = mix(transparent, color, clamp(1,0,abs(v-x)));
|
||||
if(v >= x && v <= y)
|
||||
color = transparent;
|
||||
|
||||
diffuse = color;
|
||||
}else{
|
||||
for(int i=0; i<numTextures; i++){
|
||||
v = texture(textures[i], vec2(vs_st.t, vs_st.s)).r;
|
||||
vec4 color = texture(transferFunctions[i], vec2(v,0));
|
||||
if((v<(x+y)) && v>(x-y))
|
||||
color = mix(transparent, color, clamp(1,0,abs(v-x)));
|
||||
if(v >= x && v <= y)
|
||||
color = transparent;
|
||||
diffuse += color;
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,6 @@ Fragment getFragment() {
|
||||
|
||||
diffuse.a *= transparency;
|
||||
|
||||
// diffuse = vec4(vs_st.s, 0,0,1);
|
||||
Fragment frag;
|
||||
frag.color = diffuse;
|
||||
frag.depth = depth;
|
||||
|
||||
@@ -28,14 +28,14 @@ namespace {
|
||||
const std::string _loggerCat = "DataProcessor";
|
||||
const int NumBins = 512;
|
||||
}
|
||||
|
||||
// const float normVal = 1.0;
|
||||
namespace openspace {
|
||||
DataProcessor::DataProcessor()
|
||||
:_useLog(false)
|
||||
,_useHistogram(false)
|
||||
// ,_normValues(glm::vec2(normVal))
|
||||
,_normValues(glm::vec2(1.0))
|
||||
,_filterValues(glm::vec2(0.0))
|
||||
//,_histNormValues(glm::vec2(4.f, 4.f))
|
||||
{
|
||||
_coordinateVariables = {"x", "y", "z", "phi", "theta"};
|
||||
}
|
||||
@@ -70,6 +70,7 @@ void DataProcessor::clear(){
|
||||
_histograms.clear();
|
||||
_numValues.clear();
|
||||
_fitValues.clear();
|
||||
_unNormalizedhistograms.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +85,7 @@ float DataProcessor::processDataPoint(float value, int option){
|
||||
v = histogram->equalize(normalizeWithStandardScore(value, mean, sd, glm::vec2(_fitValues[option])))/(float)NumBins;
|
||||
// v = histogram->equalize(value)/(float)512;
|
||||
}else{
|
||||
v = normalizeWithStandardScore(value, mean, sd, glm::vec2(_fitValues[option]));
|
||||
v = normalizeWithStandardScore(value, mean, sd, _normValues);
|
||||
}
|
||||
return v;
|
||||
}
|
||||
@@ -119,6 +120,7 @@ void DataProcessor::initializeVectors(int numOptions){
|
||||
if(_numValues.empty()) _numValues = std::vector<float>(numOptions, 0.0f);
|
||||
if(_fitValues.empty()) _fitValues = std::vector<float>(numOptions, 0.0f);
|
||||
if(_histograms.empty())_histograms = std::vector<std::shared_ptr<Histogram>>(numOptions, nullptr);
|
||||
if(_unNormalizedhistograms.empty())_unNormalizedhistograms = std::vector<std::shared_ptr<Histogram>>(numOptions, nullptr);
|
||||
}
|
||||
|
||||
void DataProcessor::calculateFilterValues(std::vector<int> selectedOptions){
|
||||
@@ -139,14 +141,14 @@ void DataProcessor::calculateFilterValues(std::vector<int> selectedOptions){
|
||||
filterMid = histogram->highestBinValue(_useHistogram);
|
||||
filterWidth = histogram->binWidth();
|
||||
|
||||
//atleast one pixel value width. 1/512 above mid and 1/512 below mid => 1/256 filtered
|
||||
//at least one pixel value width. 1/512 above mid and 1/512 below mid => 1/256 filtered
|
||||
filterWidth = std::max(filterWidth, 1.0f/512.0f);
|
||||
}else{
|
||||
Histogram hist = _histograms[option]->equalize();
|
||||
filterMid = hist.highestBinValue(true);
|
||||
filterWidth = std::min(1.f / (float)NumBins, 1.0f/512.0f);
|
||||
}
|
||||
_filterValues += glm::vec2(filterMid, filterWidth);
|
||||
_filterValues += glm::vec2(filterMid-filterWidth, filterMid+filterWidth);
|
||||
|
||||
}
|
||||
_filterValues /= numSelected;
|
||||
@@ -162,12 +164,21 @@ void DataProcessor::add(std::vector<std::vector<float>>& optionValues, std::vect
|
||||
std::vector<float> values = optionValues[i];
|
||||
numValues = values.size();
|
||||
|
||||
//set min, max for the unnormalized histogram
|
||||
if(!_unNormalizedhistograms[i]){
|
||||
_unNormalizedhistograms[i] = std::make_shared<Histogram>(_min[i], _max[i], NumBins);
|
||||
}else{
|
||||
_unNormalizedhistograms[i]->changeRange(_min[i], _max[i]);
|
||||
}
|
||||
|
||||
variance = 0;
|
||||
mean = (1.0f/numValues)*sum[i];
|
||||
|
||||
//add values to unnormalized histogram and calculate variance
|
||||
for(int j=0; j<numValues; j++){
|
||||
value = values[j];
|
||||
variance += pow(value-mean, 2);
|
||||
_unNormalizedhistograms[i]->add(value, 1);
|
||||
}
|
||||
|
||||
standardDeviation = sqrt(variance/ numValues);
|
||||
@@ -179,22 +190,22 @@ void DataProcessor::add(std::vector<std::vector<float>>& optionValues, std::vect
|
||||
_standardDeviation[i] = sqrt(pow(standardDeviation, 2) + pow(_standardDeviation[i], 2));
|
||||
_numValues[i] += numValues;
|
||||
|
||||
_unNormalizedhistograms[i]->generateEqualizer();
|
||||
|
||||
float fit = 10.0f*_standardDeviation[i]/(_max[i]-_min[i]);
|
||||
//set the normalization fit value
|
||||
float fit = _unNormalizedhistograms[i]->entropy();
|
||||
float oldFit = _fitValues[i];
|
||||
_fitValues[i] = fit;
|
||||
|
||||
mean = (1.0f/_numValues[i])*_sum[i];
|
||||
|
||||
|
||||
float min = normalizeWithStandardScore(_min[i], mean, _standardDeviation[i], glm::vec2(_fitValues[i]));
|
||||
float max = normalizeWithStandardScore(_max[i], mean, _standardDeviation[i], glm::vec2(_fitValues[i]));
|
||||
float min = normalizeWithStandardScore(_min[i], mean, _standardDeviation[i], glm::vec2(_fitValues[i]));
|
||||
|
||||
if(!_histograms[i]){
|
||||
_histograms[i] = std::make_shared<Histogram>(min, max, NumBins);
|
||||
}
|
||||
else{
|
||||
//Re normalize all the values in the old histogram
|
||||
//Renormalize all the values in the old histogram
|
||||
const float* histData = _histograms[i]->data();
|
||||
float histMin = _histograms[i]->minValue();
|
||||
float histMax = _histograms[i]->maxValue();
|
||||
@@ -217,15 +228,14 @@ void DataProcessor::add(std::vector<std::vector<float>>& optionValues, std::vect
|
||||
_histograms[i] = newHist;
|
||||
}
|
||||
|
||||
//add the new values to the histogram
|
||||
for(int j=0; j<numValues; j++){
|
||||
value = values[j];
|
||||
_histograms[i]->add(normalizeWithStandardScore(value, mean, _standardDeviation[i], glm::vec2(_fitValues[i])), 1);
|
||||
|
||||
}
|
||||
|
||||
_histograms[i]->generateEqualizer();
|
||||
|
||||
_histograms[i]->generateEqualizer(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -109,6 +109,7 @@ private:
|
||||
|
||||
std::vector<std::shared_ptr<Histogram>> _histograms;
|
||||
|
||||
std::vector<std::shared_ptr<Histogram>> _unNormalizedhistograms;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
+22
-4
@@ -248,12 +248,29 @@ void Histogram::normalize() {
|
||||
* Old histogram value is the index of the array, and the new equalized
|
||||
* value will be the value at the index.
|
||||
*/
|
||||
void Histogram::generateEqualizer(){
|
||||
void Histogram::generateEqualizer(bool withoutHighestBin){
|
||||
float previousCdf = 0.0f;
|
||||
_equalizer = std::vector<float>(_numBins, 0.0f);
|
||||
|
||||
int highestBin = -1;
|
||||
float highestProbability = 0;
|
||||
|
||||
if(withoutHighestBin){
|
||||
highestBin = 0;
|
||||
for(int i=0; i<_numBins; i++){
|
||||
if(_data[i] > _data[highestBin]){
|
||||
highestBin = i;
|
||||
}
|
||||
}
|
||||
highestProbability = _data[highestBin] / (float)_numValues;
|
||||
}
|
||||
|
||||
|
||||
for(int i = 0; i < _numBins; i++){
|
||||
|
||||
float probability = _data[i] / (float)_numValues;
|
||||
float probability = highestProbability/(float)_numBins;
|
||||
if(i != highestBin)
|
||||
probability += _data[i] / (float)_numValues;
|
||||
|
||||
float cdf = previousCdf + probability;
|
||||
cdf = std::min(1.0f, cdf);
|
||||
_equalizer[i] = cdf * (_numBins-1);
|
||||
@@ -292,7 +309,8 @@ float Histogram::equalize(float value){
|
||||
}
|
||||
|
||||
float Histogram::entropy() const {
|
||||
float entropy;
|
||||
float entropy = 0.f;
|
||||
|
||||
for(int i = 0; i < _numBins; i++){
|
||||
if(_data[i] != 0)
|
||||
entropy -= ((float)_data[i]/_numValues) * log2((float)_data[i]/_numValues);
|
||||
|
||||
Reference in New Issue
Block a user