Skip to content
Snippets Groups Projects
Commit 97f25d89 authored by Antoine Lorence's avatar Antoine Lorence
Browse files

[MICD] Fix values on generated error image: remove clipping

The error is now stored in an Image with double values,
without restriction on these
parent 4a1a538c
No related branches found
No related tags found
No related merge requests found
...@@ -45,7 +45,7 @@ MICD::~MICD() ...@@ -45,7 +45,7 @@ MICD::~MICD()
} }
string MICD::execute( const GrayscaleImage *im, Prediction prediction_alg, Image **err_image, Image **recons_image, double Q ) { string MICD::execute( const GrayscaleImage *im, Prediction prediction_alg, imagein::ImageDouble **err_image, Image **recons_image, double Q ) {
char buffer[255]; char buffer[255];
if( quantdef == NULL ) { if( quantdef == NULL ) {
throw "Error in MICD::execute:\nquantdef = NULL"; throw "Error in MICD::execute:\nquantdef = NULL";
...@@ -66,7 +66,7 @@ string MICD::execute( const GrayscaleImage *im, Prediction prediction_alg, Image ...@@ -66,7 +66,7 @@ string MICD::execute( const GrayscaleImage *im, Prediction prediction_alg, Image
set_levels(); set_levels();
codlq(0); codlq(0);
/* allocation mmoire pour l'image d'erreur de prdiction */ /* allocation mmoire pour l'image d'erreur de prdiction */
GrayscaleImage *error_prediction_image = new GrayscaleImage(nbc, nbl); ImageDouble *error_prediction_image = new ImageDouble(nbc, nbl, 1);
Image *reconstructed_image = new GrayscaleImage(*im); Image *reconstructed_image = new GrayscaleImage(*im);
// File these images with all values of zero // File these images with all values of zero
long wcounter, hcounter; long wcounter, hcounter;
...@@ -135,8 +135,6 @@ string MICD::execute( const GrayscaleImage *im, Prediction prediction_alg, Image ...@@ -135,8 +135,6 @@ string MICD::execute( const GrayscaleImage *im, Prediction prediction_alg, Image
int tempvalue; int tempvalue;
tempvalue = ier + 128; tempvalue = ier + 128;
if( tempvalue > 255 ) tempvalue = 255;
if( tempvalue < 0 ) tempvalue = 0;
po = tempvalue; po = tempvalue;
error_prediction_image->setPixelAt( j, i, po ); error_prediction_image->setPixelAt( j, i, po );
tempvalue = pred + ireco; tempvalue = pred + ireco;
...@@ -156,7 +154,6 @@ string MICD::execute( const GrayscaleImage *im, Prediction prediction_alg, Image ...@@ -156,7 +154,6 @@ string MICD::execute( const GrayscaleImage *im, Prediction prediction_alg, Image
} }
} }
/* affichage des rsultats */ /* affichage des rsultats */
sprintf(buffer, "\nL'entropie de l'image d'erreur de prediction vaut : %lf\n",h); sprintf(buffer, "\nL'entropie de l'image d'erreur de prediction vaut : %lf\n",h);
returnval = returnval + buffer; returnval = returnval + buffer;
......
...@@ -30,7 +30,7 @@ public: ...@@ -30,7 +30,7 @@ public:
MICD(); MICD();
enum Prediction {PX_EQ_A, PX_EQ_B, PX_EQ_APC, PX_EQ_Q}; enum Prediction {PX_EQ_A, PX_EQ_B, PX_EQ_APC, PX_EQ_Q};
virtual ~MICD(); virtual ~MICD();
std::string execute( const imagein::GrayscaleImage *im, Prediction prediction_alg, imagein::Image **err_image, imagein::Image **recons_image, double Q = 0 ); std::string execute(const imagein::GrayscaleImage *im, Prediction prediction_alg, imagein::ImageDouble **err_image, imagein::Image **recons_image, double Q = 0 );
void setQuantification( Quantification* tquantdef ); void setQuantification( Quantification* tquantdef );
private: private:
std::string print_iloiqu(); std::string print_iloiqu();
......
...@@ -55,7 +55,6 @@ Quantification* MICDDialog::getQuantification() const { ...@@ -55,7 +55,6 @@ Quantification* MICDDialog::getQuantification() const {
catch(std::exception&) { catch(std::exception&) {
return NULL; return NULL;
} }
} }
MICD::Prediction MICDDialog::getPrediction() const { MICD::Prediction MICDDialog::getPrediction() const {
......
...@@ -43,21 +43,23 @@ void MICDEncodingOp::operator()(const imagein::Image* img, const std::map<const ...@@ -43,21 +43,23 @@ void MICDEncodingOp::operator()(const imagein::Image* img, const std::map<const
QDialog::DialogCode code = static_cast<QDialog::DialogCode>(dialog->exec()); QDialog::DialogCode code = static_cast<QDialog::DialogCode>(dialog->exec());
if(code!=QDialog::Accepted) return; if(code != QDialog::Accepted) return;
MICD micd; MICD micd;
try { try {
micd.setQuantification(dialog->getQuantification()); micd.setQuantification(dialog->getQuantification());
} }
catch(const char* str) { catch(const char* str) {
QMessageBox::critical(NULL, qApp->translate("MICD", "Error while loading quantification file"), qApp->translate("MICD", "The specified quantification file could not be opened !")); QMessageBox::critical(NULL, qApp->translate("MICD", "Error while loading quantification file"),
qApp->translate("MICD", "The specified quantification file could not be opened !"));
return; return;
} }
GrayscaleImage* image = Converter<GrayscaleImage>::convert(*img); GrayscaleImage* image = Converter<GrayscaleImage>::convert(*img);
Image *errorImage, *reconstructedImage; Image *reconstructedImage;
ImageDouble *errorImage;
string s = micd.execute(image, dialog->getPrediction(), &errorImage, &reconstructedImage, dialog->getQ()); string s = micd.execute(image, dialog->getPrediction(), &errorImage, &reconstructedImage, dialog->getQ());
outText(s); outText(s);
outImage(errorImage, qApp->translate("MICD", "Error image").toStdString()); outDoubleImage(errorImage, qApp->translate("MICD", "Error image").toStdString());
outImage(reconstructedImage, qApp->translate("MICD", "Reconstructed image").toStdString()); outImage(reconstructedImage, qApp->translate("MICD", "Reconstructed image").toStdString());
} }
...@@ -68,7 +68,7 @@ void GenericOperation::outImage(imagein::Image* img, string title) { ...@@ -68,7 +68,7 @@ void GenericOperation::outImage(imagein::Image* img, string title) {
this->outImgWnd(wnd, title); this->outImgWnd(wnd, title);
} }
void GenericOperation::outDoubleImage(imagein::Image_t<double>* img, string title, bool norm, bool log, double logScale, bool abs) { void GenericOperation::outDoubleImage(imagein::ImageDouble* img, string title, bool norm, bool log, double logScale, bool abs) {
DoubleImageWindow* wnd = new DoubleImageWindow(img, QString(), norm, log, logScale, abs); DoubleImageWindow* wnd = new DoubleImageWindow(img, QString(), norm, log, logScale, abs);
this->outImgWnd(wnd, title); this->outImgWnd(wnd, title);
} }
......
...@@ -120,7 +120,7 @@ class GenericOperation { ...@@ -120,7 +120,7 @@ class GenericOperation {
* @param logScale The logarithm scale constant to apply if the Image is displayed using log. scale (value from 8^-3 to 8^3, see genericinterface::DoubleImageWindow for more details). * @param logScale The logarithm scale constant to apply if the Image is displayed using log. scale (value from 8^-3 to 8^3, see genericinterface::DoubleImageWindow for more details).
* @param abs wether to display an absolute value version of the Image (doesn't affect the data contained in the image, compatible with any other options). * @param abs wether to display an absolute value version of the Image (doesn't affect the data contained in the image, compatible with any other options).
*/ */
void outDoubleImage(imagein::Image_t<double>* img, std::string title = "", bool norm=false, bool log=false, double logScale = 1., bool abs = false); void outDoubleImage(imagein::ImageDouble* img, std::string title = "", bool norm=false, bool log=false, double logScale = 1., bool abs = false);
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment