Skip to content
Snippets Groups Projects
Commit 6fdf5e2e authored by ariotte's avatar ariotte
Browse files

added algorithm in operation

parent 40bcb681
No related branches found
No related tags found
No related merge requests found
...@@ -24,7 +24,10 @@ ...@@ -24,7 +24,10 @@
#include <QObject> #include <QObject>
#include "Operation.h" #include "Operation.h"
#include "ucharconvertdialog.h" #include "ucharconvertdialog.h"
#include "Image.h"
#include <Converter.h>
using namespace imagein;
UCharConvertOp::UCharConvertOp() : DoubleOperation(qApp->translate("Operations", "UChar converter").toStdString()) UCharConvertOp::UCharConvertOp() : DoubleOperation(qApp->translate("Operations", "UChar converter").toStdString())
{ {
...@@ -34,9 +37,57 @@ bool UCharConvertOp::needCurrentImg() const{ ...@@ -34,9 +37,57 @@ bool UCharConvertOp::needCurrentImg() const{
return true; 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()); UCharConvertDialog* dialog = new UCharConvertDialog(QApplication::activeWindow());
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;
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");
} }
...@@ -14,6 +14,10 @@ public: ...@@ -14,6 +14,10 @@ public:
bool needCurrentImg() const; bool needCurrentImg() const;
void operator()(const imagein::Image_t<double>*, const std::map<const imagein::Image_t<double>*, std::string>&); 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 #endif // UCHARCONVERTOP_H
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