diff --git a/app/Operations/Quantification.cpp b/app/Operations/Quantification.cpp index c8da7c36571f8f783e5610a4adf77ad9df5c56e6..eae19cc6bf87a51410f7c313e8b24a6e3a6a30ec 100644 --- a/app/Operations/Quantification.cpp +++ b/app/Operations/Quantification.cpp @@ -171,8 +171,3 @@ Quantification Quantification::nonLinearQuantOptimized(int size, const Image* im return quant; } -Quantifier::Quantifier(Quantification quant) { - for(int i = 0; i < N_MAX_THRESHOLD; ++i) { - values[i] = quant.valueOf(i); - } -} diff --git a/app/Operations/Quantification.h b/app/Operations/Quantification.h index 8ea3ff714146018d7cb9e3ce485161306d0b1c46..756b8c05425a50d6f9178aca577a523f127060fe 100644 --- a/app/Operations/Quantification.h +++ b/app/Operations/Quantification.h @@ -32,22 +32,22 @@ public: void saveAs(std::string filename); inline int valueOf(int value) const { - for(int i = 0; i < this->size - 1; ++i) { - if(value < this->_threshold[i]) { - return this->_values[i]; + for(int i = 0; i < nbThresholds(); ++i) { + if(value < _threshold[i]) { + return _values[i]; } } - return this->_values[this->size - 1]; + return _values[nbThresholds()]; } - inline int nbValues() {return size;} + inline int nbValues() const {return size;} - inline int nbThresholds() {return size - 1;} + inline int nbThresholds() const {return size - 1;} - inline int value(int i) {return _values[i];} + inline int value(int i) const {return _values[i];} inline void setValue(int i, int v) {_values[i] = v;} - inline int threshold(int i) {return _threshold[i];} + inline int threshold(int i) const {return _threshold[i];} inline void setThreshold(int i, int v) {_threshold[i] = v;} static Quantification linearQuant(int size); @@ -60,14 +60,4 @@ private: int* _values; }; -class Quantifier { -public: - Quantifier(Quantification quant); - inline int valueOf(imagein::Image::depth_t value) { - return this->values[value]; - } -private: - int values[N_MAX_THRESHOLD]; -}; - #endif // QUANTIFICATION_H diff --git a/app/Operations/QuantificationOp.cpp b/app/Operations/QuantificationOp.cpp index 051b2d44ed4a316902d1add97107999adb203631..4f813ab7bc8c7c11b30225b00dca68a23f9d910b 100644 --- a/app/Operations/QuantificationOp.cpp +++ b/app/Operations/QuantificationOp.cpp @@ -64,11 +64,10 @@ void QuantificationOp::operator()(const imagein::Image* image, const std::map<co cout << quantification.threshold(i) << "."; } cout << endl; - Quantifier quantifier = Quantifier(quantification); for(unsigned int j = 0; j < image->getHeight(); ++j) { for(unsigned int i = 0; i < image->getWidth(); ++i) { const Image::depth_t value = image->getPixelAt(i, j, c); - resImg->setPixelAt(i, j, c, quantifier.valueOf(value)); + resImg->setPixelAt(i, j, c, quantification.valueOf(value)); } } }