diff --git a/app/Operations/UCharConvertOp.cpp b/app/Operations/UCharConvertOp.cpp index 81f982e5b3dfb844d9b7e060df3731b712ce7f89..45c4b47888d43f62493923bd876ae5d9fb6b8550 100644 --- a/app/Operations/UCharConvertOp.cpp +++ b/app/Operations/UCharConvertOp.cpp @@ -24,7 +24,10 @@ #include <QObject> #include "Operation.h" #include "ucharconvertdialog.h" +#include "Image.h" +#include <Converter.h> +using namespace imagein; UCharConvertOp::UCharConvertOp() : DoubleOperation(qApp->translate("Operations", "UChar converter").toStdString()) { @@ -34,9 +37,57 @@ bool UCharConvertOp::needCurrentImg() const{ return true; } -void UCharConvertOp::operator()(const imagein::Image_t<double>*, const std::map<const imagein::Image_t<double>*, std::string>&){ +void UCharConvertOp::operator()(const imagein::Image_t<double>* from, const std::map<const imagein::Image_t<double>*, std::string>&){ UCharConvertDialog* dialog = new UCharConvertDialog(QApplication::activeWindow()); QDialog::DialogCode code = static_cast<QDialog::DialogCode>(dialog->exec()); if(code!=QDialog::Accepted) return; + + + + + + Image * resImg; + std::string LogMessage = ""; + Image_t<int> * tempIntImg; + int offset; + switch(conversionTYPE) + { + case CROP : + resImg = Converter<Image>::convertAndRound(*from); + break; + + case NORMALIZE : + tempIntImg = Converter<Image_t<double>>::convertToInt(*from); + tempIntImg->normalize(); + resImg = Converter<Image>::convert(*tempIntImg); + delete tempIntImg; + break; + + case OFFSET : + tempIntImg = Converter<Image_t<double>>::convertToInt(*from); + offset = 130; //getOffset() + resImg = Converter<Image>::convertAndOffset(*tempIntImg, &LogMessage, offset); + delete tempIntImg; + break; + + case OFFSETNSCALE : + tempIntImg = Converter<Image_t<double>>::convertToInt(*from); + resImg = Converter<Image>::convertScaleAndOffset(*tempIntImg, &LogMessage); + delete tempIntImg; + break; + + case SCALE : + tempIntImg = Converter<Image_t<double>>::convertToInt(*from); + resImg = Converter<Image>::convertAndScale(*tempIntImg, &LogMessage); + delete tempIntImg; + break; + + default: + std::cout << "Default conversion" << std::endl; + resImg = Converter<Image>::convertAndRound(*from); + break; + } + + outImage(resImg, "Title"); } diff --git a/app/Operations/UCharConvertOp.h b/app/Operations/UCharConvertOp.h index 06c8d1b2438f59854fa2049fc164a56e3ab712f7..1091d40b68bcc9c120686ffb88fb978eaa2b63bb 100644 --- a/app/Operations/UCharConvertOp.h +++ b/app/Operations/UCharConvertOp.h @@ -14,6 +14,10 @@ public: bool needCurrentImg() const; void operator()(const imagein::Image_t<double>*, const std::map<const imagein::Image_t<double>*, std::string>&); + +private : + + enum{CROP, NORMALIZE, OFFSET, OFFSETNSCALE, SCALE} conversionTYPE; }; #endif // UCHARCONVERTOP_H