From b24a1cbd56433714e52fb76299edee69bedf514e Mon Sep 17 00:00:00 2001
From: qbigot <quentin.bigot@insa-rennes.fr>
Date: Fri, 1 Sep 2017 17:56:16 +0200
Subject: [PATCH] fix Hough and histogram problems and other issues

---
 app/Operations/DPCM.cpp               |  26 +++--
 app/Operations/DoubleEntropyOp.cpp    |   4 +-
 app/Operations/EntropyOp.cpp          |   2 +-
 app/Operations/HoughOp.cpp            |   1 +
 app/Operations/HoughOp.h              |   2 +
 app/Operations/InverseHoughDialog.cpp |   4 +
 app/Operations/InverseHoughDialog.h   |   1 +
 app/Operations/InverseHoughDialog.ui  |  15 +--
 app/Operations/InverseHoughOp.cpp     |   3 +-
 app/Operations/Transforms.cpp         | 155 +++++++++++++++++++-------
 app/Operations/Transforms.h           |   1 +
 app/imageinsa_en.ts                   |  19 +++-
 app/imageinsa_fr.ts                   |  10 +-
 core/Operation.cpp                    |   6 +-
 lib/detiq-t                           |   2 +-
 15 files changed, 176 insertions(+), 75 deletions(-)

diff --git a/app/Operations/DPCM.cpp b/app/Operations/DPCM.cpp
index caf889f..81d425e 100644
--- a/app/Operations/DPCM.cpp
+++ b/app/Operations/DPCM.cpp
@@ -60,7 +60,7 @@ string DPCM::execute( const GrayscaleImage *im, Prediction prediction_alg, image
     int code; // code
     int coding_err; // erreur de codage
 
-    float pi[512],piq[512],nbpt = 0;
+    double pi[512],piq[512],nbpt = 0;
     double h = 0.;
     double hq = 0.;
 
@@ -72,7 +72,7 @@ string DPCM::execute( const GrayscaleImage *im, Prediction prediction_alg, image
     codlq(0);
 
     /* allocation mmoire pour l'image d'erreur de prdiction */
-    ImageDouble *quantized_predction_error_image = new ImageDouble(imgWidth, imgHeight, 1);  // renommer quantized_predction_error_image
+    ImageDouble *quantized_prediction_error_image = new ImageDouble(imgWidth, imgHeight, 1);  // renommer quantized_prediction_error_image
     ImageDouble *predction_error_image = new ImageDouble(imgWidth, imgHeight, 1);  // renommer predction_error_image
     ImageDouble *coding_error_image = new ImageDouble(imgWidth, imgHeight, 1);
     Image *reconstructed_image = new GrayscaleImage(*im);
@@ -81,7 +81,7 @@ string DPCM::execute( const GrayscaleImage *im, Prediction prediction_alg, image
     // Init the error images with 0 values
     for(int i=0; i < imgHeight; i++) {
         for(int j=0; j< imgWidth; j++) {
-            quantized_predction_error_image->setPixelAt(j, i, 0);
+            quantized_prediction_error_image->setPixelAt(j, i, 0);
             predction_error_image->setPixelAt(j, i, 0);
         }
     }
@@ -151,25 +151,26 @@ string DPCM::execute( const GrayscaleImage *im, Prediction prediction_alg, image
             //erreur de prediction
             pred_err = thePixel - pred;
             predction_error_image->setPixelAt(j, i, pred_err);
-                  /* proba associe a l'erreur de prediction */
 
             depth_default_t pixImg = im->getPixelAt(j, i);
 
+            //code obsolete
+            //codec(0, quant_pred_err, &code, &reco);//action : voir code Vero 1988 calcul : reco = quant_pred_err (erreur de prediction quantifiee)
+            //int tempvalue = pred + reco;
+
             //quantification erreur de prediction
             quant_pred_err = quantdef->valueOf(pred_err);
+            quantized_prediction_error_image->setPixelAt(j, i, quant_pred_err);
 
-            codec(0, quant_pred_err, &code, &reco);//action ? on suppose codage/decodage sans perte : reco = quant_pred_err
-
+            //mise a jour proba pour calcul entropie
             pi[pred_err+255]++;
             piq[quant_pred_err+255]++;      /* proba associe a l'erreur de prediction */
             nbpt++;
 
-            quantized_predction_error_image->setPixelAt(j, i, quant_pred_err);
+            quantized_prediction_error_image->setPixelAt(j, i, quant_pred_err);
 
             // valeur reconstruite
-
-            int tempvalue = pred + reco;
-            //int tempvalue = pred + quant_pred_err;
+            int tempvalue = pred + quant_pred_err;
             // Crop the value in [0,255]
             reconstructed_image->setPixelAt(j, i, tempvalue > 255 ? 255 : tempvalue < 0 ? 0 : tempvalue);
             depth_default_t reconstructedPix = reconstructed_image->getPixelAt(j, i);
@@ -182,6 +183,7 @@ string DPCM::execute( const GrayscaleImage *im, Prediction prediction_alg, image
     }
 
     /* calcul de l'entropie de l'image d'erreur de prediction quantifiee */
+    nbpt = imgHeight*imgWidth;
     for(int i=0 ; i < 512 ; i++)
     {
         if(pi[i] != 0) {
@@ -194,6 +196,8 @@ string DPCM::execute( const GrayscaleImage *im, Prediction prediction_alg, image
         }
     }
 
+    //reprendre le code de DoubleEntropyOp pour voir si on obtient le même résultat
+
     /* affichage des rsultats */
     sprintf(buffer, "\nL'entropie de l'image d'erreur de prediction vaut : %lf\n",h);
     sprintf(buffer2, "\nL'entropie de l'image d'erreur de prediction quantifiee vaut : %lf\n",hq);
@@ -204,7 +208,7 @@ string DPCM::execute( const GrayscaleImage *im, Prediction prediction_alg, image
     returnval = returnval + print_iloiqu();
 
     /* libration de la mmoire alloue */
-    *quant_err_image = quantized_predction_error_image;
+    *quant_err_image = quantized_prediction_error_image;
     *err_image = predction_error_image;
     *recons_image = reconstructed_image;
     *pred_image = prediction_image;
diff --git a/app/Operations/DoubleEntropyOp.cpp b/app/Operations/DoubleEntropyOp.cpp
index ff55790..4535898 100644
--- a/app/Operations/DoubleEntropyOp.cpp
+++ b/app/Operations/DoubleEntropyOp.cpp
@@ -42,7 +42,7 @@ void DoubleEntropyOp::operator()(const Image_t<double>* image, const std::map<co
     int min = image->min();
     int max = image->max();
     for(unsigned int c = 0; c < image->getNbChannels(); ++c) {
-        Histogram histo = image->getHistogram(c);
+        Histogram histo = image->getHistogramForEntropy(c, 511);
 //      for(int i = -255; i < 256 ; ++i) {
         for(int i = min; i<= max; i++){
             if(histo[i] > 0) {
@@ -53,7 +53,7 @@ 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());
+    outText(qApp->translate("Operations", "Entropy of the image (sum of channels entropy) = %1").arg(entropy).toStdString());
 
 }
 
diff --git a/app/Operations/EntropyOp.cpp b/app/Operations/EntropyOp.cpp
index 4631cbe..cf55946 100644
--- a/app/Operations/EntropyOp.cpp
+++ b/app/Operations/EntropyOp.cpp
@@ -51,7 +51,7 @@ void EntropyOp::operator()(const Image* image, const std::map<const imagein::Ima
     }
 
     entropy = - entropy / log(2);
-    outText(qApp->translate("Operations", "Entropy of the image = %1").arg(entropy).toStdString());
+    outText(qApp->translate("Operations", "Entropy of the image (sum of channels entropy) = %1").arg(entropy).toStdString());
 }
 
 bool EntropyOp::needCurrentImg() const {
diff --git a/app/Operations/HoughOp.cpp b/app/Operations/HoughOp.cpp
index 04af234..b4ec4ac 100644
--- a/app/Operations/HoughOp.cpp
+++ b/app/Operations/HoughOp.cpp
@@ -43,6 +43,7 @@ void HoughOp::operator()(const imagein::Image* img, const std::map<const imagein
 
     if(code!=QDialog::Accepted) return;
     if(dialog->isMethod1()) {
+        method1 = true;
         GrayscaleImage* image = Converter<GrayscaleImage>::convert(*img);
         resImg = Transforms::hough(image);
         delete image;
diff --git a/app/Operations/HoughOp.h b/app/Operations/HoughOp.h
index 06190cb..52f27a8 100644
--- a/app/Operations/HoughOp.h
+++ b/app/Operations/HoughOp.h
@@ -33,11 +33,13 @@ public:
 
     double getAngleStep(){return angleStep;}
     double getDistanceStep(){return distanceStep;}
+    bool hough1(){return method1;}
 
 private:
 
     double angleStep;
     double distanceStep;
+    bool method1;
 };
 
 #endif // HOUGHOP_H
diff --git a/app/Operations/InverseHoughDialog.cpp b/app/Operations/InverseHoughDialog.cpp
index 76a339f..041e34c 100644
--- a/app/Operations/InverseHoughDialog.cpp
+++ b/app/Operations/InverseHoughDialog.cpp
@@ -40,6 +40,10 @@ int InverseHoughDialog::getHeight() const {
     return ui->heightBox->value();
 }
 
+//int InverseHoughDialog::getSize() const {
+//    return ui->sizeBox->value();
+//}
+
 int InverseHoughDialog::getThreshodl() const {
     return ui->thresholdBox->value();
 }
diff --git a/app/Operations/InverseHoughDialog.h b/app/Operations/InverseHoughDialog.h
index 405cb4c..ea10af6 100644
--- a/app/Operations/InverseHoughDialog.h
+++ b/app/Operations/InverseHoughDialog.h
@@ -35,6 +35,7 @@ public:
     ~InverseHoughDialog();
     int getWidth() const;
     int getHeight() const;
+//    int getSize() const;
     int getThreshodl() const;
     
 private:
diff --git a/app/Operations/InverseHoughDialog.ui b/app/Operations/InverseHoughDialog.ui
index fd0b42b..dc6aef2 100644
--- a/app/Operations/InverseHoughDialog.ui
+++ b/app/Operations/InverseHoughDialog.ui
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>279</width>
-    <height>113</height>
+    <height>121</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -19,12 +19,12 @@
      <item row="0" column="0">
       <widget class="QLabel" name="label">
        <property name="text">
-        <string>Reconstructed image width : </string>
+        <string>Reconstructed image height : </string>
        </property>
       </widget>
      </item>
      <item row="0" column="1">
-      <widget class="QSpinBox" name="widthBox">
+      <widget class="QSpinBox" name="heightBox">
        <property name="minimum">
         <number>1</number>
        </property>
@@ -35,7 +35,7 @@
         <number>1</number>
        </property>
        <property name="value">
-        <number>256</number>
+        <number>1</number>
        </property>
       </widget>
      </item>
@@ -56,21 +56,18 @@
      <item row="1" column="0">
       <widget class="QLabel" name="label_3">
        <property name="text">
-        <string>Reconstructed image height :</string>
+        <string>Reconstructed image width : </string>
        </property>
       </widget>
      </item>
      <item row="1" column="1">
-      <widget class="QSpinBox" name="heightBox">
+      <widget class="QSpinBox" name="widthBox">
        <property name="minimum">
         <number>1</number>
        </property>
        <property name="maximum">
         <number>65536</number>
        </property>
-       <property name="value">
-        <number>256</number>
-       </property>
       </widget>
      </item>
     </layout>
diff --git a/app/Operations/InverseHoughOp.cpp b/app/Operations/InverseHoughOp.cpp
index 6d7c1c0..7e24a0c 100644
--- a/app/Operations/InverseHoughOp.cpp
+++ b/app/Operations/InverseHoughOp.cpp
@@ -25,7 +25,7 @@
 using namespace std;
 using namespace imagein;
 
-InverseHoughOp::InverseHoughOp() : DoubleOperation(qApp->translate("Operations", "Houghman inverse transform").toStdString())
+InverseHoughOp::InverseHoughOp() : DoubleOperation(qApp->translate("Operations", "Inverse Hough transform").toStdString())
 {
 }
 
@@ -41,5 +41,6 @@ void InverseHoughOp::operator()(const imagein::Image_t<double>* img, const std::
     if(code!=QDialog::Accepted) return;
     Image* resImg2;
     Transforms::hough2_inverse(img, &resImg2, dialog->getWidth(), dialog->getHeight(), dialog->getThreshodl());
+    //Transforms::hough2_inverse(img, &resImg2, dialog->getSize(), dialog->getThreshodl());
     outImage(resImg2, qApp->translate("Hough", "Hough inverse transform").toStdString());
 }
diff --git a/app/Operations/Transforms.cpp b/app/Operations/Transforms.cpp
index 9523498..4adc87d 100644
--- a/app/Operations/Transforms.cpp
+++ b/app/Operations/Transforms.cpp
@@ -24,6 +24,7 @@
 #include <cstdio>
 #include <Converter.h>
 
+#include <Utilities/Log.h>
 using namespace std;
 using namespace imagein;
 const double pi = 3.1415926535897932384626433832795;
@@ -47,33 +48,77 @@ Image_t<double>* Transforms::hough(const GrayscaleImage *image ) {   //TODO : in
                 int i1 = i;
 
                 for(unsigned int j1 = j+1; j1 < image->getWidth(); j1++) {
+
                     if(image->getPixelAt(j1, i1) == 255) {
+
+                        //passage dans le repere x horieontal, y vertical et origine en bas à gauche
                         const double x0 = j;
                         const double y0 = image->getHeight() -i;
                         const double x1 = j1;
                         const double y1 = image->getHeight()-i1;
+
+                        //calcul de la droite passant par les deux points
                         const double l0 = sqrt((double)((y0-y1)*(y0-y1) + (x0-x1)*(x0-x1)));
                         const double l1 = fabs((double)(x0*y1 - x1*y0));
-                        const double x2 = l1/l0;
+                        const double rho = l1/l0;
                         double y2;
-                        const int j2 = x2 + 0.5;
-                        int i2;
+                        const int j2 = rho + 0.5;
+                        double theta;
+                        double thetadeg;
+                        if(x0==x1){
+                            theta = 0;
+                            //Log::info("x0==x1");
+
+                        }else{
+                            //Log::info("x0!=x1");
+                            theta = atan((y1-y0) / (x1-x0))+ pid2;
+
+                            //cas ou theta entre 0 et -pi/2
+                            //Calcul de l'ordonnee a l'origine
+                            int ordorig = y0 - x0 * ((y1-y0) / (x1-x0));
+
+                            //Log::info("theta = "+std::to_string(theta)+"atan = "+std::to_string(atan((y1-y0) / (x1-x0))+pid2)+ " ; ordorig = "+std::to_string(ordorig));
+                            if(ordorig < 0 && ((y1-y0) / (x1-x0)) > 0) theta = theta - pi;
+
+                        }
+                        //Passage de radian a degre
+                        thetadeg = theta*(180/pi);
+                        //Coordonées du point a colorier dans l'espace de Hough
+                        //Espace de Hough :
+                        //Origine en bas a gauche
+                        //Rho horizontal vers la droite de 0 a imageDiag
+                        //Theta vertical vers le haut de -90 a 180
+                        int rhoStep = 1;
+                        int angleStep = 1;
+                        int jDisplayRho = round(rho / rhoStep);
+                        int iDisplayTheta = round((180-thetadeg) / angleStep);
+                        //Log::info("x0 = "+std::to_string(x0)+ "; x1 = "+std::to_string(x1)+" ; y0 = "+std::to_string(y0)+" ; y1 = "+std::to_string(y1)+" ; Rho = "+std::to_string(rho)+" ; Theta = "+std::to_string(thetadeg)+" ; ThetaDisplay = "+std::to_string(iDisplayTheta));
+
 
-                            y2 = (x1 != x0) ? atan((y1-y0) / (x1-x0)) + pid2 : y1 > y0 ? pi : pid2;
-                            i2 = (int)(180-((y2 / pi) * 180. +180 + 0.5)) +1;
-                            //i2 = (int) (y2*(pi/180));
-                            //Coordonées du point a colorier dans l'espace de Hough
-                            //Espace de Hough :
-                            //Origine en bas a gauche
-                            //Rho horizontal vers la droite de 0 a imageDiag
-                            //Theta vertical vers le haut de -90 a 180
-                            int jDisplayRho = round(j2);
-                            int iDisplayTheta = round(i2+180);
 
+//                            y2 = x1 != x0 ? atan((y1-y0) / (x1-x0))+ pid2 : y1 > y0 ? pi : pid2;//pid2 dans les deux cas (?)
+//                            theta = (int)(180-((y2 / pi) * 180. +180 + 0.5)) +1;//conversion en entier + modulo 180
+                        //theta = (int) ((y2/pi)*180);
 
-                            resImg->setPixelAt(jDisplayRho, iDisplayTheta, resImg->getPixelAt(jDisplayRho, iDisplayTheta) + 1.);
 
-                        //resImg->setPixelAt(j2, i2, resImg->getPixelAt(j2, i2) + 1.);
+
+
+//                            y2 = (x1 != x0) ? atan((y1-y0) / (x1-x0)) + pid2 : y1 > y0 ? pi : pid2;
+//                            theta = (int)(180-((y2 / pi) * 180. +180 + 0.5)) +1;
+//                            //theta = (int) (y2*(pi/180));
+//                            //Coordonées du point a colorier dans l'espace de Hough
+//                            //Espace de Hough :
+//                            //Origine en bas a gauche
+//                            //Rho horizontal vers la droite de 0 a imageDiag
+//                            //Theta vertical vers le haut de -90 a 180
+//                            int jDisplayRho = round(j2);
+//                            int iDisplayTheta = round(theta+180);
+
+
+                        resImg->pixelAt(jDisplayRho, iDisplayTheta, 0)++;
+//                            resImg->setPixelAt(jDisplayRho, iDisplayTheta, resImg->getPixelAt(jDisplayRho, iDisplayTheta) + 1.);
+
+                        //resImg->setPixelAt(j2, theta, resImg->getPixelAt(j2, theta) + 1.);
                     }
                 }
 
@@ -86,26 +131,46 @@ Image_t<double>* Transforms::hough(const GrayscaleImage *image ) {   //TODO : in
                             const double y1 = image->getHeight()-i1;//-i1
                             const double l0 = sqrt((double)((y0-y1)*(y0-y1) + (x0-x1)*(x0-x1)));
                             const double l1 = fabs((double)(x0*y1 - x1*y0));
-                            const double x2 = l1/l0; //Rho reel
-                            double y2;//theta radian (enconce tp)
-                            const int j2 = x2 + 0.5; //rho arrondi entier
-                            int i2;// theta degre [0 :180[
-
-                            y2 = x1 != x0 ? atan((y1-y0) / (x1-x0))+ pid2 : y1 > y0 ? pi : pid2;//pid2 dans les deux cas (?)
-                            i2 = (int)(180-((y2 / pi) * 180. +180 + 0.5)) +1;//conversion en entier + modulo 180
-                            //i2 = (int) ((y2/pi)*180);
+                            const double rho = l1/l0; //Rho reel
+                            double theta;// theta radian
+                            double thetadeg;//theta degre
+                            if(x0==x1){
+                                theta = 0;
+                                //Log::info("x0==x1");
+
+                            }else{
+                                theta = atan((y1-y0) / (x1-x0))+ pid2;
+                                //Log::info("x0!=x1");
+
+                                //cas ou theta entre 0 et -pi/2
+                                //Calcul de l'ordonnee a l'origine
+                                int ordorig = y0 - x0 * ((y1-y0) / (x1-x0));
+                                //Log::info("theta = "+std::to_string(theta)+"atan = "+std::to_string(atan((y1-y0) / (x1-x0))+pid2)+ " ; ordorig = "+std::to_string(ordorig));
+                                if(ordorig < 0 && ((y1-y0) / (x1-x0)) > 0) theta = theta - pi;
+                            }
+                            //Passage de radian a degre
+                            thetadeg = theta*(180/pi);
+
+//                            y2 = x1 != x0 ? atan((y1-y0) / (x1-x0))+ pid2 : y1 > y0 ? pi : pid2;//pid2 dans les deux cas (?)
+//                            theta = (int)(180-((y2 / pi) * 180. +180 + 0.5)) +1;//conversion en entier + modulo 180
+                            //theta = (int) ((y2/pi)*180);
+
+
                             //Coordonées du point a colorier dans l'espace de Hough
                             //Espace de Hough :
                             //Origine en bas a gauche
                             //Rho horizontal vers la droite de 0 a imageDiag
                             //Theta vertical vers le haut de -90 a 180
-                            int jDisplayRho = round(j2);
-                            int iDisplayTheta = round(i2+180);
-
+                            int rhoStep = 1;
+                            int angleStep = 1;
+                            int jDisplayRho = round(rho / rhoStep);
+                            int iDisplayTheta = round((180-thetadeg) / angleStep);
+                            //Log::info("x0 = "+std::to_string(x0)+ "; x1 = "+std::to_string(x1)+" ; y0 = "+std::to_string(y0)+" ; y1 = "+std::to_string(y1)+" ; Rho = "+std::to_string(rho)+" ; Theta = "+std::to_string(thetadeg)+" ; ThetaDisplay = "+std::to_string(iDisplayTheta));
 
-                            resImg->setPixelAt(jDisplayRho, iDisplayTheta, resImg->getPixelAt(jDisplayRho, iDisplayTheta) + 1.);
+                            resImg->pixelAt(jDisplayRho, iDisplayTheta, 0)++;
+//                          resImg->setPixelAt(jDisplayRho, iDisplayTheta, resImg->getPixelAt(jDisplayRho, iDisplayTheta) + 1.);
 
-                            //resImg->setPixelAt(j2, i2, resImg->getPixelAt(j2, i2) + 1.);
+                            //resImg->setPixelAt(j2, theta, resImg->getPixelAt(j2, theta) + 1.);
                         }
                     }
                 }
@@ -137,7 +202,7 @@ Image_t<double>* Transforms::hough2(const Image *image, double angleStep, double
         {
             for(unsigned int j = 0; j < image->getWidth(); ++j)
             {
-                if(image->getPixelAt(i, j, c) == 255)
+                if(image->getPixelAt(j, i, c) == 255)//getPixelAt demande la colonne j puis la ligne i
                 {
                     //Changement de repere : origine en bas  a gauche de l'image, x horizontal vers la droite et y vertical vers le haut
                     int x = j;
@@ -160,7 +225,7 @@ Image_t<double>* Transforms::hough2(const Image *image, double angleStep, double
                             //Rho horizontal vers la droite de 0 a imageDiag
                             //Theta vertical vers le haut de -90 a 180
                             int jDisplayRho = round(rho / rhoStep);
-                            int iDisplayTheta = round((te+90) / angleStep);
+                            int iDisplayTheta = round((180-te) / angleStep);
 
                             resImg->pixelAt(jDisplayRho, iDisplayTheta, c)++;
                         }
@@ -182,8 +247,10 @@ Image_t<double>* Transforms::hough2(const Image *image, double angleStep, double
     return resImg;
 }
 string Transforms::hough2_inverse(const Image_t<double> *image, Image** resImgptr, unsigned int width, unsigned int height, unsigned int threshold) {
+//string Transforms::hough2_inverse(const Image_t<double> *image, Image** resImgptr, unsigned int size, unsigned int threshold) {
 
     Image_t<uint32_t>* resImg = new Image_t<uint32_t>(width, height, image->getNbChannels(), uint32_t(0));
+   // Image_t<uint32_t>* resImg = new Image_t<uint32_t>(size, size, image->getNbChannels(), uint32_t(0));
 
 //    int param = 5000 + 20 * image->getWidth() * image->getHeight();
 
@@ -195,7 +262,7 @@ string Transforms::hough2_inverse(const Image_t<double> *image, Image** resImgpt
 //    sprintf( buffer, "Valeur Max de la matrice d'entre=%d",(int)(max+0.1));
 
 
-    double angleStep = 180. / image->getHeight();
+    double angleStep = 271. / image->getHeight(); //les angles varient de -90 à +180 = intervalle de longueur 271 degre
     double imageDiag = resImg->getWidth() * sqrt(2.);
     double rhoStep = imageDiag / image->getWidth();
 
@@ -210,7 +277,7 @@ string Transforms::hough2_inverse(const Image_t<double> *image, Image** resImgpt
                 if(n >= threshold)
                 {
                     cmpt++;
-                    double angle = angleStep * i / 180. * pi;
+                    double angle = (180 - (angleStep * i)) / 180. * pi;
                     double rho = rhoStep * j;
                     double sinte = sin(angle);
                     double coste = cos(angle);
@@ -218,23 +285,26 @@ string Transforms::hough2_inverse(const Image_t<double> *image, Image** resImgpt
     //                sprintf( tampon,"\nniveau=%d\tangle=%1.0f\tdistance=%1.0f",(int)(0.1+tab_image[i+nl*j]),angle/pi*180.,rho);
     //                strcat( buffer, tampon);
 
-                    //Construction de la droite d'quation
+                    //Construction de la droite d'quation rho = x*coste + y*sinte
                     for(unsigned int jj = 0; jj < width; ++jj) {
-
-    //                    int kk = rho * (cos(angle) + tan(angle) * sin(angle)) - tan(angle)*jj;
-                        int kk = (rho - sinte * jj) / coste;
-                        if( kk > 0 && kk < height) {
-                            resImg->pixelAt(jj, kk, c) += n;
+                        double x = jj;
+                        double y = (rho - x*coste)/sinte;
+                        int ii = height-round(y);
+//                        int kk = rho * (cos(angle) + tan(angle) * sin(angle)) - tan(angle)*jj;
+                        if( ii >= 0 && ii < height) {
+                            resImg->pixelAt(jj, ii, c) += n;
                         }
+
                     }
                     for(unsigned int ii = 0; ii < height; ++ii) {
     //                    int kk = ( rho * (cos(angle) + tan(angle) * sin(angle)) -ii ) / tan(angle);
-                        int kk = (rho - coste * ii) / sinte;
-                        if( kk>0 && kk < width) {
-                            resImg->pixelAt(kk, ii, c) += n;
+                        double y = height - ii;
+                        double x = (rho-y*sinte)/coste;
+                        int jj = round(x);
+                        if( jj>=0 && jj < width) {
+                            resImg->pixelAt(jj, ii, c) += n;
                         }
                      }
-
                 }
             }
         }
@@ -242,6 +312,7 @@ string Transforms::hough2_inverse(const Image_t<double> *image, Image** resImgpt
 
 //        sprintf( tampon,"\nNombre de droites traces=%d",cmpt);
 //        strcat( buffer, tampon);
+
     //On applique une mise à l'echelle de l'image pour mettre la valeur max a 255
     std::cout << resImg->max() << std::endl;
     Image* resStdImg = new Image(resImg->getWidth(), resImg->getHeight(), resImg->getNbChannels());
diff --git a/app/Operations/Transforms.h b/app/Operations/Transforms.h
index 1044972..fe7650f 100644
--- a/app/Operations/Transforms.h
+++ b/app/Operations/Transforms.h
@@ -29,6 +29,7 @@ namespace Transforms
     imagein::Image_t<double> *hough( const imagein::GrayscaleImage *im ); // This function works
     imagein::Image_t<double> *hough2( const imagein::Image *im , double angleStep, double rhoStep); // This function works
     std::string hough2_inverse(const imagein::Image_t<double> *image, imagein::Image **resImg, unsigned int width, unsigned int height, unsigned int threshold);
+    //std::string hough2_inverse(const imagein::Image_t<double> *image, imagein::Image **resImg, unsigned int size, unsigned int threshold);
     std::string Hadamard( const imagein::Image *im, imagein::Image_t<double> **result, imagein::Image **result_inverse, imagein::GrayscaleImage_t<bool> *selection = NULL);
     std::string Haar( const imagein::Image *im, imagein::Image_t<double> **result, imagein::Image **result_inverse, imagein::GrayscaleImage_t<bool> *selection = NULL );
     std::string cosinus( const imagein::Image *image, imagein::Image_t<double> **resImg, imagein::Image **invImg, imagein::GrayscaleImage_t<bool> *selection = NULL  );
diff --git a/app/imageinsa_en.ts b/app/imageinsa_en.ts
index 6145f5a..25ba880 100644
--- a/app/imageinsa_en.ts
+++ b/app/imageinsa_en.ts
@@ -546,6 +546,21 @@ Number of classes = %1 </translation>
         <source>Reconstructed image</source>
         <translation>Reconstructed image</translation>
     </message>
+    <message>
+        <location filename="Operations/DPCM.cpp"/>
+        <source>\nL'entropie de l'image d'erreur de prediction vaut : %lf\n</source>
+        <translation>The entropy of the predicion error image is :</translation>
+    </message>
+    <message>
+        <location filename="Operations/DPCM.cpp"/>
+        <source>\nL'entropie de l'image d'erreur de prediction quantifiee vaut : %lf\n</source>
+        <translation>The entropy of the quantized predicion error image is :</translation>
+    </message>
+    <message>
+        <location filename="Operations/DPCM.cpp"/>
+        <source>seuils de decision --------------- niveaux de reconstruction\n</source>
+        <translation>decision thresholds --------- reconstruction levels\n</translation>
+    </message>    
 </context>
 <context>
     <name>DPCMDialog</name>
@@ -1122,8 +1137,8 @@ Number of classes = %1 </translation>
     </message>
     <message>
         <location filename="Operations/InverseHoughOp.cpp" line="28"/>
-        <source>Houghman inverse transform</source>
-        <translation>Houghman inverse transform</translation>
+        <source>Inverse Hough transform</source>
+        <translation>Inverse Hough transform</translation>
     </message>
     <message>
         <location filename="Operations/InversePyramidOp.cpp" line="31"/>
diff --git a/app/imageinsa_fr.ts b/app/imageinsa_fr.ts
index 3c7548f..c55d522 100644
--- a/app/imageinsa_fr.ts
+++ b/app/imageinsa_fr.ts
@@ -969,13 +969,13 @@ Nombre de classes = %1 </translation>
     </message>
     <message>
         <location filename="Operations/DoubleEntropyOp.cpp" line="47"/>
-        <source>Entropy of the image = %1</source>
-        <translation>Entropie de l&apos;image = %1</translation>
+        <source>Entropy of the image (sum of channels entropy) = %1</source>
+        <translation>Entropie de l&apos;image (somme des entropies des canaux) = %1</translation>
     </message>
     <message>
         <location filename="Operations/EntropyOp.cpp" line="30"/>
-        <source>Calcul d&apos;entropie (image standard)</source>
-        <translation>Calcul d&apos;entropie (image standard)</translation>
+        <source>Entropy of the image (sum of channels entropy) = %1</source>
+        <translation>Entropie de l&apos;image (somme des entropies des canaux) = %1</translation>
     </message>
     <message>
         <location filename="Operations/EntropyOp.cpp" line="47"/>
@@ -1127,7 +1127,7 @@ Nombre de classes = %1 </translation>
     </message>
     <message>
         <location filename="Operations/InverseHoughOp.cpp" line="28"/>
-        <source>Houghman inverse transform</source>
+        <source>Inverse Hough transform</source>
         <translation>Transformée de Hough inverse</translation>
     </message>
     <message>
diff --git a/core/Operation.cpp b/core/Operation.cpp
index c6b425d..c0d1c29 100644
--- a/core/Operation.cpp
+++ b/core/Operation.cpp
@@ -73,7 +73,11 @@ void GenericOperation::outDoubleImage(imagein::ImageDouble* img, string title, b
     DoubleImageWindow* wnd = new DoubleImageWindow(img, QString(), norm, log, logScale, abs);
     if(HoughOp* v = dynamic_cast<HoughOp*>(this)) {
        // teste si l'operation effectuee est une transformee de Hough
-       wnd->isHough(v->getAngleStep(), v->getDistanceStep());
+       if (v->hough1()){
+           wnd->isHough(1, 1);
+       }else{
+           wnd->isHough(v->getAngleStep(), v->getDistanceStep());
+       }
        //isHough=true ce qui change les coordonnées des pixels de l'image pour correspondre au domaine de Hough
     }
     this->outImgWnd(wnd, title);
diff --git a/lib/detiq-t b/lib/detiq-t
index 6224831..bcc0ab1 160000
--- a/lib/detiq-t
+++ b/lib/detiq-t
@@ -1 +1 @@
-Subproject commit 6224831a2e6b63d719ddd92b0f2407a475ffd41a
+Subproject commit bcc0ab1b62450d9edb9b38dfebcdc7c46e808706
-- 
GitLab