From 0cbcb856c6b585ce0fb803353e6c2ae5627fc1cd Mon Sep 17 00:00:00 2001 From: qbigot <quentin.bigot@insa-rennes.fr> Date: Mon, 24 Jul 2017 16:32:46 +0200 Subject: [PATCH] fix double image entropy calculation issue --- app/Operations/DoubleEntropyOp.cpp | 10 ++++++++-- app/Operations/DoubleEntropyOp.h | 2 ++ app/Operations/EntropyOp.cpp | 3 +++ app/Operations/EntropyOp.h | 2 ++ lib/detiq-t | 2 +- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/app/Operations/DoubleEntropyOp.cpp b/app/Operations/DoubleEntropyOp.cpp index b553bb1..ff55790 100644 --- a/app/Operations/DoubleEntropyOp.cpp +++ b/app/Operations/DoubleEntropyOp.cpp @@ -39,10 +39,12 @@ DoubleEntropyOp::DoubleEntropyOp() : DoubleOperation(qApp->translate("Operations void DoubleEntropyOp::operator()(const Image_t<double>* image, const std::map<const imagein::Image_t<double>*, std::string>&) { double entropy = 0.; - + int min = image->min(); + int max = image->max(); for(unsigned int c = 0; c < image->getNbChannels(); ++c) { Histogram histo = image->getHistogram(c); - for(int i = 0; i < 256; ++i) { +// for(int i = -255; i < 256 ; ++i) { + for(int i = min; i<= max; i++){ if(histo[i] > 0) { double p = (double)histo[i] / image->getWidth() /image->getHeight(); entropy += p * log(p); @@ -52,8 +54,12 @@ void DoubleEntropyOp::operator()(const Image_t<double>* image, const std::map<co entropy = - entropy / log(2); outText(qApp->translate("Operations", "Entropy of the image = %1").arg(entropy).toStdString()); + } bool DoubleEntropyOp::needCurrentImg() const { return true; } + +DoubleEntropyOp::~DoubleEntropyOp() { +} diff --git a/app/Operations/DoubleEntropyOp.h b/app/Operations/DoubleEntropyOp.h index 4df8cd7..61ddffc 100644 --- a/app/Operations/DoubleEntropyOp.h +++ b/app/Operations/DoubleEntropyOp.h @@ -27,6 +27,8 @@ class DoubleEntropyOp : public DoubleOperation public: DoubleEntropyOp(); + virtual ~DoubleEntropyOp(); + void operator()(const imagein::Image_t<double>*, const std::map<const imagein::Image_t<double>*, std::string>&); bool needCurrentImg() const; diff --git a/app/Operations/EntropyOp.cpp b/app/Operations/EntropyOp.cpp index c14e279..4631cbe 100644 --- a/app/Operations/EntropyOp.cpp +++ b/app/Operations/EntropyOp.cpp @@ -57,3 +57,6 @@ void EntropyOp::operator()(const Image* image, const std::map<const imagein::Ima bool EntropyOp::needCurrentImg() const { return true; } + +EntropyOp::~EntropyOp() { +} diff --git a/app/Operations/EntropyOp.h b/app/Operations/EntropyOp.h index 2848b6f..53f01b5 100644 --- a/app/Operations/EntropyOp.h +++ b/app/Operations/EntropyOp.h @@ -27,6 +27,8 @@ class EntropyOp : public Operation public: EntropyOp(); + virtual ~EntropyOp(); + void operator()(const imagein::Image*, const std::map<const imagein::Image*, std::string>&); bool needCurrentImg() const; diff --git a/lib/detiq-t b/lib/detiq-t index 9376ae7..8f5e49b 160000 --- a/lib/detiq-t +++ b/lib/detiq-t @@ -1 +1 @@ -Subproject commit 9376ae7717171c4a1e7ab4027f2d656742689763 +Subproject commit 8f5e49b95200fc47fffcb06bf7a2a612ea72464e -- GitLab