From b272404328440a86d2c6e5e7611704b5a5b36f07 Mon Sep 17 00:00:00 2001 From: Antoine Lorence <antoine.lorence@insa-rennes.fr> Date: Tue, 18 Nov 2014 17:52:21 +0100 Subject: [PATCH] [Quantif] Remove useless Quantifier class --- app/Operations/Quantification.cpp | 5 ----- app/Operations/Quantification.h | 26 ++++++++------------------ app/Operations/QuantificationOp.cpp | 3 +-- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/app/Operations/Quantification.cpp b/app/Operations/Quantification.cpp index c8da7c3..eae19cc 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 8ea3ff7..756b8c0 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 051b2d4..4f813ab 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)); } } } -- GitLab