diff --git a/.gitignore b/.gitignore index 38f517db2..214136aa7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .DS_Store +core/algorithms/ImagingAlgorithms/.DS_Store build* *.user *.stash diff --git a/GUI/qt/ImagingTests/ImagingTests.pro b/GUI/qt/ImagingTests/ImagingTests.pro new file mode 100644 index 000000000..999b68697 --- /dev/null +++ b/GUI/qt/ImagingTests/ImagingTests.pro @@ -0,0 +1,52 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2018-06-29T07:56:02 +# +#------------------------------------------------- + +QT += core gui + +greaterThan(QT_MAJOR_VERSION, 4): QT += widgets + +TARGET = ImagingTests +TEMPLATE = app + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + + +SOURCES += \ + main.cpp \ + mainwindow.cpp + +HEADERS += \ + mainwindow.h + +FORMS += \ + mainwindow.ui + +CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../lib -lkipl -lQtAddons -lReaderConfig -lQtImaging +else:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../lib/debug -lkipl -lQtAddons -lReaderConfig -lQtImaging + +INCLUDEPATH += $$PWD/../../../core/kipl/kipl/include +DEPENDPATH += $$PWD/../../../core/kipl/kipl/include + +INCLUDEPATH += $$PWD/../../../core/modules/ReaderConfig/ +DEPENDPATH += $$PWD/../../../core/modules/ReaderConfig/ + +INCLUDEPATH += $$PWD/../../../gui/qt/QtAddons +DEPENDPATH += $$PWD/../../../gui/qt/QtAddons + +INCLUDEPATH += $$PWD/../QtAddons +DEPENDPATH += $$PWD/../QtAddons + +INCLUDEPATH += $$PWD/../QtImaging +DEPENDPATH += $$PWD/../QtImaging diff --git a/GUI/qt/ImagingTests/main.cpp b/GUI/qt/ImagingTests/main.cpp new file mode 100644 index 000000000..b48f94ec8 --- /dev/null +++ b/GUI/qt/ImagingTests/main.cpp @@ -0,0 +1,11 @@ +#include "mainwindow.h" +#include + +int main(int argc, char *argv[]) +{ + QApplication a(argc, argv); + MainWindow w; + w.show(); + + return a.exec(); +} diff --git a/GUI/qt/ImagingTests/mainwindow.cpp b/GUI/qt/ImagingTests/mainwindow.cpp new file mode 100644 index 000000000..213e651d6 --- /dev/null +++ b/GUI/qt/ImagingTests/mainwindow.cpp @@ -0,0 +1,23 @@ +#include "mainwindow.h" +#include "ui_mainwindow.h" + +#include + +MainWindow::MainWindow(QWidget *parent) : + QMainWindow(parent), + ui(new Ui::MainWindow) +{ + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + delete ui; +} + +void MainWindow::on_pushButton_clicked() +{ + PixelSizeDlg dlg; + + dlg.exec(); +} diff --git a/GUI/qt/ImagingTests/mainwindow.h b/GUI/qt/ImagingTests/mainwindow.h new file mode 100644 index 000000000..ed42168c7 --- /dev/null +++ b/GUI/qt/ImagingTests/mainwindow.h @@ -0,0 +1,25 @@ +#ifndef MAINWINDOW_H +#define MAINWINDOW_H + +#include + +namespace Ui { +class MainWindow; +} + +class MainWindow : public QMainWindow +{ + Q_OBJECT + +public: + explicit MainWindow(QWidget *parent = 0); + ~MainWindow(); + +private slots: + void on_pushButton_clicked(); + +private: + Ui::MainWindow *ui; +}; + +#endif // MAINWINDOW_H diff --git a/GUI/qt/ImagingTests/mainwindow.ui b/GUI/qt/ImagingTests/mainwindow.ui new file mode 100644 index 000000000..d5532a8c1 --- /dev/null +++ b/GUI/qt/ImagingTests/mainwindow.ui @@ -0,0 +1,54 @@ + + + MainWindow + + + + 0 + 0 + 400 + 300 + + + + MainWindow + + + + + + 10 + 30 + 113 + 32 + + + + Pixel size + + + + + + + 0 + 0 + 400 + 22 + + + + + + TopToolBarArea + + + false + + + + + + + + diff --git a/GUI/qt/QtAddons/uxroiwidget.ui b/GUI/qt/QtAddons/uxroiwidget.ui index 3bc266569..4defb1921 100644 --- a/GUI/qt/QtAddons/uxroiwidget.ui +++ b/GUI/qt/QtAddons/uxroiwidget.ui @@ -43,6 +43,9 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + 9999 + @@ -81,6 +84,9 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + 9999 + @@ -97,6 +103,9 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + 9999 + @@ -120,25 +129,20 @@ false - + - 20 + 10 50 60 16 - - - 9 - - (x0,y0) - + 130 @@ -147,22 +151,10 @@ 16 - - - 9 - - (x1,y1) - label_2 - label - spinY1 - spinX1 - spinX0 - spinY0 - buttonGetROI diff --git a/GUI/qt/QtImaging/QtImaging.pro b/GUI/qt/QtImaging/QtImaging.pro new file mode 100644 index 000000000..33a115658 --- /dev/null +++ b/GUI/qt/QtImaging/QtImaging.pro @@ -0,0 +1,81 @@ +#------------------------------------------------- +# +# Project created by QtCreator 2018-06-25T07:52:23 +# +#------------------------------------------------- + +QT += widgets + +QT -= gui + +TARGET = QtImaging +TEMPLATE = lib + +CONFIG += c++11 + +DEFINES += QTIMAGING_LIBRARY + +CONFIG(release, debug|release): DESTDIR = $$PWD/../../../../lib +else:CONFIG(debug, debug|release): DESTDIR = $$PWD/../../../../lib/debug + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +unix:!macx { + QMAKE_CXXFLAGS += -fopenmp -fPIC -O2 + QMAKE_LFLAGS += -lgomp + LIBS += -lgomp +} + +unix:macx { + QMAKE_MAC_SDK = macosx10.12 + QMAKE_CXXFLAGS += -fPIC -O2 + INCLUDEPATH += /opt/local/include + QMAKE_LIBDIR += /opt/local/lib +} + +win32 { + contains(QMAKE_HOST.arch, x86_64):{ + QMAKE_LFLAGS += /MACHINE:X64 + } + INCLUDEPATH += ../../../external/include . + LIBPATH += ../../../external/lib64 + QMAKE_CXXFLAGS += /openmp /O2 +} + +SOURCES += \ + qtimaging.cpp \ + pixelsizedlg.cpp + +HEADERS += \ + qtimaging.h \ + qtimaging_global.h \ + pixelsizedlg.h + +unix { + target.path = /usr/lib + INSTALLS += target +} + +FORMS += \ + pixelsizedlg.ui + +CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../lib -lkipl -lQtAddons -lReaderConfig +else:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../lib/debug -lkipl -lQtAddons -lReaderConfig + +INCLUDEPATH += $$PWD/../../../core/kipl/kipl/include +DEPENDPATH += $$PWD/../../../core/kipl/kipl/include + +INCLUDEPATH += $$PWD/../../../core/modules/ReaderConfig/ +DEPENDPATH += $$PWD/../../../core/modules/ReaderConfig/ + +INCLUDEPATH += $$PWD/../../../gui/qt/QtAddons +DEPENDPATH += $$PWD/../../../gui/qt/QtAddons diff --git a/GUI/qt/QtImaging/pixelsizedlg.cpp b/GUI/qt/QtImaging/pixelsizedlg.cpp new file mode 100644 index 000000000..090ab7cc9 --- /dev/null +++ b/GUI/qt/QtImaging/pixelsizedlg.cpp @@ -0,0 +1,129 @@ +// + +#include +#include +#include + +#include "pixelsizedlg.h" +#include "ui_pixelsizedlg.h" + +#include +#include +#include +#include + +PixelSizeDlg::PixelSizeDlg(QWidget *parent) : + QDialog(parent), + logger("PixelSizeDlg"), + ui(new Ui::PixelSizeDlg), + pixelSize(0.1f) +{ + ui->setupUi(this); + ui->roi->registerViewer(ui->viewer); +} + +PixelSizeDlg::~PixelSizeDlg() +{ + delete ui; +} + +float PixelSizeDlg::getPixelSize() +{ + return pixelSize; +} + +float PixelSizeDlg::getDistance(kipl::base::TImage &im, size_t *roi) +{ + size_t w=roi[2]-roi[0]; + size_t h=roi[3]-roi[1]; + size_t N=max(w,h); + float *profile=new float [N+1]; + std::fill_n(roi,N,0.0f); + + if (roi[2]-roi[0]radioButton_Edges->isChecked()) { + for (size_t i=1; i peaks; + kipl::math::findPeaks(profile,N,stat.E(),stat.s(),peaks); + + pixelDistance=peaks.back()-peaks.front(); + delete [] profile; + return pixelDistance; +} + + +void PixelSizeDlg::on_lineEdit_FileName_returnPressed() +{ + loadImage(ui->lineEdit_FileName->text()); +} + +void PixelSizeDlg::on_pushButton_Browse_clicked() +{ + QString fname=QFileDialog::getOpenFileName(this, + tr("Select an image to measure the pixel size"), + ui->lineEdit_FileName->text()); + ui->lineEdit_FileName->setText(fname); + + loadImage(fname); +} + +void PixelSizeDlg::on_pushButton_Analyze_clicked() +{ + size_t roi[4]; + + ui->roi->getROI(roi); + if (img.Size()==0) { + QMessageBox::warning(this,"No image","You have to load an image before you can analyse.",QMessageBox::Ok); + logger(logger.LogMessage,"No image loaded."); + + return; + } + qDebug() << "Pre get distance"; + pixelDistance=getDistance(img,roi); + qDebug() << "Post get distance"; + pixelSize=ui->doubleSpinBox_Distance->value()/pixelDistance; +// std::ostringstream msg; +// msg<<"Distance: "<doubleSpinBox_Distance->value()<<"mm/"<label_results->setText(QString::fromStdString(msg.str())); + +} + +void PixelSizeDlg::loadImage(QString fn) +{ + fname=fn.toStdString(); + kipl::strings::filenames::CheckPathSlashes(fname,false); + ImageReader reader; + + img=reader.Read(fname); + ui->viewer->set_image(img.GetDataPtr(),img.Dims()); +} diff --git a/GUI/qt/QtImaging/pixelsizedlg.h b/GUI/qt/QtImaging/pixelsizedlg.h new file mode 100644 index 000000000..b68558d4d --- /dev/null +++ b/GUI/qt/QtImaging/pixelsizedlg.h @@ -0,0 +1,45 @@ +#ifndef PIXELSIZEDLG_H +#define PIXELSIZEDLG_H + +#include +#include + +#include + +#include +#include + +namespace Ui { +class PixelSizeDlg; +} + +class QTIMAGINGSHARED_EXPORT PixelSizeDlg : public QDialog +{ + Q_OBJECT + kipl::logging::Logger logger; +public: + explicit PixelSizeDlg(QWidget *parent = 0); + ~PixelSizeDlg(); + + float getPixelSize(); + float getDistance(kipl::base::TImage &im, size_t *roi); + +private slots: + + void on_lineEdit_FileName_returnPressed(); + + void on_pushButton_Browse_clicked(); + + void on_pushButton_Analyze_clicked(); + +private: + void loadImage(QString fn); + Ui::PixelSizeDlg *ui; + + float pixelSize; + float pixelDistance; + std::string fname; + kipl::base::TImage img; +}; + +#endif // PIXELSIZEDLG_H diff --git a/GUI/qt/QtImaging/pixelsizedlg.ui b/GUI/qt/QtImaging/pixelsizedlg.ui new file mode 100644 index 000000000..404fc9a05 --- /dev/null +++ b/GUI/qt/QtImaging/pixelsizedlg.ui @@ -0,0 +1,237 @@ + + + PixelSizeDlg + + + + 0 + 0 + 610 + 521 + + + + Measure pixel size + + + + + + + + File + + + + + + + Full path to the image. + + + + + + + Browse for image to analyse + + + Browse + + + + + + + + + + + + + + 196 + 123 + + + + + + + + Image features to analyse + + + + + + The distance is measured between two lines in the marked ROI + + + Lines + + + + + + + The distance is measured between two edges in the ROI. + + + Edges + + + + + + + + + + + + Distance + + + + + + + Metric distance between two features in the image. + + + + + + + mm + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Start the analysis. + + + Analyze + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + 386 + 386 + + + + + + + + + + TextLabel + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + QtAddons::ImageViewerWidget + QWidget +
imageviewerwidget.h
+ 1 + + levelsChanged(float,float) + +
+ + QtAddons::uxROIWidget + QWidget +
uxroiwidget.h
+ 1 + + valueChanged(int,int,int,int) + +
+
+ + + + buttonBox + accepted() + PixelSizeDlg + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + PixelSizeDlg + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/GUI/qt/QtImaging/qtimaging.cpp b/GUI/qt/QtImaging/qtimaging.cpp new file mode 100644 index 000000000..bd790f297 --- /dev/null +++ b/GUI/qt/QtImaging/qtimaging.cpp @@ -0,0 +1,6 @@ +#include "qtimaging.h" + + +QtImaging::QtImaging() +{ +} diff --git a/GUI/qt/QtImaging/qtimaging.h b/GUI/qt/QtImaging/qtimaging.h new file mode 100644 index 000000000..8dcc1ee15 --- /dev/null +++ b/GUI/qt/QtImaging/qtimaging.h @@ -0,0 +1,13 @@ +#ifndef QTIMAGING_H +#define QTIMAGING_H + +#include "qtimaging_global.h" + +class QTIMAGINGSHARED_EXPORT QtImaging +{ + +public: + QtImaging(); +}; + +#endif // QTIMAGING_H diff --git a/GUI/qt/QtImaging/qtimaging_global.h b/GUI/qt/QtImaging/qtimaging_global.h new file mode 100644 index 000000000..deda902bc --- /dev/null +++ b/GUI/qt/QtImaging/qtimaging_global.h @@ -0,0 +1,12 @@ +#ifndef QTIMAGING_GLOBAL_H +#define QTIMAGING_GLOBAL_H + +#include + +#if defined(QTIMAGING_LIBRARY) +# define QTIMAGINGSHARED_EXPORT Q_DECL_EXPORT +#else +# define QTIMAGINGSHARED_EXPORT Q_DECL_IMPORT +#endif + +#endif // QTIMAGING_GLOBAL_H diff --git a/applications/CLI/muhrecCLI/muhreccli.cpp b/applications/CLI/muhrecCLI/muhreccli.cpp index 1f7190611..6924fd003 100644 --- a/applications/CLI/muhrecCLI/muhreccli.cpp +++ b/applications/CLI/muhrecCLI/muhreccli.cpp @@ -74,8 +74,8 @@ int MuhRecCLI::exec() } } // Exception handling as last resort to report unhandled faults catch (ReconException &re) { - cerr<<"An unhandled reconstructor exception occurred"< #include #include +#include #include "edgefileitemdialog.h" @@ -571,3 +572,16 @@ void NIQAMainWindow::on_widget_roi3DBalls_valueChanged(int x0, int y0, int x1, i ui->viewer_Packing->set_rectangle(ui->widget_roi3DBalls->getROI(),QColor("red"),0); } + +void NIQAMainWindow::on_pushButton_contrast_pixelSize_clicked() +{ + PixelSizeDlg dlg; + + int res=dlg.exec(); + + if (res==dlg.Accepted) { + ui->spin_contrast_pixelsize->setValue(dlg.getPixelSize()); + } + + +} diff --git a/applications/NIQualityAssessment/NIQA/niqamainwindow.h b/applications/NIQualityAssessment/NIQA/niqamainwindow.h index 31843e9b2..fe3aec26c 100644 --- a/applications/NIQualityAssessment/NIQA/niqamainwindow.h +++ b/applications/NIQualityAssessment/NIQA/niqamainwindow.h @@ -63,6 +63,8 @@ private slots: void on_check_3DBallsCrop_toggled(bool checked); + void on_pushButton_contrast_pixelSize_clicked(); + private: void showContrastBoxPlot(); void showContrastHistogram(); diff --git a/applications/NIQualityAssessment/NIQA/niqamainwindow.ui b/applications/NIQualityAssessment/NIQA/niqamainwindow.ui index 0384a56c3..376dfa7ad 100644 --- a/applications/NIQualityAssessment/NIQA/niqamainwindow.ui +++ b/applications/NIQualityAssessment/NIQA/niqamainwindow.ui @@ -18,7 +18,7 @@ - 3 + 0 @@ -46,53 +46,43 @@ - - + + - <html><head/><body><p>The pixel size is needed to define the size of the insets.</p></body></html> + <html><head/><body><p>Intensity slope and intercept are used to scale the gray levels to attenuation coefficients. If you only have gray min and max you have to calculate the slope and intercept.</p></body></html> 4 - - 0.000000000000000 - - - 0.100000000000000 + + 99999.000000000000000 - - + + - <html><head/><body><p>Intensity slope and intercept are used to scale the gray levels to attenuation coefficients. If you only have gray min and max you have to calculate the slope and intercept.</p></body></html> + <html><head/><body><p>The pixel size is needed to define the size of the insets.</p></body></html> 4 - - 9999.000000000000000 + + 0.000000000000000 - 1.000000000000000 - - - - - - - Pixel size + 0.100000000000000 - + Intensity slope - + Intensity intercept @@ -100,7 +90,7 @@ - + <html><head/><body><p>Intensity slope and intercept are used to scale the gray levels to attenuation coefficients. If you only have gray min and max you have to calculate the slope and intercept.</p></body></html> @@ -108,7 +98,17 @@ 4 - 99999.000000000000000 + 9999.000000000000000 + + + 1.000000000000000 + + + + + + + Pixel size @@ -870,6 +870,9 @@ QWidget
imageviewerwidget.h
1 + + levelsChanged(float,float) + QtAddons::ROIWidget diff --git a/applications/kiptool/deploykiptool_mac.sh b/applications/kiptool/deploykiptool_mac.sh old mode 100644 new mode 100755 diff --git a/applications/kiptool/qt/QtKipTool/QtKipTool.pro b/applications/kiptool/qt/QtKipTool/QtKipTool.pro index a920d9852..6dbbe587b 100644 --- a/applications/kiptool/qt/QtKipTool/QtKipTool.pro +++ b/applications/kiptool/qt/QtKipTool/QtKipTool.pro @@ -4,7 +4,7 @@ # #------------------------------------------------- -QT += core widgets printsupport concurrent +QT += core widgets concurrent # printsupport TARGET = QtKipTool TEMPLATE = app @@ -50,6 +50,26 @@ win32 { QMAKE_CXXFLAGS += /openmp /O2 } +unix:mac { +exists($$PWD/../../../../external/mac/lib/*NeXus*) { + + message("-lNeXus exists") + DEFINES *= HAVE_NEXUS + + INCLUDEPATH += $$PWD/../../../../external/mac/include/ $$PWD/../../../../external/mac/include/nexus $$PWD/../../../../external/mac/include/hdf5 + DEPENDPATH += $$PWD/../../../../external/mac/include/ $$PWD/../../../../external/mac/include/nexus $$PWD/../../../../external/mac/include/hdf5 + QMAKE_LIBDIR += $$PWD/../../../../external/mac/lib/ + + LIBS += -lNeXus.1.0.0 -lNeXusCPP.1.0.0 + + +} +else { +message("-lNeXus does not exist $$HEADERS") +} + +} + ICON = kip_icon.icns SOURCES += ../../src/main.cpp\ diff --git a/applications/muhrec3/Resources/defaults_linux.xml b/applications/muhrec/Resources/defaults_linux.xml similarity index 100% rename from applications/muhrec3/Resources/defaults_linux.xml rename to applications/muhrec/Resources/defaults_linux.xml diff --git a/applications/muhrec3/Resources/defaults_mac.xml b/applications/muhrec/Resources/defaults_mac.xml similarity index 100% rename from applications/muhrec3/Resources/defaults_mac.xml rename to applications/muhrec/Resources/defaults_mac.xml diff --git a/applications/muhrec3/Resources/defaults_windows.xml b/applications/muhrec/Resources/defaults_windows.xml similarity index 100% rename from applications/muhrec3/Resources/defaults_windows.xml rename to applications/muhrec/Resources/defaults_windows.xml diff --git a/applications/muhrec3/Resources/muhrec3.icns b/applications/muhrec/Resources/muhrec3.icns similarity index 100% rename from applications/muhrec3/Resources/muhrec3.icns rename to applications/muhrec/Resources/muhrec3.icns diff --git a/applications/muhrec3/clean-all.sh b/applications/muhrec/clean-all.sh similarity index 100% rename from applications/muhrec3/clean-all.sh rename to applications/muhrec/clean-all.sh diff --git a/applications/muhrec3/copy_dylibs.sh b/applications/muhrec/copy_dylibs.sh similarity index 100% rename from applications/muhrec3/copy_dylibs.sh rename to applications/muhrec/copy_dylibs.sh diff --git a/applications/muhrec3/deploymuhrec3_mac.sh b/applications/muhrec/deploymuhrec_mac.sh similarity index 92% rename from applications/muhrec3/deploymuhrec3_mac.sh rename to applications/muhrec/deploymuhrec_mac.sh index 69c6f485a..d9e329a58 100755 --- a/applications/muhrec3/deploymuhrec3_mac.sh +++ b/applications/muhrec/deploymuhrec_mac.sh @@ -1,13 +1,13 @@ DIRECTORY=~/Applications QTPATH=$QTBINPATH/.. -DEST="$DIRECTORY/muhrec3.app" +DEST="$DIRECTORY/MuhRec.app" REPOSPATH=$WORKSPACE if [ ! -d "$DIRECTORY" ]; then mkdir $DIRECTORY fi -cp -r $REPOSPATH/Applications/muhrec3.app $DIRECTORY +cp -r $REPOSPATH/Applications/MuhRec.app $DIRECTORY pushd . CPCMD="cp" @@ -33,11 +33,6 @@ fi `$CPCMD $REPOSPATH/lib/libInspectorModules.1.0.0.dylib $DEST/Contents/Frameworks` `$CPCMD $REPOSPATH/lib/libFDKBackProjectors.1.0.0.dylib $DEST/Contents/Frameworks` -# if [ ! -d "./Resources" ]; then -# mkdir ./Resources -# fi -# `$CPCMD $REPOSPATH/tomography/trunk/src/muhrec3/resources/muh_icon.icns $DEST/Contents/Resources` - rm -f ./MacOS/*.dylib cd Frameworks @@ -54,7 +49,7 @@ cd .. if [ ! -d "./Resources" ]; then mkdir ./Resources fi -cp ~/repos/tomography/trunk/src/muhrec3/resources/* ./Resources +cp ~/repos/tomography/trunk/src/muhrec/resources/* ./Resources sed -i.bak s+com.yourcompany+ch.imagingscience+g $DEST/Contents/Info.plist echo "copy plugins" @@ -95,13 +90,13 @@ echo "Do deploy..." ./macdeployqt $DEST #-dmg cd $DEST/Contents/MacOS -# muhrec3 -install_name_tool -change libkipl.1.dylib @executable_path/../Frameworks/libkipl.1.dylib muhrec3 -install_name_tool -change libModuleConfig.1.dylib @executable_path/../Frameworks/libModuleConfig.1.dylib muhrec3 -install_name_tool -change libQtAddons.1.dylib @executable_path/../Frameworks/libQtAddons.1.dylib muhrec3 -install_name_tool -change libQtModuleConfigure.1.dylib @executable_path/../Frameworks/libQtModuleConfigure.1.dylib muhrec3 -install_name_tool -change libReconFramework.1.dylib @executable_path/../Frameworks/libReconFramework.1.dylib muhrec3 -install_name_tool -change libImagingAlgorithms.1.dylib @executable_path/../Frameworks/libImagingAlgorithms.1.dylib muhrec3 +# MuhRec +install_name_tool -change libkipl.1.dylib @executable_path/../Frameworks/libkipl.1.dylib MuhRec +install_name_tool -change libModuleConfig.1.dylib @executable_path/../Frameworks/libModuleConfig.1.dylib MuhRec +install_name_tool -change libQtAddons.1.dylib @executable_path/../Frameworks/libQtAddons.1.dylib MuhRec +install_name_tool -change libQtModuleConfigure.1.dylib @executable_path/../Frameworks/libQtModuleConfigure.1.dylib MuhRec +install_name_tool -change libReconFramework.1.dylib @executable_path/../Frameworks/libReconFramework.1.dylib MuhRec +install_name_tool -change libImagingAlgorithms.1.dylib @executable_path/../Frameworks/libImagingAlgorithms.1.dylib MuhRec cd ../Frameworks # ModuleConfig diff --git a/applications/muhrec3/deploymuhrec3_mac_NeXus.sh b/applications/muhrec/deploymuhrec_mac_NeXus.sh similarity index 93% rename from applications/muhrec3/deploymuhrec3_mac_NeXus.sh rename to applications/muhrec/deploymuhrec_mac_NeXus.sh index 0a44f8f23..6a8837815 100755 --- a/applications/muhrec3/deploymuhrec3_mac_NeXus.sh +++ b/applications/muhrec/deploymuhrec_mac_NeXus.sh @@ -1,9 +1,7 @@ DIRECTORY=~/Applications -#QTPATH=$QT_HOME QTPATH=/Applications/QT/5.9.4/clang_64 -DEST="$DIRECTORY/muhrec3.app" -#REPOSPATH=$WORKSPACE +DEST="$DIRECTORY/MuhRec.app" REPOSPATH=~/git if [ ! -d "$DIRECTORY" ]; then @@ -15,7 +13,7 @@ echo $QTPATH echo $DEST echo $REPOSPATH -cp -r $REPOSPATH/Applications/muhrec3.app $DIRECTORY +cp -r $REPOSPATH/Applications/MuhRec.app $DIRECTORY pushd . CPCMD="cp" @@ -52,7 +50,7 @@ fi # if [ ! -d "./Resources" ]; then # mkdir ./Resources # fi -# `$CPCMD $REPOSPATH/tomography/trunk/src/muhrec3/resources/muh_icon.icns $DEST/Contents/Resources` +# `$CPCMD $REPOSPATH/tomography/trunk/src/MuhRec/resources/muh_icon.icns $DEST/Contents/Resources` rm -f ./MacOS/*.dylib @@ -72,8 +70,8 @@ if [ ! -d "./Resources" ]; then mkdir ./Resources fi -#cp ~/repos/tomography/trunk/src/muhrec3/resources/* ./Resources #this must be mistaken -cp $REPOSPATH/imagingsuite/applications/muhrec3/Resources/* ./Resources +#cp ~/repos/tomography/trunk/src/MuhRec/resources/* ./Resources #this must be mistaken +cp $REPOSPATH/imagingsuite/applications/muhrec/Resources/* ./Resources sed -i.bak s+com.yourcompany+ch.imagingscience+g $DEST/Contents/Info.plist echo "copy plugins" @@ -114,14 +112,14 @@ echo "Do deploy..." ./macdeployqt $DEST #-dmg cd $DEST/Contents/MacOS -# muhrec3 -install_name_tool -change libkipl.1.dylib @executable_path/../Frameworks/libkipl.1.dylib muhrec3 -install_name_tool -change libModuleConfig.1.dylib @executable_path/../Frameworks/libModuleConfig.1.dylib muhrec3 -install_name_tool -change libQtAddons.1.dylib @executable_path/../Frameworks/libQtAddons.1.dylib muhrec3 -install_name_tool -change libQtModuleConfigure.1.dylib @executable_path/../Frameworks/libQtModuleConfigure.1.dylib muhrec3 -install_name_tool -change libReconFramework.1.dylib @executable_path/../Frameworks/libReconFramework.1.dylib muhrec3 -install_name_tool -change libImagingAlgorithms.1.dylib @executable_path/../Frameworks/libImagingAlgorithms.1.dylib muhrec3 -install_name_tool -change libImagingAlgorithms.1.dylib @executable_path/../Frameworks/libImagingAlgorithms.1.dylib muhrec3 +# MuhRec +install_name_tool -change libkipl.1.dylib @executable_path/../Frameworks/libkipl.1.dylib MuhRec +install_name_tool -change libModuleConfig.1.dylib @executable_path/../Frameworks/libModuleConfig.1.dylib MuhRec +install_name_tool -change libQtAddons.1.dylib @executable_path/../Frameworks/libQtAddons.1.dylib MuhRec +install_name_tool -change libQtModuleConfigure.1.dylib @executable_path/../Frameworks/libQtModuleConfigure.1.dylib MuhRec +install_name_tool -change libReconFramework.1.dylib @executable_path/../Frameworks/libReconFramework.1.dylib MuhRec +install_name_tool -change libImagingAlgorithms.1.dylib @executable_path/../Frameworks/libImagingAlgorithms.1.dylib MuhRec +install_name_tool -change libImagingAlgorithms.1.dylib @executable_path/../Frameworks/libImagingAlgorithms.1.dylib MuhRec cd ../Frameworks diff --git a/applications/muhrec3/deploymuhrec3_mac_debug.sh b/applications/muhrec/deploymuhrec_mac_debug.sh similarity index 94% rename from applications/muhrec3/deploymuhrec3_mac_debug.sh rename to applications/muhrec/deploymuhrec_mac_debug.sh index 5b1ccb80a..a7d50d3d7 100755 --- a/applications/muhrec3/deploymuhrec3_mac_debug.sh +++ b/applications/muhrec/deploymuhrec_mac_debug.sh @@ -1,10 +1,7 @@ DIRECTORY=~/Applications -#QTPATH=$QTPATH -#QTPATH=/Users/carminati/QT/5.9.4/clang_64 -DEST="$DIRECTORY/muhrec3.app" +DEST="$DIRECTORY/MuhRec.app" REPOSPATH=$WORKSPACE -#REPOSPATH=/Users/carminati/git if [ ! -d "$DIRECTORY" ]; then mkdir $DIRECTORY @@ -15,7 +12,7 @@ echo $QTPATH echo $DEST echo $REPOSPATH -cp -r $REPOSPATH/Applications/muhrec3.app $DIRECTORY +cp -r $REPOSPATH/Applications/MuhRec.app $DIRECTORY pushd . CPCMD="cp" @@ -52,12 +49,6 @@ if [ -e "$REPOSPATH/Applications/muhrecCLI" ]; then `$CPCMD $REPOSPATH/Applications/muhrecCLI $DEST/Contents/MacOS` fi - -# if [ ! -d "./Resources" ]; then -# mkdir ./Resources -# fi -# `$CPCMD $REPOSPATH/tomography/trunk/src/muhrec3/resources/muh_icon.icns $DEST/Contents/Resources` - rm -f ./MacOS/*.dylib cd Frameworks @@ -76,8 +67,7 @@ if [ ! -d "./Resources" ]; then mkdir ./Resources fi -#cp ~/repos/tomography/trunk/src/muhrec3/resources/* ./Resources #this must be mistaken -cp $REPOSPATH/imagingsuite/applications/muhrec3/Resources/* ./Resources +cp $REPOSPATH/imagingsuite/applications/muhrec/Resources/* ./Resources sed -i.bak s+com.yourcompany+ch.imagingscience+g $DEST/Contents/Info.plist echo "copy plugins" @@ -118,16 +108,16 @@ echo "Do deploy..." ./macdeployqt $DEST #-dmg cd $DEST/Contents/MacOS -# muhrec3 -install_name_tool -change libkipl.1.dylib @executable_path/../Frameworks/libkipl.1.dylib muhrec3 -install_name_tool -change libModuleConfig.1.dylib @executable_path/../Frameworks/libModuleConfig.1.dylib muhrec3 -install_name_tool -change libQtAddons.1.dylib @executable_path/../Frameworks/libQtAddons.1.dylib muhrec3 -install_name_tool -change libQtModuleConfigure.1.dylib @executable_path/../Frameworks/libQtModuleConfigure.1.dylib muhrec3 -install_name_tool -change libReconFramework.1.dylib @executable_path/../Frameworks/libReconFramework.1.dylib muhrec3 -install_name_tool -change libImagingAlgorithms.1.dylib @executable_path/../Frameworks/libImagingAlgorithms.1.dylib muhrec3 -install_name_tool -change libImagingAlgorithms.1.dylib @executable_path/../Frameworks/libImagingAlgorithms.1.dylib muhrec3 -install_name_tool -change libNeXus.1.dylib @executable_path/../Frameworks/libNeXus.1.dylib muhrec3 -install_name_tool -change libNeXusCPP.1.dylib @executable_path/../Frameworks/libNeXusCPP.1.dylib muhrec3 +# muhrec +install_name_tool -change libkipl.1.dylib @executable_path/../Frameworks/libkipl.1.dylib MuhRec +install_name_tool -change libModuleConfig.1.dylib @executable_path/../Frameworks/libModuleConfig.1.dylib MuhRec +install_name_tool -change libQtAddons.1.dylib @executable_path/../Frameworks/libQtAddons.1.dylib MuhRec +install_name_tool -change libQtModuleConfigure.1.dylib @executable_path/../Frameworks/libQtModuleConfigure.1.dylib MuhRec +install_name_tool -change libReconFramework.1.dylib @executable_path/../Frameworks/libReconFramework.1.dylib MuhRec +install_name_tool -change libImagingAlgorithms.1.dylib @executable_path/../Frameworks/libImagingAlgorithms.1.dylib MuhRec +install_name_tool -change libImagingAlgorithms.1.dylib @executable_path/../Frameworks/libImagingAlgorithms.1.dylib MuhRec +install_name_tool -change libNeXus.1.dylib @executable_path/../Frameworks/libNeXus.1.dylib MuhRec +install_name_tool -change libNeXusCPP.1.dylib @executable_path/../Frameworks/libNeXusCPP.1.dylib MuhRec # muhrecCLI if [ -e "muhrecCLI" ]; then diff --git a/applications/muhrec3/deploymuhrec3_ubuntu.sh b/applications/muhrec/deploymuhrec_ubuntu.sh similarity index 85% rename from applications/muhrec3/deploymuhrec3_ubuntu.sh rename to applications/muhrec/deploymuhrec_ubuntu.sh index 82c097866..09d93fc2e 100755 --- a/applications/muhrec3/deploymuhrec3_ubuntu.sh +++ b/applications/muhrec/deploymuhrec_ubuntu.sh @@ -2,7 +2,7 @@ CPCMD="cp " REPOSPATH=$WORKSPACE -DEST="$WORKSPACE/deploy/muhrec3" +DEST="$WORKSPACE/deploy/muhrec" mkdir --parent $DEST mkdir --parent $DEST/bin @@ -55,12 +55,12 @@ done cd $DEST/bin -`$CPCMD $REPOSPATH/Applications/muhrec3 .` +`$CPCMD $REPOSPATH/Applications/muhrec .` cd .. -`$CPCMD $REPOSPATH/imagingsuite/applications/muhrec3/scripts/muhrec3 .` -chmod +x muhrec3 +`$CPCMD $REPOSPATH/imagingsuite/applications/muhrec/scripts/muhrec .` +chmod +x muhrec -cp $REPOSPATH/imagingsuite/applications/muhrec3/src/resources/*.xml resources +cp $REPOSPATH/imagingsuite/applications/muhrec/src/resources/*.xml resources popd diff --git a/applications/muhrec3/deploymuhrec3_ubuntu_withQT.sh b/applications/muhrec/deploymuhrec_ubuntu_withQT.sh similarity index 81% rename from applications/muhrec3/deploymuhrec3_ubuntu_withQT.sh rename to applications/muhrec/deploymuhrec_ubuntu_withQT.sh index 2c585c0ab..411676621 100755 --- a/applications/muhrec3/deploymuhrec3_ubuntu_withQT.sh +++ b/applications/muhrec/deploymuhrec_ubuntu_withQT.sh @@ -1,12 +1,10 @@ -#CPCMD="ln -s " CPCMD="cp " REPOSPATH="/home/`whoami`/git" -#QT_PATH=/home/`whoami`/Qt/5.8/gcc_64 QT_PATH="$QTPATH" -DEST="$HOME/muhrec3" +DEST="$HOME/muhrec" mkdir --parent $DEST mkdir --parent $DEST/bin mkdir --parent $DEST/bin/platforms @@ -34,9 +32,9 @@ rm -f *.1.0.0.dylib `$CPCMD $REPOSPATH/lib/libStdPreprocModules.so.1.0.0 .` `$CPCMD $REPOSPATH/lib/libStdPreprocModulesGUI.so.1.0.0 .` -`$CPCMD $REPOSPATH/lib/libUnpublPreProcessing.so.1.0.0 .` -`$CPCMD $REPOSPATH/lib/libUnpublPreProcessingGUI.so.1.0.0 .` -`$CPCMD $REPOSPATH/lib/libUnpublishedImagingAlgorithms.so.1.0.0 .` +#`$CPCMD $REPOSPATH/lib/libUnpublPreProcessing.so.1.0.0 .` +#`$CPCMD $REPOSPATH/lib/libUnpublPreProcessingGUI.so.1.0.0 .` +#`$CPCMD $REPOSPATH/lib/libUnpublishedImagingAlgorithms.so.1.0.0 .` `$CPCMD $REPOSPATH/lib/libInspectorModules.so.1.0.0 .` `$CPCMD $REPOSPATH/lib/libInspectorModulesGUI.so.1.0.0 .` @@ -94,13 +92,13 @@ cd $DEST/bin/platforms cd $DEST/bin -`$CPCMD $REPOSPATH/Applications/muhrec3 .` +`$CPCMD $REPOSPATH/Applications/MuhRec .` cd .. -`$CPCMD $REPOSPATH/imagingsuite/applications/muhrec3/scripts/muhrec3 .` -chmod +x muhrec3 +`$CPCMD $REPOSPATH/imagingsuite/applications/muhrec/scripts/muhrec .` +chmod +x muhrec -cp $REPOSPATH/imagingsuite/applications/muhrec3/src/resources/*.xml resources +cp $REPOSPATH/imagingsuite/applications/muhrec/src/resources/*.xml resources popd diff --git a/applications/muhrec3/copy_dlls.bat b/applications/muhrec/deploymuhrec_win.bat similarity index 81% rename from applications/muhrec3/copy_dlls.bat rename to applications/muhrec/deploymuhrec_win.bat index 749387c6a..1db4531cc 100644 --- a/applications/muhrec3/copy_dlls.bat +++ b/applications/muhrec/deploymuhrec_win.bat @@ -21,9 +21,9 @@ copy %REPOS%\lib\StdPreprocModulesGUI.dll . copy %REPOS%\lib\InspectorModulesGUI.dll . copy %REPOS%\lib\InspectorModules.dll . copy %REPOS%\lib\FDKBackProjectors.dll . -copy %REPOS%\lib\UnpublishedImagingAlgorithms.dll . -copy %REPOS%\lib\UnpublPreProcessing.dll . -copy %REPOS%\lib\UnpublPreProcessingGUI.dll . +#copy %REPOS%\lib\UnpublishedImagingAlgorithms.dll . +#copy %REPOS%\lib\UnpublPreProcessing.dll . +#copy %REPOS%\lib\UnpublPreProcessingGUI.dll . copy %REPOS%\lib\ReaderConfig.dll . copy %REPOS%\lib\ReaderGUI.dll . #copy %REPOS%\lib\ReconAlgorithms.dll . @@ -43,14 +43,14 @@ copy %REPOS%\imagingsuite\external\lib64\hdf5\hdf5_cpp.dll . copy %REPOS%\imagingsuite\external\lib64\hdf5\zlib.dll . copy %REPOS%\imagingsuite\external\lib64\hdf5\szip.dll . -copy %REPOS%\Applications\muhrec3.exe . -copy %REPOS%\Applications\muhrecCLI.exe . +copy %REPOS%\Applications\MuhRec.exe . +copy %REPOS%\Applications\MuhRecCLI.exe . -copy %REPOS%\imagingsuite\applications\muhrec3\src\resources resources +copy %REPOS%\imagingsuite\applications\muhrec\Resources resources cd %QTBINPATH% -windeployqt %DEST%\muhrec3.exe +windeployqt %DEST%\muhrec.exe windeployqt %DEST%\muhrecCLI.exe copy Qt5PrintSupport.dll %DEST% diff --git a/applications/muhrec/deploymuhrec_win_nofolder.bat b/applications/muhrec/deploymuhrec_win_nofolder.bat new file mode 100644 index 000000000..491a3c83c --- /dev/null +++ b/applications/muhrec/deploymuhrec_win_nofolder.bat @@ -0,0 +1,55 @@ +@echo ----------------- Deploy copy -------------- +set REPOS=C:\%HOMEPATH%\git +set DEST=C:\%HOMEPATH%\imagingscience + +if not exist %DEST% mkdir %DEST% + +pushd . +cd %DEST% +mkdir resources + +copy %REPOS%\lib\ImagingAlgorithms.dll . +copy %REPOS%\lib\ModuleConfig.dll . +copy %REPOS%\lib\QtAddons.dll . +copy %REPOS%\lib\QtModuleConfigure.dll . +copy %REPOS%\lib\kipl.dll . +copy %REPOS%\lib\ReconFramework.dll . +copy %REPOS%\lib\StdBackProjectors.dll . +copy %REPOS%\lib\StdPreprocModules.dll . +copy %REPOS%\lib\StdPreprocModulesGUI.dll . +copy %REPOS%\lib\InspectorModulesGUI.dll . +copy %REPOS%\lib\InspectorModules.dll . +copy %REPOS%\lib\FDKBackProjectors.dll . +copy %REPOS%\lib\UnpublishedImagingAlgorithms.dll . +copy %REPOS%\lib\UnpublPreProcessing.dll . +copy %REPOS%\lib\UnpublPreProcessingGUI.dll . + +copy %REPOS%\external\lib64\libtiff.dll . +copy %REPOS%\external\lib64\libjpeg-62.dll . +copy %REPOS%\external\lib64\zlib1.dll . +copy %REPOS%\external\lib64\libfftw3-3.dll . +copy %REPOS%\external\lib64\libfftw3f-3.dll . +copy %REPOS%\external\lib64\libxml2-2.dll . +copy %REPOS%\external\lib64\libiconv.dll . +copy %REPOS%\external\lib64\cfitsio.dll . +copy %REPOS%\external\lib64\nexus\NeXus.dll . +copy %REPOS%\external\lib64\nexus\NeXusCPP.dll . +copy %REPOS%\external\lib64\hdf5\hdf5.dll . +copy %REPOS%\external\lib64\hdf5\hdf5_cpp.dll . +copy %REPOS%\external\lib64\hdf5\zlib.dll . +copy %REPOS%\external\lib64\hdf5\szip.dll . + + +copy %REPOS%\Applications\muhrec3.exe . + +copy %REPOS%\applications\muhrec3\src\resources resources + +#rem cd C:\Qt\5.8\msvc2015_64\bin +#cd C:\Qt59\5.9.3\msvc2015_64\bin +#cd C:\Qt\5.8\msvc2015_64\bin +cd C:\Qt\5.9\msvc2015_64\bin + +windeployqt %DEST%\muhrec3.exe +copy Qt5PrintSupport.dll %DEST% + +popd \ No newline at end of file diff --git a/applications/muhrec3/doc/BugsAndFeaturesToImprove.docx b/applications/muhrec/doc/BugsAndFeaturesToImprove.docx similarity index 100% rename from applications/muhrec3/doc/BugsAndFeaturesToImprove.docx rename to applications/muhrec/doc/BugsAndFeaturesToImprove.docx diff --git a/applications/muhrec3/doc/MuhRec 3_008.png b/applications/muhrec/doc/MuhRec 3_008.png similarity index 100% rename from applications/muhrec3/doc/MuhRec 3_008.png rename to applications/muhrec/doc/MuhRec 3_008.png diff --git a/applications/muhrec3/doc/distribution/howto_mac.docx b/applications/muhrec/doc/distribution/howto_mac.docx similarity index 100% rename from applications/muhrec3/doc/distribution/howto_mac.docx rename to applications/muhrec/doc/distribution/howto_mac.docx diff --git a/applications/muhrec3/doc/icon/build_icon.sh b/applications/muhrec/doc/icon/build_icon.sh similarity index 100% rename from applications/muhrec3/doc/icon/build_icon.sh rename to applications/muhrec/doc/icon/build_icon.sh diff --git a/applications/muhrec3/doc/icon/build_icon_win.sh b/applications/muhrec/doc/icon/build_icon_win.sh similarity index 100% rename from applications/muhrec3/doc/icon/build_icon_win.sh rename to applications/muhrec/doc/icon/build_icon_win.sh diff --git a/applications/muhrec3/doc/icon/muh4_icon.ico b/applications/muhrec/doc/icon/muh4_icon.ico similarity index 100% rename from applications/muhrec3/doc/icon/muh4_icon.ico rename to applications/muhrec/doc/icon/muh4_icon.ico diff --git a/applications/muhrec3/doc/icon/muh4_icon.png b/applications/muhrec/doc/icon/muh4_icon.png similarity index 100% rename from applications/muhrec3/doc/icon/muh4_icon.png rename to applications/muhrec/doc/icon/muh4_icon.png diff --git a/applications/muhrec3/doc/icon/muh4_icon.svg b/applications/muhrec/doc/icon/muh4_icon.svg similarity index 100% rename from applications/muhrec3/doc/icon/muh4_icon.svg rename to applications/muhrec/doc/icon/muh4_icon.svg diff --git a/applications/muhrec3/doc/icon/muh4_icon_256.png b/applications/muhrec/doc/icon/muh4_icon_256.png similarity index 100% rename from applications/muhrec3/doc/icon/muh4_icon_256.png rename to applications/muhrec/doc/icon/muh4_icon_256.png diff --git a/applications/muhrec3/doc/icon/muh_icon.png b/applications/muhrec/doc/icon/muh_icon.png similarity index 100% rename from applications/muhrec3/doc/icon/muh_icon.png rename to applications/muhrec/doc/icon/muh_icon.png diff --git a/applications/muhrec3/doc/icon/muh_icon.svg b/applications/muhrec/doc/icon/muh_icon.svg similarity index 100% rename from applications/muhrec3/doc/icon/muh_icon.svg rename to applications/muhrec/doc/icon/muh_icon.svg diff --git a/applications/muhrec3/doc/moduleapi/figures/KiplComponents.pdf b/applications/muhrec/doc/moduleapi/figures/KiplComponents.pdf similarity index 100% rename from applications/muhrec3/doc/moduleapi/figures/KiplComponents.pdf rename to applications/muhrec/doc/moduleapi/figures/KiplComponents.pdf diff --git a/applications/muhrec3/doc/moduleapi/figures/KiplComponents.svg b/applications/muhrec/doc/moduleapi/figures/KiplComponents.svg similarity index 100% rename from applications/muhrec3/doc/moduleapi/figures/KiplComponents.svg rename to applications/muhrec/doc/moduleapi/figures/KiplComponents.svg diff --git a/applications/muhrec3/doc/moduleapi/moduleapi_doc.tex b/applications/muhrec/doc/moduleapi/moduleapi_doc.tex similarity index 100% rename from applications/muhrec3/doc/moduleapi/moduleapi_doc.tex rename to applications/muhrec/doc/moduleapi/moduleapi_doc.tex diff --git a/applications/muhrec3/doc/muhrec_stored_config.png b/applications/muhrec/doc/muhrec_stored_config.png similarity index 100% rename from applications/muhrec3/doc/muhrec_stored_config.png rename to applications/muhrec/doc/muhrec_stored_config.png diff --git a/applications/muhrec3/doc/releases/ReleaseNote.txt b/applications/muhrec/doc/releases/ReleaseNote.txt similarity index 100% rename from applications/muhrec3/doc/releases/ReleaseNote.txt rename to applications/muhrec/doc/releases/ReleaseNote.txt diff --git a/applications/muhrec3/doc/releases/ReleaseTest/ReleaseCheckList.tex b/applications/muhrec/doc/releases/ReleaseTest/ReleaseCheckList.tex similarity index 100% rename from applications/muhrec3/doc/releases/ReleaseTest/ReleaseCheckList.tex rename to applications/muhrec/doc/releases/ReleaseTest/ReleaseCheckList.tex diff --git a/applications/muhrec3/doc/releases/getreposlogs.sh b/applications/muhrec/doc/releases/getreposlogs.sh similarity index 100% rename from applications/muhrec3/doc/releases/getreposlogs.sh rename to applications/muhrec/doc/releases/getreposlogs.sh diff --git a/applications/muhrec3/doc/usermanual/figures/ConfISS.png b/applications/muhrec/doc/usermanual/figures/ConfISS.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/ConfISS.png rename to applications/muhrec/doc/usermanual/figures/ConfISS.png diff --git a/applications/muhrec3/doc/usermanual/figures/ConfMedMixRing.png b/applications/muhrec/doc/usermanual/figures/ConfMedMixRing.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/ConfMedMixRing.png rename to applications/muhrec/doc/usermanual/figures/ConfMedMixRing.png diff --git a/applications/muhrec3/doc/usermanual/figures/ConfPolyCorr.png b/applications/muhrec/doc/usermanual/figures/ConfPolyCorr.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/ConfPolyCorr.png rename to applications/muhrec/doc/usermanual/figures/ConfPolyCorr.png diff --git a/applications/muhrec3/doc/usermanual/figures/ConfProjFilter.png b/applications/muhrec/doc/usermanual/figures/ConfProjFilter.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/ConfProjFilter.png rename to applications/muhrec/doc/usermanual/figures/ConfProjFilter.png diff --git a/applications/muhrec3/doc/usermanual/figures/ConfSpotClean2.png b/applications/muhrec/doc/usermanual/figures/ConfSpotClean2.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/ConfSpotClean2.png rename to applications/muhrec/doc/usermanual/figures/ConfSpotClean2.png diff --git a/applications/muhrec3/doc/usermanual/figures/ConfigLogNorm.png b/applications/muhrec/doc/usermanual/figures/ConfigLogNorm.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/ConfigLogNorm.png rename to applications/muhrec/doc/usermanual/figures/ConfigLogNorm.png diff --git a/applications/muhrec3/doc/usermanual/figures/GeometryListDlg.png b/applications/muhrec/doc/usermanual/figures/GeometryListDlg.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/GeometryListDlg.png rename to applications/muhrec/doc/usermanual/figures/GeometryListDlg.png diff --git a/applications/muhrec3/doc/usermanual/figures/MatrixTab.png b/applications/muhrec/doc/usermanual/figures/MatrixTab.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/MatrixTab.png rename to applications/muhrec/doc/usermanual/figures/MatrixTab.png diff --git a/applications/muhrec3/doc/usermanual/figures/ProcessingTab.png b/applications/muhrec/doc/usermanual/figures/ProcessingTab.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/ProcessingTab.png rename to applications/muhrec/doc/usermanual/figures/ProcessingTab.png diff --git a/applications/muhrec3/doc/usermanual/figures/ProjectInfoTab.png b/applications/muhrec/doc/usermanual/figures/ProjectInfoTab.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/ProjectInfoTab.png rename to applications/muhrec/doc/usermanual/figures/ProjectInfoTab.png diff --git a/applications/muhrec3/doc/usermanual/figures/ProjectionGeometry.png b/applications/muhrec/doc/usermanual/figures/ProjectionGeometry.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/ProjectionGeometry.png rename to applications/muhrec/doc/usermanual/figures/ProjectionGeometry.png diff --git a/applications/muhrec3/doc/usermanual/figures/SaveProjectionsDlg.png b/applications/muhrec/doc/usermanual/figures/SaveProjectionsDlg.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/SaveProjectionsDlg.png rename to applications/muhrec/doc/usermanual/figures/SaveProjectionsDlg.png diff --git a/applications/muhrec3/doc/usermanual/figures/WaveletRingCleanDlg.png b/applications/muhrec/doc/usermanual/figures/WaveletRingCleanDlg.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/WaveletRingCleanDlg.png rename to applications/muhrec/doc/usermanual/figures/WaveletRingCleanDlg.png diff --git a/applications/muhrec3/doc/usermanual/figures/adaptive_diff.png b/applications/muhrec/doc/usermanual/figures/adaptive_diff.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/adaptive_diff.png rename to applications/muhrec/doc/usermanual/figures/adaptive_diff.png diff --git a/applications/muhrec3/doc/usermanual/figures/adaptive_filtered.png b/applications/muhrec/doc/usermanual/figures/adaptive_filtered.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/adaptive_filtered.png rename to applications/muhrec/doc/usermanual/figures/adaptive_filtered.png diff --git a/applications/muhrec3/doc/usermanual/figures/adaptive_raw.png b/applications/muhrec/doc/usermanual/figures/adaptive_raw.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/adaptive_raw.png rename to applications/muhrec/doc/usermanual/figures/adaptive_raw.png diff --git a/applications/muhrec3/doc/usermanual/figures/axis_tilt.pdf b/applications/muhrec/doc/usermanual/figures/axis_tilt.pdf similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/axis_tilt.pdf rename to applications/muhrec/doc/usermanual/figures/axis_tilt.pdf diff --git a/applications/muhrec3/doc/usermanual/figures/axis_tilt.svg b/applications/muhrec/doc/usermanual/figures/axis_tilt.svg similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/axis_tilt.svg rename to applications/muhrec/doc/usermanual/figures/axis_tilt.svg diff --git a/applications/muhrec3/doc/usermanual/figures/lineartifact_clean.png b/applications/muhrec/doc/usermanual/figures/lineartifact_clean.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/lineartifact_clean.png rename to applications/muhrec/doc/usermanual/figures/lineartifact_clean.png diff --git a/applications/muhrec3/doc/usermanual/figures/lineartifact_raw.png b/applications/muhrec/doc/usermanual/figures/lineartifact_raw.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/lineartifact_raw.png rename to applications/muhrec/doc/usermanual/figures/lineartifact_raw.png diff --git a/applications/muhrec3/doc/usermanual/figures/local_raw.png b/applications/muhrec/doc/usermanual/figures/local_raw.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/local_raw.png rename to applications/muhrec/doc/usermanual/figures/local_raw.png diff --git a/applications/muhrec3/doc/usermanual/figures/local_tap.png b/applications/muhrec/doc/usermanual/figures/local_tap.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/local_tap.png rename to applications/muhrec/doc/usermanual/figures/local_tap.png diff --git a/applications/muhrec3/doc/usermanual/figures/muh_icon.pdf b/applications/muhrec/doc/usermanual/figures/muh_icon.pdf similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/muh_icon.pdf rename to applications/muhrec/doc/usermanual/figures/muh_icon.pdf diff --git a/applications/muhrec3/doc/usermanual/figures/muh_icon.png b/applications/muhrec/doc/usermanual/figures/muh_icon.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/muh_icon.png rename to applications/muhrec/doc/usermanual/figures/muh_icon.png diff --git a/applications/muhrec3/doc/usermanual/figures/muh_icon.svg b/applications/muhrec/doc/usermanual/figures/muh_icon.svg similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/muh_icon.svg rename to applications/muhrec/doc/usermanual/figures/muh_icon.svg diff --git a/applications/muhrec3/doc/usermanual/figures/muhrec3.icns b/applications/muhrec/doc/usermanual/figures/muhrec3.icns similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/muhrec3.icns rename to applications/muhrec/doc/usermanual/figures/muhrec3.icns diff --git a/applications/muhrec3/doc/usermanual/figures/translated_center.pdf b/applications/muhrec/doc/usermanual/figures/translated_center.pdf similarity index 100% rename from applications/muhrec3/doc/usermanual/figures/translated_center.pdf rename to applications/muhrec/doc/usermanual/figures/translated_center.pdf diff --git a/applications/muhrec3/doc/usermanual/figures3/ConfISS.png b/applications/muhrec/doc/usermanual/figures3/ConfISS.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/ConfISS.png rename to applications/muhrec/doc/usermanual/figures3/ConfISS.png diff --git a/applications/muhrec3/doc/usermanual/figures3/ConfMedMixRing.png b/applications/muhrec/doc/usermanual/figures3/ConfMedMixRing.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/ConfMedMixRing.png rename to applications/muhrec/doc/usermanual/figures3/ConfMedMixRing.png diff --git a/applications/muhrec3/doc/usermanual/figures3/ConfPolyCorr.png b/applications/muhrec/doc/usermanual/figures3/ConfPolyCorr.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/ConfPolyCorr.png rename to applications/muhrec/doc/usermanual/figures3/ConfPolyCorr.png diff --git a/applications/muhrec3/doc/usermanual/figures3/ConfProjFilter.png b/applications/muhrec/doc/usermanual/figures3/ConfProjFilter.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/ConfProjFilter.png rename to applications/muhrec/doc/usermanual/figures3/ConfProjFilter.png diff --git a/applications/muhrec3/doc/usermanual/figures3/ConfSpotClean2.png b/applications/muhrec/doc/usermanual/figures3/ConfSpotClean2.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/ConfSpotClean2.png rename to applications/muhrec/doc/usermanual/figures3/ConfSpotClean2.png diff --git a/applications/muhrec3/doc/usermanual/figures3/ConfigLogNorm.png b/applications/muhrec/doc/usermanual/figures3/ConfigLogNorm.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/ConfigLogNorm.png rename to applications/muhrec/doc/usermanual/figures3/ConfigLogNorm.png diff --git a/applications/muhrec3/doc/usermanual/figures3/Dialog_BigDataSet.png b/applications/muhrec/doc/usermanual/figures3/Dialog_BigDataSet.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/Dialog_BigDataSet.png rename to applications/muhrec/doc/usermanual/figures3/Dialog_BigDataSet.png diff --git a/applications/muhrec3/doc/usermanual/figures3/Dialog_CenterConfig.png b/applications/muhrec/doc/usermanual/figures3/Dialog_CenterConfig.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/Dialog_CenterConfig.png rename to applications/muhrec/doc/usermanual/figures3/Dialog_CenterConfig.png diff --git a/applications/muhrec3/doc/usermanual/figures3/Dialog_MorphSpotClean.png b/applications/muhrec/doc/usermanual/figures3/Dialog_MorphSpotClean.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/Dialog_MorphSpotClean.png rename to applications/muhrec/doc/usermanual/figures3/Dialog_MorphSpotClean.png diff --git a/applications/muhrec3/doc/usermanual/figures3/Dialog_SkipList.png b/applications/muhrec/doc/usermanual/figures3/Dialog_SkipList.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/Dialog_SkipList.png rename to applications/muhrec/doc/usermanual/figures3/Dialog_SkipList.png diff --git a/applications/muhrec3/doc/usermanual/figures3/GeometryListDlg.png b/applications/muhrec/doc/usermanual/figures3/GeometryListDlg.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/GeometryListDlg.png rename to applications/muhrec/doc/usermanual/figures3/GeometryListDlg.png diff --git a/applications/muhrec3/doc/usermanual/figures3/Main_DataAndGeometry.png b/applications/muhrec/doc/usermanual/figures3/Main_DataAndGeometry.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/Main_DataAndGeometry.png rename to applications/muhrec/doc/usermanual/figures3/Main_DataAndGeometry.png diff --git a/applications/muhrec3/doc/usermanual/figures3/Main_Information.png b/applications/muhrec/doc/usermanual/figures3/Main_Information.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/Main_Information.png rename to applications/muhrec/doc/usermanual/figures3/Main_Information.png diff --git a/applications/muhrec3/doc/usermanual/figures3/Main_Logging.png b/applications/muhrec/doc/usermanual/figures3/Main_Logging.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/Main_Logging.png rename to applications/muhrec/doc/usermanual/figures3/Main_Logging.png diff --git a/applications/muhrec3/doc/usermanual/figures3/Main_Modules.png b/applications/muhrec/doc/usermanual/figures3/Main_Modules.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/Main_Modules.png rename to applications/muhrec/doc/usermanual/figures3/Main_Modules.png diff --git a/applications/muhrec3/doc/usermanual/figures3/Main_Results.png b/applications/muhrec/doc/usermanual/figures3/Main_Results.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/Main_Results.png rename to applications/muhrec/doc/usermanual/figures3/Main_Results.png diff --git a/applications/muhrec3/doc/usermanual/figures3/MatrixTab.png b/applications/muhrec/doc/usermanual/figures3/MatrixTab.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/MatrixTab.png rename to applications/muhrec/doc/usermanual/figures3/MatrixTab.png diff --git a/applications/muhrec3/doc/usermanual/figures3/Module_LogNorm.png b/applications/muhrec/doc/usermanual/figures3/Module_LogNorm.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/Module_LogNorm.png rename to applications/muhrec/doc/usermanual/figures3/Module_LogNorm.png diff --git a/applications/muhrec3/doc/usermanual/figures3/Module_ProjectionFilter.png b/applications/muhrec/doc/usermanual/figures3/Module_ProjectionFilter.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/Module_ProjectionFilter.png rename to applications/muhrec/doc/usermanual/figures3/Module_ProjectionFilter.png diff --git a/applications/muhrec3/doc/usermanual/figures3/MuhRecROIs.png b/applications/muhrec/doc/usermanual/figures3/MuhRecROIs.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/MuhRecROIs.png rename to applications/muhrec/doc/usermanual/figures3/MuhRecROIs.png diff --git a/applications/muhrec3/doc/usermanual/figures3/ProcessingTab.png b/applications/muhrec/doc/usermanual/figures3/ProcessingTab.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/ProcessingTab.png rename to applications/muhrec/doc/usermanual/figures3/ProcessingTab.png diff --git a/applications/muhrec3/doc/usermanual/figures3/ProjectInfoTab.png b/applications/muhrec/doc/usermanual/figures3/ProjectInfoTab.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/ProjectInfoTab.png rename to applications/muhrec/doc/usermanual/figures3/ProjectInfoTab.png diff --git a/applications/muhrec3/doc/usermanual/figures3/ProjectionGeometry.png b/applications/muhrec/doc/usermanual/figures3/ProjectionGeometry.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/ProjectionGeometry.png rename to applications/muhrec/doc/usermanual/figures3/ProjectionGeometry.png diff --git a/applications/muhrec3/doc/usermanual/figures3/SaveProjectionsDlg.png b/applications/muhrec/doc/usermanual/figures3/SaveProjectionsDlg.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/SaveProjectionsDlg.png rename to applications/muhrec/doc/usermanual/figures3/SaveProjectionsDlg.png diff --git a/applications/muhrec3/doc/usermanual/figures3/Viewer_InfoDialog.png b/applications/muhrec/doc/usermanual/figures3/Viewer_InfoDialog.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/Viewer_InfoDialog.png rename to applications/muhrec/doc/usermanual/figures3/Viewer_InfoDialog.png diff --git a/applications/muhrec3/doc/usermanual/figures3/WaveletRingCleanDlg.png b/applications/muhrec/doc/usermanual/figures3/WaveletRingCleanDlg.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/WaveletRingCleanDlg.png rename to applications/muhrec/doc/usermanual/figures3/WaveletRingCleanDlg.png diff --git a/applications/muhrec3/doc/usermanual/figures3/adaptive_diff.png b/applications/muhrec/doc/usermanual/figures3/adaptive_diff.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/adaptive_diff.png rename to applications/muhrec/doc/usermanual/figures3/adaptive_diff.png diff --git a/applications/muhrec3/doc/usermanual/figures3/adaptive_filtered.png b/applications/muhrec/doc/usermanual/figures3/adaptive_filtered.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/adaptive_filtered.png rename to applications/muhrec/doc/usermanual/figures3/adaptive_filtered.png diff --git a/applications/muhrec3/doc/usermanual/figures3/adaptive_raw.png b/applications/muhrec/doc/usermanual/figures3/adaptive_raw.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/adaptive_raw.png rename to applications/muhrec/doc/usermanual/figures3/adaptive_raw.png diff --git a/applications/muhrec3/doc/usermanual/figures3/axis_tilt.pdf b/applications/muhrec/doc/usermanual/figures3/axis_tilt.pdf similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/axis_tilt.pdf rename to applications/muhrec/doc/usermanual/figures3/axis_tilt.pdf diff --git a/applications/muhrec3/doc/usermanual/figures3/lineartifact_clean.png b/applications/muhrec/doc/usermanual/figures3/lineartifact_clean.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/lineartifact_clean.png rename to applications/muhrec/doc/usermanual/figures3/lineartifact_clean.png diff --git a/applications/muhrec3/doc/usermanual/figures3/lineartifact_raw.png b/applications/muhrec/doc/usermanual/figures3/lineartifact_raw.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/lineartifact_raw.png rename to applications/muhrec/doc/usermanual/figures3/lineartifact_raw.png diff --git a/applications/muhrec3/doc/usermanual/figures3/local_raw.png b/applications/muhrec/doc/usermanual/figures3/local_raw.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/local_raw.png rename to applications/muhrec/doc/usermanual/figures3/local_raw.png diff --git a/applications/muhrec3/doc/usermanual/figures3/local_tap.png b/applications/muhrec/doc/usermanual/figures3/local_tap.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/local_tap.png rename to applications/muhrec/doc/usermanual/figures3/local_tap.png diff --git a/applications/muhrec3/doc/usermanual/figures3/muh_icon.pdf b/applications/muhrec/doc/usermanual/figures3/muh_icon.pdf similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/muh_icon.pdf rename to applications/muhrec/doc/usermanual/figures3/muh_icon.pdf diff --git a/applications/muhrec3/doc/usermanual/figures3/muh_icon.png b/applications/muhrec/doc/usermanual/figures3/muh_icon.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/muh_icon.png rename to applications/muhrec/doc/usermanual/figures3/muh_icon.png diff --git a/applications/muhrec3/doc/usermanual/figures3/muh_icon.svg b/applications/muhrec/doc/usermanual/figures3/muh_icon.svg similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/muh_icon.svg rename to applications/muhrec/doc/usermanual/figures3/muh_icon.svg diff --git a/applications/muhrec3/doc/usermanual/figures3/muhrec3.icns b/applications/muhrec/doc/usermanual/figures3/muhrec3.icns similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/muhrec3.icns rename to applications/muhrec/doc/usermanual/figures3/muhrec3.icns diff --git a/applications/muhrec3/doc/usermanual/figures3/tab1_refmodule.png b/applications/muhrec/doc/usermanual/figures3/tab1_refmodule.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/tab1_refmodule.png rename to applications/muhrec/doc/usermanual/figures3/tab1_refmodule.png diff --git a/applications/muhrec3/doc/usermanual/figures3/tab2_refmodule.png b/applications/muhrec/doc/usermanual/figures3/tab2_refmodule.png similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/tab2_refmodule.png rename to applications/muhrec/doc/usermanual/figures3/tab2_refmodule.png diff --git a/applications/muhrec3/doc/usermanual/figures3/translated_center.pdf b/applications/muhrec/doc/usermanual/figures3/translated_center.pdf similarity index 100% rename from applications/muhrec3/doc/usermanual/figures3/translated_center.pdf rename to applications/muhrec/doc/usermanual/figures3/translated_center.pdf diff --git a/applications/muhrec3/doc/usermanual/howto_mac.docx b/applications/muhrec/doc/usermanual/howto_mac.docx similarity index 100% rename from applications/muhrec3/doc/usermanual/howto_mac.docx rename to applications/muhrec/doc/usermanual/howto_mac.docx diff --git a/applications/muhrec3/doc/usermanual/install_instructions.tex b/applications/muhrec/doc/usermanual/install_instructions.tex similarity index 100% rename from applications/muhrec3/doc/usermanual/install_instructions.tex rename to applications/muhrec/doc/usermanual/install_instructions.tex diff --git a/applications/muhrec3/doc/usermanual/muhrec2_manual.tex b/applications/muhrec/doc/usermanual/muhrec2_manual.tex similarity index 100% rename from applications/muhrec3/doc/usermanual/muhrec2_manual.tex rename to applications/muhrec/doc/usermanual/muhrec2_manual.tex diff --git a/applications/muhrec3/doc/usermanual/muhrec3_manual.tex b/applications/muhrec/doc/usermanual/muhrec3_manual.tex similarity index 100% rename from applications/muhrec3/doc/usermanual/muhrec3_manual.tex rename to applications/muhrec/doc/usermanual/muhrec3_manual.tex diff --git a/applications/muhrec/package_mac.sh b/applications/muhrec/package_mac.sh new file mode 100755 index 000000000..ab7abf214 --- /dev/null +++ b/applications/muhrec/package_mac.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +mkdir /tmp/MuhRec +ln -s /Applications /tmp/muhrec/Applications +cp -r ~/Applications/MuhRec.app /tmp/MuhRec + +hdiutil create -volname MuhRec -srcfolder /tmp/muhrec -ov -format UDZO ~/MuhRec_`date +%Y%m%d`.dmg + diff --git a/applications/muhrec/package_ubuntu.sh b/applications/muhrec/package_ubuntu.sh new file mode 100755 index 000000000..6312c8b3e --- /dev/null +++ b/applications/muhrec/package_ubuntu.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +fname=~/muhrec_`uname -s`_`uname -m`_`date +%Y%m%d`_rev`svn info |grep Revision | sed -e 's/Revision: //'`.tar.bz2 + +echo $fname +pushd . +cd +#tar -jcvhf $fname muhrec +tar -jcvf $fname muhrec +popd + diff --git a/applications/muhrec3/proc_scripts/process_roots.py b/applications/muhrec/proc_scripts/process_roots.py similarity index 100% rename from applications/muhrec3/proc_scripts/process_roots.py rename to applications/muhrec/proc_scripts/process_roots.py diff --git a/applications/muhrec3/proc_scripts/recon_roots.xml b/applications/muhrec/proc_scripts/recon_roots.xml similarity index 100% rename from applications/muhrec3/proc_scripts/recon_roots.xml rename to applications/muhrec/proc_scripts/recon_roots.xml diff --git a/applications/muhrec3/scripts/muhrec3 b/applications/muhrec/scripts/muhrec similarity index 69% rename from applications/muhrec3/scripts/muhrec3 rename to applications/muhrec/scripts/muhrec index 938d94394..534bba323 100644 --- a/applications/muhrec3/scripts/muhrec3 +++ b/applications/muhrec/scripts/muhrec @@ -4,7 +4,7 @@ RP="`readlink -e $0`" BASEPATH="`dirname $RP`" MUHREC_BASE_PATH=$BASEPATH -LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$BASEPATH/Frameworks +LD_LIBRARY_PATH=$BASEPATH/Frameworks:$LD_LIBRARY_PATH export MUHREC_BASE_PATH export LD_LIBRARY_PATH @@ -14,5 +14,5 @@ do args=$args" "$arg done -$BASEPATH/bin/muhrec3 $args +$BASEPATH/bin/MuhRec $args diff --git a/applications/muhrec3/scripts/windows/CurrentRecon.xml b/applications/muhrec/scripts/windows/CurrentRecon.xml similarity index 100% rename from applications/muhrec3/scripts/windows/CurrentRecon.xml rename to applications/muhrec/scripts/windows/CurrentRecon.xml diff --git a/applications/muhrec3/scripts/windows/recon.bat b/applications/muhrec/scripts/windows/recon.bat similarity index 100% rename from applications/muhrec3/scripts/windows/recon.bat rename to applications/muhrec/scripts/windows/recon.bat diff --git a/applications/muhrec3/scripts/windows/run.bat b/applications/muhrec/scripts/windows/run.bat similarity index 100% rename from applications/muhrec3/scripts/windows/run.bat rename to applications/muhrec/scripts/windows/run.bat diff --git a/applications/muhrec3/src/MuhrecInteractor.cpp b/applications/muhrec/src/MuhrecInteractor.cpp similarity index 100% rename from applications/muhrec3/src/MuhrecInteractor.cpp rename to applications/muhrec/src/MuhrecInteractor.cpp diff --git a/applications/muhrec3/src/MuhrecInteractor.h b/applications/muhrec/src/MuhrecInteractor.h similarity index 100% rename from applications/muhrec3/src/MuhrecInteractor.h rename to applications/muhrec/src/MuhrecInteractor.h diff --git a/applications/muhrec3/src/PreProcModuleConfigurator.cpp b/applications/muhrec/src/PreProcModuleConfigurator.cpp similarity index 100% rename from applications/muhrec3/src/PreProcModuleConfigurator.cpp rename to applications/muhrec/src/PreProcModuleConfigurator.cpp diff --git a/applications/muhrec3/src/PreProcModuleConfigurator.h b/applications/muhrec/src/PreProcModuleConfigurator.h similarity index 100% rename from applications/muhrec3/src/PreProcModuleConfigurator.h rename to applications/muhrec/src/PreProcModuleConfigurator.h diff --git a/applications/muhrec3/src/ReconReport.cpp b/applications/muhrec/src/ReconReport.cpp similarity index 100% rename from applications/muhrec3/src/ReconReport.cpp rename to applications/muhrec/src/ReconReport.cpp diff --git a/applications/muhrec3/src/ReconReport.h b/applications/muhrec/src/ReconReport.h similarity index 100% rename from applications/muhrec3/src/ReconReport.h rename to applications/muhrec/src/ReconReport.h diff --git a/applications/muhrec3/src/configuregeometrydialog.cpp b/applications/muhrec/src/configuregeometrydialog.cpp similarity index 100% rename from applications/muhrec3/src/configuregeometrydialog.cpp rename to applications/muhrec/src/configuregeometrydialog.cpp diff --git a/applications/muhrec3/src/configuregeometrydialog.h b/applications/muhrec/src/configuregeometrydialog.h similarity index 100% rename from applications/muhrec3/src/configuregeometrydialog.h rename to applications/muhrec/src/configuregeometrydialog.h diff --git a/applications/muhrec3/src/configuregeometrydialog.ui b/applications/muhrec/src/configuregeometrydialog.ui similarity index 100% rename from applications/muhrec3/src/configuregeometrydialog.ui rename to applications/muhrec/src/configuregeometrydialog.ui diff --git a/applications/muhrec3/src/dialogtoobig.cpp b/applications/muhrec/src/dialogtoobig.cpp similarity index 100% rename from applications/muhrec3/src/dialogtoobig.cpp rename to applications/muhrec/src/dialogtoobig.cpp diff --git a/applications/muhrec3/src/dialogtoobig.h b/applications/muhrec/src/dialogtoobig.h similarity index 100% rename from applications/muhrec3/src/dialogtoobig.h rename to applications/muhrec/src/dialogtoobig.h diff --git a/applications/muhrec3/src/dialogtoobig.ui b/applications/muhrec/src/dialogtoobig.ui similarity index 100% rename from applications/muhrec3/src/dialogtoobig.ui rename to applications/muhrec/src/dialogtoobig.ui diff --git a/applications/muhrec3/src/findskiplistdialog.cpp b/applications/muhrec/src/findskiplistdialog.cpp similarity index 100% rename from applications/muhrec3/src/findskiplistdialog.cpp rename to applications/muhrec/src/findskiplistdialog.cpp diff --git a/applications/muhrec3/src/findskiplistdialog.h b/applications/muhrec/src/findskiplistdialog.h similarity index 100% rename from applications/muhrec3/src/findskiplistdialog.h rename to applications/muhrec/src/findskiplistdialog.h diff --git a/applications/muhrec3/src/findskiplistdialog.ui b/applications/muhrec/src/findskiplistdialog.ui similarity index 100% rename from applications/muhrec3/src/findskiplistdialog.ui rename to applications/muhrec/src/findskiplistdialog.ui diff --git a/applications/muhrec3/src/icons.qrc b/applications/muhrec/src/icons.qrc similarity index 100% rename from applications/muhrec3/src/icons.qrc rename to applications/muhrec/src/icons.qrc diff --git a/applications/muhrec3/src/main.cpp b/applications/muhrec/src/main.cpp similarity index 90% rename from applications/muhrec3/src/main.cpp rename to applications/muhrec/src/main.cpp index 477d04c83..8b61e16ca 100644 --- a/applications/muhrec3/src/main.cpp +++ b/applications/muhrec/src/main.cpp @@ -1,5 +1,8 @@ // +#include +#include + #include #include #include @@ -10,13 +13,15 @@ #include #include #include -#include "muhrecmainwindow.h" -#include + #include #include + #include #include +#include "muhrecmainwindow.h" + int RunGUI(QApplication *app); int RunOffline(QApplication *app); void TestConfig(); @@ -24,13 +29,14 @@ void TestConfig(); int main(int argc, char *argv[]) { - std::cout<<"Starting muhrec3"<Run3D(); logger(kipl::logging::Logger::LogMessage, "Reconstruction done"); @@ -177,8 +183,8 @@ int RunOffline(QApplication *app) } } // Exception handling as last resort to report unhandled faults catch (ReconException &re) { - cerr<<"An unhandled reconstructor exception occurred"< #include #include +#include #include #include @@ -133,8 +134,6 @@ MuhRecMainWindow::MuhRecMainWindow(QApplication *app, QWidget *parent) : SetupCallBacks(); ui->widgetProjectionROI->updateViewer(); -// if (ui->checkCBCT->isChecked()) SlicesCBCTChanged(0); - } MuhRecMainWindow::~MuhRecMainWindow() @@ -759,8 +758,9 @@ void MuhRecMainWindow::MenuHelpAbout() { QMessageBox dlg; std::ostringstream msg; + QVersionNumber ver; - msg<<"MuhRec 3\nCompile date: "<<__DATE__<<" at "<<__TIME__<applicationVersion().toStdString()<<"\nCompile date: "<<__DATE__<<" at "<<__TIME__<spinSlicesFirst->setMaximum(arg1-1); +// ui->spinSlicesFirst->setMaximum(arg1-1); SlicesChanged(arg1); } @@ -1892,28 +1892,6 @@ void MuhRecMainWindow::on_dspinResolution_valueChanged(double arg1) - -//void MuhRecMainWindow::on_spinSubVolumeSizeZ0_valueChanged(int arg1) -//{ -// SlicesCBCTChanged(arg1); -//} - -//void MuhRecMainWindow::on_spinSubVolumeSizeZ1_valueChanged(int arg1) -//{ -// SlicesCBCTChanged(arg1); -//} - -//void MuhRecMainWindow::SlicesCBCTChanged(int x) -//{ -// QRect rect; -// rect.setCoords(ui->spinProjROIx0->value(), -// ui->spinSubVolumeSizeZ0->value(), -// ui->spinProjROIx1->value(), -// ui->spinSubVolumeSizeZ1->value()); - -// ui->projectionViewer->set_rectangle(rect,QColor("lightblue"),2); -//} - void MuhRecMainWindow::on_actionRegister_for_news_letter_triggered() { QUrl url=QUrl("http://www.imagingscience.ch/newsletter/"); @@ -2508,8 +2486,8 @@ void MuhRecMainWindow::on_pushButtonGetSliceROI_clicked() return; } } - QSignalBlocker b1(ui->spinSlicesFirst); - QSignalBlocker b2(ui->spinSlicesLast); +// QSignalBlocker b1(ui->spinSlicesFirst); +// QSignalBlocker b2(ui->spinSlicesLast); ui->spinSlicesFirst->setValue(first); ui->spinSlicesLast->setValue(last); diff --git a/applications/muhrec3/src/muhrecmainwindow.h b/applications/muhrec/src/muhrecmainwindow.h similarity index 99% rename from applications/muhrec3/src/muhrecmainwindow.h rename to applications/muhrec/src/muhrecmainwindow.h index d5c65203a..d731025e4 100644 --- a/applications/muhrec3/src/muhrecmainwindow.h +++ b/applications/muhrec/src/muhrecmainwindow.h @@ -37,7 +37,7 @@ class MuhRecMainWindow : public QMainWindow, public ApplicationBase QApplication *m_QtApp; void SetApplicationPath(std::string path) {m_sApplicationPath=path;} void SlicesChanged(int x); - void SlicesCBCTChanged(int x); +// void SlicesCBCTChanged(int x); // Collection of call-backs diff --git a/applications/muhrec3/src/muhrecmainwindow.ui b/applications/muhrec/src/muhrecmainwindow.ui similarity index 99% rename from applications/muhrec3/src/muhrecmainwindow.ui rename to applications/muhrec/src/muhrecmainwindow.ui index 173fada3b..058649030 100644 --- a/applications/muhrec3/src/muhrecmainwindow.ui +++ b/applications/muhrec/src/muhrecmainwindow.ui @@ -11,7 +11,7 @@ - MuhRec 3 + MuhRec @@ -2331,7 +2331,7 @@ 0 0 1126 - 22 + 26 diff --git a/applications/muhrec3/src/piercingpointdialog.cpp b/applications/muhrec/src/piercingpointdialog.cpp similarity index 100% rename from applications/muhrec3/src/piercingpointdialog.cpp rename to applications/muhrec/src/piercingpointdialog.cpp diff --git a/applications/muhrec3/src/piercingpointdialog.h b/applications/muhrec/src/piercingpointdialog.h similarity index 100% rename from applications/muhrec3/src/piercingpointdialog.h rename to applications/muhrec/src/piercingpointdialog.h diff --git a/applications/muhrec3/src/piercingpointdialog.ui b/applications/muhrec/src/piercingpointdialog.ui similarity index 100% rename from applications/muhrec3/src/piercingpointdialog.ui rename to applications/muhrec/src/piercingpointdialog.ui diff --git a/applications/muhrec3/src/preferencesdialog.cpp b/applications/muhrec/src/preferencesdialog.cpp similarity index 100% rename from applications/muhrec3/src/preferencesdialog.cpp rename to applications/muhrec/src/preferencesdialog.cpp diff --git a/applications/muhrec3/src/preferencesdialog.h b/applications/muhrec/src/preferencesdialog.h similarity index 100% rename from applications/muhrec3/src/preferencesdialog.h rename to applications/muhrec/src/preferencesdialog.h diff --git a/applications/muhrec3/src/preferencesdialog.ui b/applications/muhrec/src/preferencesdialog.ui similarity index 100% rename from applications/muhrec3/src/preferencesdialog.ui rename to applications/muhrec/src/preferencesdialog.ui diff --git a/applications/muhrec3/src/recondialog.cpp b/applications/muhrec/src/recondialog.cpp similarity index 100% rename from applications/muhrec3/src/recondialog.cpp rename to applications/muhrec/src/recondialog.cpp diff --git a/applications/muhrec3/src/recondialog.h b/applications/muhrec/src/recondialog.h similarity index 100% rename from applications/muhrec3/src/recondialog.h rename to applications/muhrec/src/recondialog.h diff --git a/applications/muhrec3/src/recondialog.ui b/applications/muhrec/src/recondialog.ui similarity index 100% rename from applications/muhrec3/src/recondialog.ui rename to applications/muhrec/src/recondialog.ui diff --git a/applications/muhrec3/src/referencefiledlg.cpp b/applications/muhrec/src/referencefiledlg.cpp similarity index 100% rename from applications/muhrec3/src/referencefiledlg.cpp rename to applications/muhrec/src/referencefiledlg.cpp diff --git a/applications/muhrec3/src/referencefiledlg.h b/applications/muhrec/src/referencefiledlg.h similarity index 100% rename from applications/muhrec3/src/referencefiledlg.h rename to applications/muhrec/src/referencefiledlg.h diff --git a/applications/muhrec3/src/referencefiledlg.ui b/applications/muhrec/src/referencefiledlg.ui similarity index 100% rename from applications/muhrec3/src/referencefiledlg.ui rename to applications/muhrec/src/referencefiledlg.ui diff --git a/applications/muhrec3/src/resources/defaults_linux.xml b/applications/muhrec/src/resources/defaults_linux.xml similarity index 100% rename from applications/muhrec3/src/resources/defaults_linux.xml rename to applications/muhrec/src/resources/defaults_linux.xml diff --git a/applications/muhrec3/src/resources/defaults_mac.xml b/applications/muhrec/src/resources/defaults_mac.xml similarity index 100% rename from applications/muhrec3/src/resources/defaults_mac.xml rename to applications/muhrec/src/resources/defaults_mac.xml diff --git a/applications/muhrec3/src/resources/defaults_windows.xml b/applications/muhrec/src/resources/defaults_windows.xml similarity index 100% rename from applications/muhrec3/src/resources/defaults_windows.xml rename to applications/muhrec/src/resources/defaults_windows.xml diff --git a/applications/muhrec3/src/resources/muh4_icon.icns b/applications/muhrec/src/resources/muh4_icon.icns similarity index 100% rename from applications/muhrec3/src/resources/muh4_icon.icns rename to applications/muhrec/src/resources/muh4_icon.icns diff --git a/applications/muhrec3/src/resources/muh4_icon.ico b/applications/muhrec/src/resources/muh4_icon.ico similarity index 100% rename from applications/muhrec3/src/resources/muh4_icon.ico rename to applications/muhrec/src/resources/muh4_icon.ico diff --git a/applications/muhrec3/src/resources/muhrec3.icns b/applications/muhrec/src/resources/muhrec3.icns similarity index 100% rename from applications/muhrec3/src/resources/muhrec3.icns rename to applications/muhrec/src/resources/muhrec3.icns diff --git a/applications/muhrec3/src/stdafx.cpp b/applications/muhrec/src/stdafx.cpp similarity index 100% rename from applications/muhrec3/src/stdafx.cpp rename to applications/muhrec/src/stdafx.cpp diff --git a/applications/muhrec3/src/stdafx.h b/applications/muhrec/src/stdafx.h similarity index 100% rename from applications/muhrec3/src/stdafx.h rename to applications/muhrec/src/stdafx.h diff --git a/applications/muhrec3/src/viewgeometrylistdialog.cpp b/applications/muhrec/src/viewgeometrylistdialog.cpp similarity index 100% rename from applications/muhrec3/src/viewgeometrylistdialog.cpp rename to applications/muhrec/src/viewgeometrylistdialog.cpp diff --git a/applications/muhrec3/src/viewgeometrylistdialog.h b/applications/muhrec/src/viewgeometrylistdialog.h similarity index 100% rename from applications/muhrec3/src/viewgeometrylistdialog.h rename to applications/muhrec/src/viewgeometrylistdialog.h diff --git a/applications/muhrec3/src/viewgeometrylistdialog.ui b/applications/muhrec/src/viewgeometrylistdialog.ui similarity index 100% rename from applications/muhrec3/src/viewgeometrylistdialog.ui rename to applications/muhrec/src/viewgeometrylistdialog.ui diff --git a/applications/muhrec3/package_mac.sh b/applications/muhrec3/package_mac.sh deleted file mode 100755 index ca15998d8..000000000 --- a/applications/muhrec3/package_mac.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh - -mkdir /tmp/muhrec3 -ln -s /Applications /tmp/muhrec3/Applications -cp -r ~/Applications/muhrec3.app /tmp/muhrec3 - -hdiutil create -volname MuhRec3 -srcfolder /tmp/muhrec3 -ov -format UDZO ~/MuhRec3_`date +%Y%m%d`.dmg - diff --git a/applications/muhrec3/package_ubuntu.sh b/applications/muhrec3/package_ubuntu.sh deleted file mode 100755 index f3bf9f6b1..000000000 --- a/applications/muhrec3/package_ubuntu.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -fname=~/muhrec3_`uname -s`_`uname -m`_`date +%Y%m%d`_rev`svn info |grep Revision | sed -e 's/Revision: //'`.tar.bz2 - -echo $fname -pushd . -cd ~/home/ -#tar -jcvhf $fname muhrec3 -tar -jcvf $fname muhrec3_14 -popd - diff --git a/build/build_applications_muhrec.sh b/build/build_applications_muhrec.sh index 457370762..3fa839d2c 100755 --- a/build/build_applications_muhrec.sh +++ b/build/build_applications_muhrec.sh @@ -12,22 +12,22 @@ DEST=$WORKSPACE/builds mkdir -p $DEST/build-muhrec cd $DEST/build-muhrec -$QTBINPATH/qmake -makefile -r $SPECSTR -o Makefile ../../imagingsuite/applications/muhrec3/src/muhrec3.pro +$QTBINPATH/qmake -makefile -r $SPECSTR -o Makefile ../../imagingsuite/applications/muhrec/src/muhrec.pro make -f Makefile clean make -f Makefile mocables all make -f Makefile echo "Build tests" -if [ -e "$REPOSPATH/applications/muhrec3/UnitTests" ]; then -for f in `ls $REPOSPATH/applications/muhrec3/UnitTests` +if [ -e "$REPOSPATH/applications/muhrec/UnitTests" ]; then +for f in `ls $REPOSPATH/applications/muhrec/UnitTests` do - echo "$REPOSPATH/applications/muhrec3/UnitTests/$f/$f.pro" - if [ -e "$REPOSPATH/applications/muhrec3/UnitTests/$f/$f.pro" ] + echo "$REPOSPATH/applications/muhrec/UnitTests/$f/$f.pro" + if [ -e "$REPOSPATH/applications/muhrec/UnitTests/$f/$f.pro" ] then mkdir -p $DEST/build-$f cd $DEST/build-$f - $QTBINPATH/qmake -makefile -r $SPECSTR -o Makefile ../../imagingsuite/applications/muhrec3/UnitTests/$f/$f.pro + $QTBINPATH/qmake -makefile -r $SPECSTR -o Makefile ../../imagingsuite/applications/muhrec/UnitTests/$f/$f.pro make -f Makefile clean make -f Makefile mocables all make -f Makefile diff --git a/build/windows/build_all.bat b/build/windows/build_all.bat index 57ee9774f..2ec617e7a 100644 --- a/build/windows/build_all.bat +++ b/build/windows/build_all.bat @@ -10,4 +10,5 @@ rem call build_applications_NIQA.bat rem call build_applications_imageviewer.bat rem call build_applications_kipltool.bat call build_applications_muhrec.bat +call build_applications_muhrecCLI.bat diff --git a/build/windows/build_applications_muhrec.bat b/build/windows/build_applications_muhrec.bat index ebaeba813..9e1ba8a61 100644 --- a/build/windows/build_applications_muhrec.bat +++ b/build/windows/build_applications_muhrec.bat @@ -9,14 +9,14 @@ mkdir %DEST%\build-muhrec cd %DEST%\build-muhrec -%QTBINPATH%\qmake.exe -makefile ..\..\imagingsuite\applications\muhrec3\src\muhrec3.pro -o Makefile +%QTBINPATH%\qmake.exe -makefile ..\..\imagingsuite\applications\muhrec\src\muhrec.pro -o Makefile %QTBINPATH%\..\..\..\Tools\QtCreator\bin\jom.exe -f Makefile clean %QTBINPATH%\..\..\..\Tools\QtCreator\bin\jom.exe -f Makefile mocables all %QTBINPATH%\..\..\..\Tools\QtCreator\bin\jom.exe -f Makefile release echo "Build tests" -cd %REPOSPATH%\applications\muhrec3\UnitTests +cd %REPOSPATH%\applications\muhrec\UnitTests FOR /D %%I IN (*) DO @call :testloopbody %REPOSPATH% %%I %DEST% @@ -27,11 +27,11 @@ goto :eof :testloopbody echo %2 -if exist "%1\applications\muhrec3\UnitTests\%2\%2.pro" ( +if exist "%1\applications\muhrec\UnitTests\%2\%2.pro" ( mkdir %3\%2 cd %3\%2 - %QTBINPATH%\qmake.exe -makefile ..\..\imagingsuite\applications\muhrec3\UnitTests\%2\%2.pro -o Makefile + %QTBINPATH%\qmake.exe -makefile ..\..\imagingsuite\applications\muhrec\UnitTests\%2\%2.pro -o Makefile %QTBINPATH%\..\..\..\Tools\QtCreator\bin\jom.exe -f Makefile clean %QTBINPATH%\..\..\..\Tools\QtCreator\bin\jom.exe -f Makefile mocables all %QTBINPATH%\..\..\..\Tools\QtCreator\bin\jom.exe -f Makefile release diff --git a/core/algorithms/ImagingAlgorithms/include/ReferenceImageCorrection.h b/core/algorithms/ImagingAlgorithms/include/ReferenceImageCorrection.h new file mode 100644 index 000000000..ff5fd078a --- /dev/null +++ b/core/algorithms/ImagingAlgorithms/include/ReferenceImageCorrection.h @@ -0,0 +1,235 @@ +// + +#ifndef REFERENCEIMAGECORRECTION_H +#define REFERENCEIMAGECORRECTION_H +#include "ImagingAlgorithms_global.h" + +#include +#include + +#include +#include +#include "../include/averageimage.h" +#include + + + +namespace ImagingAlgorithms { + +class IMAGINGALGORITHMSSHARED_EXPORT ReferenceImageCorrection { +protected: + kipl::logging::Logger logger; +public: + enum eReferenceMethod { + ReferenceLogNorm, + ReferenceNorm + }; /// Options for Referencing method. not yet used + + enum eBBOptions { + noBB, + Interpolate, + Average, + OneToOne, + ExternalBB + }; /// Options for BB image handling + + enum eInterpOrderX{ + SecondOrder_x, + FirstOrder_x, + ZeroOrder_x + }; /// Options for BB mask interpolation, x direction + + enum eInterpOrderY{ + SecondOrder_y, + FirstOrder_y, + ZeroOrder_y + }; /// Options for BB mask interpolation, y direction + + enum eInterpMethod{ + Polynomial, + ThinPlateSplines + }; /// Options for background interpolation + + + + ReferenceImageCorrection(); + virtual ~ReferenceImageCorrection(); + + void LoadReferenceImages(std::string path, std::string obname, size_t firstob, size_t obcnt, + std::string dcname, size_t firstdc, size_t dccnt, + std::string bbname, size_t firstbb, size_t bbcnt, + size_t *roi, + size_t *doseroi); + + void SetReferenceImages(kipl::base::TImage *ob, + kipl::base::TImage *dc, + bool useBB, + bool useExtBB, + float dose_OB, + float dose_DC, + bool normBB, + size_t *roi, size_t *doseroi); + + void SetInterpParameters(float *ob_parameter, float *sample_parameter, size_t nBBSampleCount, size_t nProj, eBBOptions ebo); /// set interpolation parameters to be used for BB image computation + void SetSplinesParameters(float *ob_parameter, float *sample_parameter, size_t nBBSampleCount, size_t nProj, eBBOptions ebo, int nBBs); /// set interpolation parameters to be used for BB image computation in the case of thin plate splines + void SetBBInterpRoi(size_t *roi); ///set roi to be used for computing interpolated values, it is a roi relative to the projection_roi, because the interpolation parameters are computed with respect to the projection_roi + void SetBBInterpDoseRoi(size_t *roi); /// set dose roi to be used for computing interpolated values. it is the dose roi relative the projection_roi, because the interpolation parameters are computed with respect to the projection_roi + + void ComputeLogartihm(bool x) {m_bComputeLogarithm=x;} ///< set bool value for computing -logarithm + void SetRadius(size_t x) {radius=x;} ///< set the radius used to define subset of segmented BBs + void SetTau (float x) {tau=x;} ///< set value of tau + void setDiffRoi (int *roi) {memcpy(m_diffBBroi, roi, sizeof(int)*4);} ///< set diffroi, which is the difference between BBroi and the Projection roi -- it should be now only the BBroi + void SetPBvariante (bool x) {bPBvariante=x; } ///< set bool value for computation of pierre's variante. at the moment it is hidden from the Gui and it is intended to be set as dafault true + void SetMinArea (size_t x) {min_area=x;} ///< set min area for BB segmentation + + void SetInterpolationOrderX(eInterpOrderX eim_x); + void SetInterpolationOrderY(eInterpOrderY eim_y); + void SetSplineObValues(std::map, float> &values) {spline_ob_values = values;} /// set map to be used for spline interpolation of ob images + void SetSplineSampleValues(std::map, float> &values){spline_sample_values = values; } /// set map to used for spline interpolation of sample images + void SetInterpolationMethod(eInterpMethod eint_meth) {m_InterpMethod = eint_meth;} /// set method for background interpolation, polynomial or splines + void SetManualThreshold(bool bThresh, float value) {{bUseManualThresh=bThresh; thresh=value;}} + + void SetAngles(float *ang, size_t nProj, size_t nBB); ///< set angles and number of proj and images with BB, to be used for more general interpolation + void SetDoseList(float *doselist); /// set dose list for sample images in the BB dose roi, it has to be called after SetAngles for the right definition of m_nProj + + kipl::base::TImage Process(kipl::base::TImage &img, float dose); ///< 2D process + void Process(kipl::base::TImage &img, float *dose); ///< 3D process + + float* PrepareBlackBodyImage(kipl::base::TImage &flat, kipl::base::TImage &dark, kipl::base::TImage &bb, kipl::base::TImage &mask); /// segments normalized image (bb-dark)/(flat-dark) to create mask and then call ComputeInterpolationParameter + float* PrepareBlackBodyImage(kipl::base::TImage &flat, kipl::base::TImage &dark, kipl::base::TImage &bb, kipl::base::TImage &mask, float &error); /// segments normalized image (bb-dark)/(flat-dark) to create mask and then call ComputeInterpolationParameter, finally computes interpolation error + float* PrepareBlackBodyImagewithSplines(kipl::base::TImage &flat, kipl::base::TImage &dark, kipl::base::TImage &bb, kipl::base::TImage &mask, std::map, float> &values); /// segments normalized image to create mask and then call interpolation with splines + float* PrepareBlackBodyImagewithSplinesAndMask(kipl::base::TImage &dark, kipl::base::TImage &bb, kipl::base::TImage&mask, std::map, float> &values); /// uses a predefined mask and then call the thin plates spline interpolation + float* PrepareBlackBodyImagewithMask(kipl::base::TImage &dark, kipl::base::TImage &bb, kipl::base::TImage&mask); /// uses a predefined mask and then call ComputeInterpolationParameter + float* ComputeInterpolationParameters(kipl::base::TImage&mask, kipl::base::TImage&img); /// compute interpolation parameters from img and mask + float* ComputeInterpolationParameters(kipl::base::TImage&mask, kipl::base::TImage&img, float &error); /// compute interpolation parameters from img and mask and give as output interpolation error + kipl::base::TImage InterpolateBlackBodyImage(float *parameters, size_t *roi); /// compute interpolated image from polynomial parameters + kipl::base::TImage InterpolateBlackBodyImagewithSplines(float *parameters, std::map,float> &values, size_t *roi); /// compute interpolated image from splines parameters + float ComputeInterpolationError(kipl::base::TImage&interpolated_img, kipl::base::TImage&mask, kipl::base::TImage &img); /// compute interpolation error from interpolated image, original image and mask that highlights the pixels to be considered + + void SetExternalBBimages(kipl::base::TImage &bb_ext, kipl::base::TImage &bb_sample_ext, float &dose, float *doselist); /// set the BB externally computed images and corresponding doses + void SetComputeMinusLog(bool value) {m_bComputeLogarithm = value;} + + +protected: + void PrepareReferences(); /// old version with references image preparation, without BB + void PrepareReferencesBB(); /// prepare reference images in case of BB + void PrepareReferencesExtBB(); /// prepare reference images in case of externally created BB + + float *SolveLinearEquation(std::map, float> &values, float &error); + float *SolveThinPlateSplines(std::map,float> &values); + + void SegmentBlackBody(kipl::base::TImage &img, kipl::base::TImage &mask); /// apply Otsu segmentation to img and create mask, it also performs some image cleaning + void SegmentBlackBody(kipl::base::TImage &normimg, kipl::base::TImage &img, kipl::base::TImage &mask, std::map, float> &values); /// apply Otsu segmentation to img and create mask, it also performs some image cleaning and creates a list with position of BB centroids + void ComputeBlackBodyCentroids(kipl::base::TImage &img, kipl::base::TImage &mask, std::map, float> &values); /// uses the same mask to create centroids values list + + float *InterpolateParameters(float *param, size_t n, size_t step); /// Interpolate parameters assuming the BB sample image are acquired uniformally with some step over the n Projection images + float *InterpolateParametersGeneric(float *param); /// Interpolate parameters for generic configuration of number of BB sample images and projection data, it assumes first SetAngle is called + float *InterpolateSplineGeneric(float *param, int nBBs); /// Interpolate parameters in the case of thin plates splines + float *ReplicateParameters(float *param, size_t n); /// Replicate interpolation parameter, to be used for the Average method + float *ReplicateSplineParameters(float *param, size_t n, int nBBs); /// Replicate interpolation parameters, to be used for the Average method and Spline option + + int ComputeLogNorm(kipl::base::TImage &img, float dose); + void ComputeNorm(kipl::base::TImage &img, float dose); + int* repeat_matrix(int* source, int count, int expand); /// repeat matrix. not used. + float computedose(kipl::base::TImage&img); /// duplicate.. to move in timage probably or something like this + + bool m_bHaveOpenBeam; + bool m_bHaveDarkCurrent; + bool m_bHaveBlackBody; + bool m_bHaveExternalBlackBody; + bool m_bComputeLogarithm; + bool bUseManualThresh; + + kipl::base::TImage m_OpenBeam; + kipl::base::TImage m_OpenBeamforBB; + kipl::base::TImage m_DarkCurrent; + kipl::base::TImage m_BlackBody; + kipl::base::TImage m_OB_BB_Interpolated; + kipl::base::TImage m_BB_sample_Interpolated; // computed in process 3d every time. but in the right way! + kipl::base::TImage m_DoseBBsample_image; + kipl::base::TImage m_DoseBBflat_image; + + kipl::base::TImage m_OB_BB_ext; /// externally computed OB image with BBs + kipl::base::TImage m_BB_sample_ext; /// externally computed sample image with BBs + kipl::base::TImage m_BB_slice_ext; /// externally computed slice of sample image with BBs + + + + float m_fOpenBeamDose; + float m_fDarkDose; + bool m_bHaveDoseROI; + bool m_bHaveBBDoseROI; + bool m_bHaveBlackBodyROI; + bool bPBvariante; + + float fdoseOB_ext; /// dose value in externally computed open beam with BB image in dose roi + float *fdose_ext_list; /// dose value list in externally computed sample with BB image in dose roi + float fdose_ext_slice; /// dose value of current slice from fdose_ext_list + + float *ob_bb_parameters; /// interpolation parameters for the OB BB image + float *sample_bb_parameters; /// interpolation parameters for the sample image with BB + float *sample_bb_interp_parameters; /// interpolation parameters for the sample image for each projection angle + + ImagingAlgorithms::AverageImage::eAverageMethod m_AverageMethod; /// method used for image averaging (options: sum, mean, max, weightedmean, median and average) + + eInterpOrderX m_IntMeth_x; + eInterpOrderY m_IntMeth_y; + + eInterpMethod m_InterpMethod; + + + int a,b,c,d,e,f; /// weights for interpolation scheme, used to set different combined order + + size_t m_nDoseROI[4]; /// roi to be used for dose computation on BB images ("big roi" I would say..) + size_t m_nROI[4]; /// actual roi onto compute the background images + size_t m_nBlackBodyROI[4]; /// roi to be used for computing interpolated BB images, roi position is relative to the image projection roi, on which interpolation parameters are computed + int m_diffBBroi[4]; /// difference between BB roi and projection roi, important when computing interpolation parameters + size_t m_nDoseBBRoi[4]; /// "big roi" to be used for dose computation on BB images, this is now relative to projection roi coordinates, due to the interpolation scheme + size_t m_nBBimages; /// number of images with BB sample that are available + size_t m_nProj; /// number of images that are needed after interpolation + float angles[4]; /// first and last angles of nProj and nBBImages, respectively + size_t radius; /// radius value for BB mask creation + float tau; /// mean pattern transmission + float *dosesamplelist; /// list of doses for sample images computed at dose BB roi, to be used in the Interpolate BBOption + size_t min_area; /// min area for BB segmentation + float thresh; /// manual threshold + + std::map, float> spline_ob_values; /// map to be used for interpolation with splines and ob image. should be in principle the same number of images with BB, i start now with 1 + std::map, float> spline_sample_values; /// map to be used for interpolation with splines and sample image +}; + +} + +void IMAGINGALGORITHMSSHARED_EXPORT string2enum(std::string str, ImagingAlgorithms::ReferenceImageCorrection::eReferenceMethod &erm); + +std::string IMAGINGALGORITHMSSHARED_EXPORT enum2string(const ImagingAlgorithms::ReferenceImageCorrection::eReferenceMethod &erm); + +std::ostream IMAGINGALGORITHMSSHARED_EXPORT & operator<<(ostream & s, ImagingAlgorithms::ReferenceImageCorrection::eReferenceMethod erm); + +void IMAGINGALGORITHMSSHARED_EXPORT string2enum(std::string str, ImagingAlgorithms::ReferenceImageCorrection::eBBOptions &ebo); + +std::string IMAGINGALGORITHMSSHARED_EXPORT enum2string(const ImagingAlgorithms::ReferenceImageCorrection::eBBOptions &ebo); + +std::ostream IMAGINGALGORITHMSSHARED_EXPORT & operator<<(ostream & s, ImagingAlgorithms::ReferenceImageCorrection::eBBOptions ebo); + +void IMAGINGALGORITHMSSHARED_EXPORT string2enum(std::string str, ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderX &eim_x); + +std::string IMAGINGALGORITHMSSHARED_EXPORT enum2string(const ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderX &eim_x); + +std::ostream IMAGINGALGORITHMSSHARED_EXPORT & operator<<(ostream & s, ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderX eim_x); + +void IMAGINGALGORITHMSSHARED_EXPORT string2enum(std::string str, ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderY &eim_y); + +std::string IMAGINGALGORITHMSSHARED_EXPORT enum2string(const ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderY &eim_y); + +std::ostream IMAGINGALGORITHMSSHARED_EXPORT & operator<<(ostream & s, ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderY eim_y); + +void IMAGINGALGORITHMSSHARED_EXPORT string2enum(std::string str, ImagingAlgorithms::ReferenceImageCorrection::eInterpMethod &eint); + +std::string IMAGINGALGORITHMSSHARED_EXPORT enum2string(const ImagingAlgorithms::ReferenceImageCorrection::eInterpMethod &eint); + +std::ostream IMAGINGALGORITHMSSHARED_EXPORT & operator<<(ostream & s, ImagingAlgorithms::ReferenceImageCorrection::eInterpMethod eint); + + + +#endif /* REFERENCEIMAGECORRECTION_H_ */ diff --git a/core/algorithms/ImagingAlgorithms/qt/ImagingAlgorithms/ImagingAlgorithms.pro b/core/algorithms/ImagingAlgorithms/qt/ImagingAlgorithms/ImagingAlgorithms.pro index 6abf0d940..d7815c350 100644 --- a/core/algorithms/ImagingAlgorithms/qt/ImagingAlgorithms/ImagingAlgorithms.pro +++ b/core/algorithms/ImagingAlgorithms/qt/ImagingAlgorithms/ImagingAlgorithms.pro @@ -64,7 +64,8 @@ SOURCES += \ ../../src/pixelinfo.cpp \ ../../src/gammaclean.cpp \ ../../src/averageimage.cpp \ - ../../src/piercingpointestimator.cpp + ../../src/piercingpointestimator.cpp \ + ../../src/ReferenceImageCorrection.cpp HEADERS += \ ../../include/StripeFilter.h \ @@ -77,7 +78,8 @@ HEADERS += \ ../../include/ImagingAlgorithms_global.h \ ../../include/gammaclean.h \ ../../include/averageimage.h \ - ../../include/piercingpointestimator.h + ../../include/piercingpointestimator.h \ + ../../include/ReferenceImageCorrection.h symbian { diff --git a/core/algorithms/ImagingAlgorithms/src/ReferenceImageCorrection.cpp b/core/algorithms/ImagingAlgorithms/src/ReferenceImageCorrection.cpp new file mode 100644 index 000000000..9cf5bca7b --- /dev/null +++ b/core/algorithms/ImagingAlgorithms/src/ReferenceImageCorrection.cpp @@ -0,0 +1,3078 @@ +// + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../include/ReferenceImageCorrection.h" +#include "../include/ImagingException.h" + +using namespace TNT; + +namespace ImagingAlgorithms { + +ReferenceImageCorrection::ReferenceImageCorrection() : + logger("ReferenceImageCorrection"), + m_bHaveOpenBeam(false), + m_bHaveDarkCurrent(false), + m_bHaveBlackBody(false), + m_bComputeLogarithm(true), + m_fOpenBeamDose(1.0f), + m_bHaveDoseROI(false), + m_bHaveBlackBodyROI(false), + m_bHaveBBDoseROI(false), + tau(1.0f), + radius(0), + m_AverageMethod(ImagingAlgorithms::AverageImage::ImageWeightedAverage), + m_IntMeth_x(SecondOrder_x), + m_IntMeth_y(SecondOrder_y), + m_nProj(0), + m_nBBimages(0), + m_bHaveExternalBlackBody(false), + fdose_ext_slice(0.0f), + min_area(0), + bUseManualThresh(false), + thresh(0.0f) +{ + m_nDoseROI[0]=0; + m_nDoseROI[1]=0; + m_nDoseROI[2]=0; + m_nDoseROI[3]=0; + + m_nROI[0]=0; + m_nROI[1]=0; + m_nROI[2]=0; + m_nROI[3]=0; + + m_nBlackBodyROI[0]=0; + m_nBlackBodyROI[1]=0; + m_nBlackBodyROI[2]=0; + m_nBlackBodyROI[3]=0; + + m_diffBBroi[0]=0; + m_diffBBroi[0]=0; + m_diffBBroi[0]=0; + m_diffBBroi[0]=0; + + angles[0] = 0.0f; + angles[1] = 0.0f; + angles[2] = 0.0f; + angles[3] = 0.0f; + + a = b = c = d = e = f = 1; + +} + +ReferenceImageCorrection::~ReferenceImageCorrection() +{ + +} + +//not used +void ReferenceImageCorrection::LoadReferenceImages(std::string path, std::string obname, size_t firstob, size_t obcnt, + std::string dcname, size_t firstdc, size_t dccnt, + std::string bbname, size_t firstbb, size_t bbcnt, size_t *roi, + size_t *doseroi) +{ + + std::cout << "ciao process " << std::endl; + +} + +void ReferenceImageCorrection::SetReferenceImages(kipl::base::TImage *ob, + kipl::base::TImage *dc, + bool useBB, bool useExtBB, + float dose_OB, + float dose_DC, + bool normBB, + size_t *roi, + size_t *doseroi) +{ + + if (ob!=NULL) { + m_bHaveOpenBeam=true; + m_OpenBeam=*ob; +// kipl::io::WriteTIFF32(m_OpenBeam,"roi_ob.tif"); + } + + if (dc!=NULL) { + m_bHaveDarkCurrent=true; + m_DarkCurrent=*dc; +// kipl::io::WriteTIFF32(m_DarkCurrent,"roi_dc.tif"); + } + + if(doseroi!=nullptr){ + + memcpy(m_nDoseROI,doseroi, sizeof(size_t)*4); + } + if (roi!=nullptr){ + memcpy(m_nROI,roi, sizeof(size_t)*4); + } + + if (dose_OB!=0) { + m_bHaveDoseROI=true; + m_fOpenBeamDose = dose_OB; + } + + if (dose_DC!=0){ + m_fDarkDose = dose_DC; + } + + if (normBB) { + m_bHaveBlackBodyROI = true; + m_bHaveBBDoseROI = true; + } + + + if (useBB) { + m_bHaveBlackBody=true; + + // these images are used to compute the dose in the PB variante + // they must be declared here because they are then used in PrepareReferencesBB(); + +// m_OB_BB_Interpolated = InterpolateBlackBodyImage(ob_bb_parameters, m_nBlackBodyROI); +// m_DoseBBflat_image = InterpolateBlackBodyImage(ob_bb_parameters, m_nDoseBBRoi); +// std::cout << "before switch interpmethod" << std::endl; + + switch (m_InterpMethod) { + case (Polynomial):{ +// std::cout << "case polynomial" << std::endl; + m_OB_BB_Interpolated = InterpolateBlackBodyImage(ob_bb_parameters, m_nROI); // now rois are in absolute coordinates , richtig? + m_DoseBBflat_image = InterpolateBlackBodyImage(ob_bb_parameters, m_nDoseROI); + break; + } + case(ThinPlateSplines): { +// std::cout << "case splines: " << std::endl; +// for (std::map, float>::const_iterator it = spline_values.begin(); it != spline_values.end(); ++it) +// { +// std::cout << it->first.first << " " << it->first.second << " " << it->second << std::endl; +// } + +// std::cout << "number of centroids found: " << spline_values.size() << " " << std::endl; + + m_OB_BB_Interpolated = InterpolateBlackBodyImagewithSplines(ob_bb_parameters, spline_ob_values, m_nROI); // now rois are in absolute coordinates , richtig? + m_DoseBBflat_image = InterpolateBlackBodyImagewithSplines(ob_bb_parameters, spline_ob_values, m_nDoseROI); + + + +// if (i==0){ +// std::cout << "------DEBUG on CURRENT PARAM ----" << std::endl; +// for(int j=0;j, float>::const_iterator it = spline_ob_values.begin(); it != spline_ob_values.end(); ++it) +// { +// spline_OB_values << it->first.first << " " << it->first.second << " " << it->second << std::endl; +// } + + + + break;} +// default: throw ImagingException("Unknown m_InterpMethod in ReferenceImageCorrection::SetReferenceImages", __FILE__, __LINE__); + } + + +// std::cout << "before PrepareReferencesBB" << std::endl; +// kipl::io::WriteTIFF32(m_OB_BB_Interpolated,"ob_backgroundimage.tif"); // seem correct +// kipl::io::WriteTIFF32(m_DoseBBflat_image,"dose_bb.tif"); + PrepareReferencesBB(); + } + + if (useExtBB){ + m_bHaveExternalBlackBody = true; + PrepareReferencesExtBB(); + } + + if(!useBB && !useExtBB) { +// std::cout << "noBB option" << std::endl; + PrepareReferences(); // original way + } + + +} + +void ReferenceImageCorrection::SetInterpolationOrderX(eInterpOrderX eim_x){ + m_IntMeth_x = eim_x; + + switch(eim_x){ + + case(SecondOrder_x): + { b=1; + d=1; + e=1; + break; + } + case(FirstOrder_x): { + b=1; + d=1; + e=0; + break; + } + case(ZeroOrder_x): { + b=0; + d=0; + e=0; + break; + } + + } + +} + +void ReferenceImageCorrection::SetInterpolationOrderY(eInterpOrderY eim_y){ + m_IntMeth_y = eim_y; + + switch(eim_y){ + + case(SecondOrder_y):{ + c=1; + a=1; + f=1; + break; + } + case(FirstOrder_y):{ + c=1; + a=1; + f=0; + break; + } + case(ZeroOrder_y):{ + c=0; + a=0; + f=0; + } + + } + + +} + +kipl::base::TImage ReferenceImageCorrection::Process(kipl::base::TImage &img, float dose) +{ + if (m_bComputeLogarithm) { +// kipl::io::WriteTIFF32(img,"prelogimg.tif"); + ComputeLogNorm(img,dose); +// kipl::io::WriteTIFF32(img,"img.tif"); + } + else + ComputeNorm(img,dose); + + return img; + +} + +void ReferenceImageCorrection::Process(kipl::base::TImage &img, float *dose) +{ + kipl::base::TImage slice(img.Dims()); + + + for (size_t i=0; i, float>::const_iterator it = spline_sample_values.begin(); it != spline_sample_values.end(); ++it) +// { +// spline_values << it->first.first << " " << it->first.second << " " << it->second << std::endl; +// } + +// spline_values.close(); + + + m_BB_sample_Interpolated = InterpolateBlackBodyImagewithSplines(current_param, spline_sample_values, m_nROI); + m_DoseBBsample_image = InterpolateBlackBodyImagewithSplines(current_param, spline_sample_values, m_nDoseROI); +// if (i==0) kipl::io::WriteTIFF32(m_BB_sample_Interpolated,"background_sample.tif"); +// kipl::io::WriteTIFF32(m_BB_sample_Interpolated, ("background_sample_"+std::to_string(i)+".tif").c_str()); // now I save those for all! + delete[] current_param; + break; + } + default: throw ImagingException("Unknown m_InterpMethod in ReferenceImageCorrection::SetReferenceImages", __FILE__, __LINE__); + } + + + } + + if (m_bHaveExternalBlackBody){ + + if (m_BB_sample_ext.Size(2)!=img.Size(2)){ + throw ImagingException ("Number of externally processed BB images are not the same as Projection data",__FILE__,__LINE__); + } + m_BB_slice_ext.Resize(m_OB_BB_ext.Dims()); + memcpy(m_BB_slice_ext.GetDataPtr(),m_BB_sample_ext.GetLinePtr(0,i), sizeof(float)*m_BB_sample_ext.Size(0)*m_BB_sample_ext.Size(1)); + fdose_ext_slice = fdose_ext_list[i]; + } + + memcpy(slice.GetDataPtr(),img.GetLinePtr(0,i), sizeof(float)*slice.Size()); +// std::cout << "before Process: " << i << std::endl; + Process(slice,dose[i]); +// std::cout << "after process" << std::endl; + memcpy(img.GetLinePtr(0,i), slice.GetDataPtr(), sizeof(float)*slice.Size()); // and copy the result back + } + + +} + +void ReferenceImageCorrection::SegmentBlackBody(kipl::base::TImage &img, kipl::base::TImage &mask){ + + // 2. otsu threshold + // 2.a compute histogram + + + kipl::base::TImage norm(img.Dims()); + memcpy(norm.GetDataPtr(), img.GetDataPtr(), sizeof(float)*img.Size()); // copy to norm.. evalute if necessary + + std::vector> histo; + float min = *std::min_element(norm.GetLinePtr(0), norm.GetLinePtr(0)+norm.Size()); + float max = *std::max_element(norm.GetLinePtr(0), norm.GetLinePtr(0)+norm.Size()); + kipl::base::THistogram myhist(256, min, max); + histo = myhist(norm); + + + size_t * vec_hist = new size_t[256]; + for(int i=0; i<256; i++) + { + vec_hist[i] = histo.at(i).second; + } + + + //2.b compute otsu threshold + + float ot; + + if (bUseManualThresh) + { + ot = thresh; +// std::cout << "manual threshold " << ot << std::endl; + } + else + { + int value = kipl::segmentation::Threshold_Otsu(vec_hist, 256); + ot = static_cast(histo.at(value).first); +// std::cout << "otsu threshold " << ot << std::endl; + } + + + + //2.c threshold image + + kipl::base::TImage maskOtsu(mask.Dims()); + kipl::base::TImage labelImage(mask.Dims()); + + // now it works: +// kipl::segmentation::Threshold(norm.GetDataPtr(), maskOtsu.GetDataPtr(), norm.Size(), ot); + + float *pImg = norm.GetDataPtr(); + float *res = maskOtsu.GetDataPtr(); + const int N=static_cast(norm.Size()); + for (size_t i=0; i=ot){ + res[i] = 1; + } + else { + res[i] = 0; + } + } + +// kipl::io::WriteTIFF32(maskOtsu,"mask_Otsu.tif"); + + + float bg = 1.0f; + int num_obj = kipl::morphology::LabelImage(maskOtsu,labelImage, kipl::morphology::conn4, bg); + vector< pair< size_t, size_t > > area; + kipl::morphology::LabelArea(labelImage, num_obj, area); +// kipl::io::WriteTIFF(labelImage,"labelImage.tif"); + + if (num_obj==2 || area.at(1).first>=3*area.at(2).first) + { + throw ImagingException("SegmentBlackBodyNorm failed \n Please try to change the threshold ", __FILE__, __LINE__); + } + else + { + + + // 3. Compute mask within Otsu + // 3.a sum of rows and columns and location of rois + + + + float *vert_profile = new float[maskOtsu.Size(1)]; + float *hor_profile = new float[maskOtsu.Size(0)]; + + + kipl::base::VerticalProjection2D(maskOtsu.GetDataPtr(), maskOtsu.Dims(), vert_profile, true); // sum of rows + kipl::base::HorizontalProjection2D(maskOtsu.GetDataPtr(), maskOtsu.Dims(), hor_profile, true); // sum of columns + + + //3.b create binary Signal + float *bin_VP = new float[maskOtsu.Size(1)]; + float *bin_HP = new float[maskOtsu.Size(0)]; + + for (size_t i=0; i=1) { + pos_left[index_left] = i; + index_left++; + } + if (diff<=-1) { + pos_right[index_right]=i+1; // to have all BB within the rois + index_right++; + } + } + + + + // the same on the horizontal profile: + float *pos_left_2 = new float[100]; + float *pos_right_2 = new float[100]; + int index_left_2 = 0; + int index_right_2 = 0; + + + for (int i=0; i=1) { + pos_left_2[index_left_2] = i; + index_left_2++; + } + if (diff<=-1) { + pos_right_2[index_right_2]=i+1; + index_right_2++; + } + } + + + + // from these define ROIs containing BBs --> i can probably delete them later on + std::vector> right_edges((index_left)*(index_left_2)); + std::vector> left_edges((index_left)*(index_left_2)); + + int pos = 0; + for (int i=0; i<(index_left); i++) { + + for (int j=0; j<(index_left_2); j++) { + + right_edges.at(pos).first = pos_right[i]; // right position on vertical profiles = sum of rows = y axis = y1 + right_edges.at(pos).second = pos_right_2[j]; // right position on horizontal profiles = sum of columns = x axis = x1 + left_edges.at(pos).first = pos_left[i]; // left position on vertical profiles = y0 + left_edges.at(pos).second = pos_left_2[j]; // left position on horizontal profiles = x0 + +// std::cout << pos_right[i] << " " << pos_right_2[j] << " " << pos_left[i] << " " << pos_left_2[j] << std::endl; + pos++; + } + + } + + + + for (size_t bb_index=0; bb_index roi(roi_dim); + kipl::base::TImage roi_im(roi_dim); + + + for (int i=0; i=min_area) { + + + x_com /=sum_roi; + y_com /=sum_roi; + + for (size_t x=0; x &img, kipl::base::TImage &mask, std::map, float> &values) +{ + // 3. Compute mask within Otsu + // 3.a sum of rows and columns and location of rois + kipl::base::TImage maskOtsu(img.Dims()); + maskOtsu= 0.0f; + + std::map, float> new_values; + + float *p_mask = mask.GetDataPtr(); + float *p_otsu = maskOtsu.GetDataPtr(); + for (int i=0; i=1) { + pos_left[index_left] = i; + index_left++; + } + if (diff<=-1) { + pos_right[index_right]=i+1; // to have all BB within the rois + index_right++; + } + } + + // the same on the horizontal profile: + float *pos_left_2 = new float[100]; + float *pos_right_2 = new float[100]; + int index_left_2 = 0; + int index_right_2 = 0; + + + for (int i=0; i=1) { + pos_left_2[index_left_2] = i; + index_left_2++; + } + if (diff<=-1) { + pos_right_2[index_right_2]=i+1; + index_right_2++; + } + } + + + // from these define ROIs containing BBs --> i can probably delete them later on + std::vector> right_edges((index_left)*(index_left_2)); + std::vector> left_edges((index_left)*(index_left_2)); + + int pos = 0; + for (int i=0; i<(index_left); i++) { + + for (int j=0; j<(index_left_2); j++) { + + right_edges.at(pos).first = pos_right[i]; // right position on vertical profiles = sum of rows = y axis = y1 + right_edges.at(pos).second = pos_right_2[j]; // right position on horizontal profiles = sum of columns = x axis = x1 + left_edges.at(pos).first = pos_left[i]; // left position on vertical profiles = y0 + left_edges.at(pos).second = pos_left_2[j]; // left position on horizontal profiles = x0 + pos++; + } + + } + + +// std::cout << "pos: " << pos << std::endl; // it is the number of potential BBs that I have found: that one is correct, error comes later on +// ostringstream msg; +// msg.str(""); msg<<"pos= "<, float>::const_iterator it_values = values.begin(); + + for (size_t bb_index=0; bb_index=min_area) { //this is now wrong + + if (size!=0) { // check on BB existance + + +// x_com /=sum_roi; +// y_com /=sum_roi; + + std::pair temp; + temp = std::make_pair(floor(x_com+0.5)+left_edges.at(bb_index).second+m_diffBBroi[0], floor(y_com+0.5)+left_edges.at(bb_index).first+m_diffBBroi[1]); + + float value = 0.0f; + std::vector grayvalues; + float mean_value =0.0f; + +// std::cout << floor(x_com+0.5)+left_edges.at(bb_index).second+m_diffBBroi[0] << " " << floor(y_com+0.5)+left_edges.at(bb_index).first+m_diffBBroi[1] << std::endl; + + for (size_t x=0; x(grayvalues.size()); + + + roi(int(x_com+0.5), int(y_com+0.5))=2; + const auto median_it1 = grayvalues.begin() + grayvalues.size() / 2 - 1; + const auto median_it2 = grayvalues.begin() + grayvalues.size() / 2; + std::nth_element(grayvalues.begin(), median_it1 , grayvalues.end()); // e1 + std::nth_element(grayvalues.begin(), median_it2 , grayvalues.end()); // e2 + float median = (grayvalues.size() % 2 == 0) ? (*median_it1 + *median_it2) / 2 : *median_it2; + float average = accumulate(grayvalues.begin(), grayvalues.end(), 0.0)/ grayvalues.size(); + +// new_values.insert(std::make_pair(temp,median)); + std::pair mypair; + + for (std::map, float>::const_iterator it_values = values.begin(); it_values != values.end(); ++it_values) + { + float dist = (it_values->first.first-temp.first)*(it_values->first.first-temp.first)+(it_values->first.second-temp.second)*(it_values->first.second-temp.second); + if(dist<=100.0f) + { + mypair = std::make_pair(it_values->first.first, it_values->first.second); + mypair.first = it_values->first.first; + mypair.second = it_values->first.second; + values.at(mypair) = median; + break; + } +// mypair = std::make_pair(it_values->first.first, it_values->first.second); +// mypair.first = it_values->first.first; +// mypair.second = it_values->first.second; +// values.at(mypair) = median; + } + +// values.at(mypair) = mean_value; +// values.at(mypair) = average; +// logger(kipl::logging::Logger::LogMessage,"before insert"); +// new_values.insert(std::make_pair(temp, median)); +// logger(kipl::logging::Logger::LogMessage,"after insert"); +// ++it_values; + +// std::cout << mypair.first << " " << mypair.second << std::endl; + + } + + } + +// return new_values; + +// for (std::map, float>::const_iterator it = values.begin(); it != values.end(); ++it) +// { +// std::cout << it->first.first << " " << it->first.second << " " << it->second << std::endl; +// } + +// std::cout << "number of centroids found: " << values.size() << " " << std::endl; + +} + +void ReferenceImageCorrection::SegmentBlackBody(kipl::base::TImage &normimg, kipl::base::TImage &img, kipl::base::TImage &mask, std::map, float> &values) +{ + // 2. otsu threshold + // 2.a compute histogram + kipl::base::TImage norm(normimg.Dims()); + memcpy(norm.GetDataPtr(), normimg.GetDataPtr(), sizeof(float)*img.Size()); // copy to norm.. evalute if necessary + + std::vector> histo; + float min = *std::min_element(norm.GetLinePtr(0), norm.GetLinePtr(0)+norm.Size()); + float max = *std::max_element(norm.GetLinePtr(0), norm.GetLinePtr(0)+norm.Size()); + kipl::base::THistogram myhist(256, min, max); + histo = myhist(norm); + + + size_t * vec_hist = new size_t[256]; + for(int i=0; i<256; i++) + { + vec_hist[i] = histo.at(i).second; + } + + + //2.b compute otsu threshold + + + float ot; + + if (bUseManualThresh) + { + ot = thresh; +// std::cout << "manual threshold " << ot << std::endl; + } + else + { + int value = kipl::segmentation::Threshold_Otsu(vec_hist, 256); + ot = static_cast(histo.at(value).first); +// std::cout << "otsu threshold " << ot << std::endl; + } + + //2.c threshold image + + kipl::base::TImage maskOtsu(mask.Dims()); + kipl::base::TImage labelImage(mask.Dims()); + + // now it works: +// kipl::segmentation::Threshold(norm.GetDataPtr(), maskOtsu.GetDataPtr(), norm.Size(), ot); + + float *pImg = norm.GetDataPtr(); + float *res = maskOtsu.GetDataPtr(); + const int N=static_cast(norm.Size()); + for (size_t i=0; i=ot){ + res[i] = 1; + } + else { + res[i] = 0; + } + } + + float bg = 1.0f; + + int num_obj = kipl::morphology::LabelImage(maskOtsu,labelImage, kipl::morphology::conn4, bg); + + vector< pair< size_t, size_t > > area; + kipl::morphology::LabelArea(labelImage, num_obj, area); + + if (num_obj==2 || area.at(1).first>=3*area.at(2).first) + { + throw ImagingException("SegmentBlackBodyNorm failed \n Please try to change the threshold ", __FILE__, __LINE__); + } + else + { + + + // 3. Compute mask within Otsu + // 3.a sum of rows and columns and location of rois + + float *vert_profile = new float[maskOtsu.Size(1)]; + float *hor_profile = new float[maskOtsu.Size(0)]; + + + kipl::base::VerticalProjection2D(maskOtsu.GetDataPtr(), maskOtsu.Dims(), vert_profile, true); // sum of rows + kipl::base::HorizontalProjection2D(maskOtsu.GetDataPtr(), maskOtsu.Dims(), hor_profile, true); // sum of columns + + + //3.b create binary Signal + float *bin_VP = new float[maskOtsu.Size(1)]; + float *bin_HP = new float[maskOtsu.Size(0)]; + + for (size_t i=0; i=1) { + pos_left[index_left] = i; + index_left++; + } + if (diff<=-1) { + pos_right[index_right]=i+1; // to have all BB within the rois + index_right++; + } + } + + + // the same on the horizontal profile: + float *pos_left_2 = new float[100]; + float *pos_right_2 = new float[100]; + int index_left_2 = 0; + int index_right_2 = 0; + + + for (int i=0; i=1) { + pos_left_2[index_left_2] = i; + index_left_2++; + } + if (diff<=-1) { + pos_right_2[index_right_2]=i+1; + index_right_2++; + } + } + + + // from these define ROIs containing BBs --> i can probably delete them later on + std::vector> right_edges((index_left)*(index_left_2)); + std::vector> left_edges((index_left)*(index_left_2)); + + int pos = 0; + for (int i=0; i<(index_left); i++) { + + for (int j=0; j<(index_left_2); j++) { + + right_edges.at(pos).first = pos_right[i]; // right position on vertical profiles = sum of rows = y axis = y1 + right_edges.at(pos).second = pos_right_2[j]; // right position on horizontal profiles = sum of columns = x axis = x1 + left_edges.at(pos).first = pos_left[i]; // left position on vertical profiles = y0 + left_edges.at(pos).second = pos_left_2[j]; // left position on horizontal profiles = x0 + pos++; + } + + } + + + + for (size_t bb_index=0; bb_index roi(roi_dim); + kipl::base::TImage roi_im(roi_dim); + + + for (int i=0; i(size); + y_com /= static_cast(size); + + // float sum_roi = 0.0f; + + // // weighted center of mass: + // for (size_t x=0; x=min_area) { + + + // x_com /=sum_roi; + // y_com /=sum_roi; + + std::pair temp; + temp = std::make_pair(floor(x_com+0.5)+left_edges.at(bb_index).second+m_diffBBroi[0], floor(y_com+0.5)+left_edges.at(bb_index).first+m_diffBBroi[1]); + + float value = 0.0f; + std::vector grayvalues; + float mean_value =0.0f; + + for (size_t x=0; x(grayvalues.size()); + + + const auto median_it1 = grayvalues.begin() + grayvalues.size() / 2 - 1; + const auto median_it2 = grayvalues.begin() + grayvalues.size() / 2; + std::nth_element(grayvalues.begin(), median_it1 , grayvalues.end()); // e1 + std::nth_element(grayvalues.begin(), median_it2 , grayvalues.end()); // e2 + float median = (grayvalues.size() % 2 == 0) ? (*median_it1 + *median_it2) / 2 : *median_it2; // here I compute the median + float average = accumulate( grayvalues.begin(), grayvalues.end(), 0.0)/ grayvalues.size(); + values.insert(std::make_pair(temp,median)); +// values.insert(std::make_pair(temp,average)); + } + + } + + } +} + +void ReferenceImageCorrection::SetBBInterpRoi(size_t *roi){ + + memcpy(m_nBlackBodyROI,roi,sizeof(size_t)*4); +// std::cout << "black body roi: " << m_nBlackBodyROI[0] << " " << m_nBlackBodyROI[1] << " " << m_nBlackBodyROI[2] << " " +// << m_nBlackBodyROI[3] << std::endl; + +} + +void ReferenceImageCorrection::SetBBInterpDoseRoi(size_t *roi){ + memcpy(m_nDoseBBRoi, roi, sizeof(size_t)*4); +} + +float* ReferenceImageCorrection::ComputeInterpolationParameters(kipl::base::TImage&mask, kipl::base::TImage&img){ + + + std::map, float> values; + + + float mean_value = 0.0f; + int value_size = 0; + for (int x=0; x temp; + temp = std::make_pair(x+m_diffBBroi[0],y+m_diffBBroi[1]);// m_diffBBroi compensates for the relative position of BBroi in the images +// if (img(x,y)!=0) +// { + values.insert(std::make_pair(temp,img(x,y))); +// std::cout << " " << x << " " << y << " " << BB_DC(x,y) << std::endl; + mean_value +=img(x,y); + value_size++; +// } + + } + + } + + } + +// mean_value/=values.size(); + mean_value/=static_cast(value_size); + + // remove outliers if values to be interpolated are above mean +2std + + float std_dev = 0.0f; + + for (std::map, float>::const_iterator it = values.begin(); + it != values.end(); ++it) { + std_dev += (it->second-mean_value)*(it->second-mean_value); + } + + std_dev=sqrt(std_dev/values.size()); + + +// std::cout << "MEAN AND STD DEV: " << mean_value << " " << std_dev << std::endl; + +// for (std::map, float>::const_iterator it = values.begin(); +// it != values.end(); ++it) { + +// if(it->second >= (mean_value+2*std_dev)) { +// values.erase(it); // not sure it won't cause problems + +// } + +// } + + // this should be the correct way of removing element (STL book, page 205) + + for (std::map, float>::const_iterator it = values.begin(); it!= values.end(); ){ + if(it->second >= (mean_value+2*std_dev)){ + values.erase(it++); + } + else{ + ++it; + } + } + + float *myparam = new float[6]; + float error; + myparam = SolveLinearEquation(values, error); + + return myparam; + +} + +float* ReferenceImageCorrection::ComputeInterpolationParameters(kipl::base::TImage&mask, kipl::base::TImage&img, float &error){ + + // IMPORTANT! WHEN THE A SPECIFIC ROI IS SELECTED FOR THE BBs, THEN THE INTERPOLATION PARAMETERS NEED TO BE COMPUTED ON THE BIGGER IMAGE GRID + std::map, float> values; + + + // find values to interpolate + +// kipl::io::WriteTIFF32(mask, "mask.tif"); + + + float mean_value = 0.0f; + for (int x=0; x temp; + temp = std::make_pair(x+m_diffBBroi[0],y+m_diffBBroi[1]);// m_diffBBroi compensates for the relative position of BBroi in the images. now it should be in absolute coordinates + values.insert(std::make_pair(temp,img(x,y))); +// std::cout << " " << x << " " << y << " " << img(x,y) << std::endl; +// std::cout << m_diffBBroi[0] << " " << m_diffBBroi[1] << std::endl; +// std::cout << " " << x+m_diffBBroi[0] << " " << y+m_diffBBroi[1] << " " << img(x,y) << std::endl; + mean_value +=img(x,y); + + } + + } + + } + + mean_value/=values.size(); + + // remove outliers if values to be interpolated are above mean +2std + + float std_dev = 0.0f; + + for (std::map, float>::const_iterator it = values.begin(); + it != values.end(); ++it) { + std_dev += (it->second-mean_value)*(it->second-mean_value); + } + + std_dev=sqrt(std_dev/values.size()); + +//int outlier = 0; +// for (std::map, float>::const_iterator it = values.begin(); +// it != values.end(); ++it) { + +// if(it->second >= (mean_value+2*std_dev)) { +//// std::cout << "found outlier value" << std::endl; +//// std::cout << it->first.first << " " << it->first.second << " " << it->second << std::endl; +// values.erase(it); // not sure it won't cause problems +// outlier++; + +// } + +// } + + for (std::map, float>::const_iterator it = values.begin(); it!= values.end(); ){ + if(it->second >= (mean_value+2*std_dev)){ + values.erase(it++); + } + else{ + ++it; + } + } + +// ofstream int_points("poly_points.txt"); + +// for (std::map, float>::const_iterator it = values.begin(); +// it != values.end(); ++it) { + +// int_points << it->first.first << " " << it->first.second << " " << it->second << std::endl; + + +// } + + + + float *myparam = new float[6]; +// float error; + float my_error = 0.0f; + myparam = SolveLinearEquation(values, my_error); + error = my_error; + +// std::cout << "error in compute interpolation parameters: " << error << std::endl; + + return myparam; + +} + +float * ReferenceImageCorrection::SolveLinearEquation(std::map, float> &values, float &error){ + + + int matrix_size = 1 + ((d && a)+b+c+f+e); +// std::cout << "matrix_size: " << matrix_size << std::endl; + + Array2D< double > my_matrix(values.size(),matrix_size, 0.0); + Array1D< double > I(values.size(), 0.0); + Array1D< double > param(matrix_size, 0.0); + std::map, float>::const_iterator it = values.begin(); + +// std::cout << "TNT STUFF: " << std::endl; +// std::cout << my_matrix.dim1() << " " << my_matrix.dim2() << std::endl; + for (int x=0; xfirst.first; + my_matrix[x][2] = it->first.first*it->first.first; + my_matrix[x][3] = it->first.first*it->first.second; + my_matrix[x][4] = it->first.second; + my_matrix[x][5] = it->first.second*it->first.second; + } + if ((b && d && a && c) && (e==0) && (f==0)){ // first order X, first order Y + my_matrix[x][0] = 1; + my_matrix[x][1] = it->first.first; + my_matrix[x][2] = it->first.second; + my_matrix[x][3] = it->first.first*it->first.second; + + } + if (b==0 && a==0 && c==0 && d==0 && e==0 && f==0) { // zero order X, zero order Y + my_matrix[x][0] = 1; + } + + if ((b && d && e && c && a) && f==0 ) { // second order X, first order Y + my_matrix[x][0] = 1; + my_matrix[x][1] = it->first.first; + my_matrix[x][2] = it->first.first*it->first.first; + my_matrix[x][3] = it->first.first*it->first.second; + my_matrix[x][4] = it->first.second; + } + if ((b && d && e) && c==0 && a==0 && f==0 ) { // second order X, zero order Y + my_matrix[x][0] = 1; + my_matrix[x][1] = it->first.first; + my_matrix[x][2] = it->first.first*it->first.first; + } + + if ((b && c && d && a && f) && e==0){ // first order X, second order Y + my_matrix[x][0] = 1; + my_matrix[x][1] = it->first.first; + my_matrix[x][2] = it->first.first*it->first.second; + my_matrix[x][3] = it->first.second; + my_matrix[x][4] = it->first.second*it->first.second; + } + + if( (b && d) && a==0 && c==0 && e==0 && f==0){ //first order X, zero order Y + my_matrix[x][0] = 1; + my_matrix[x][1] = it->first.first; + } + + if (b==0 && d==0 && e==0 && (c && a && f)){ // zero order X, second order Y + my_matrix[x][0] = 1; +// my_matrix[x][1] = it->first.first; +// my_matrix[x][2] = it->first.first*it->first.first; +// my_matrix[x][3] = it->first.first*it->first.second; + my_matrix[x][1] = it->first.second; + my_matrix[x][2] = it->first.second*it->first.second; + } + + if ((c && a) && b==0 && d==0 && e==0 && f==0){ // zero order X, first order Y + my_matrix[x][0] = 1; + my_matrix[x][1] = it->first.second; + + } + + I[x] = static_cast(it->second); +// std::cout << it->first.first << " " << it->first.second << " " << it->second << "\n"; + + it++; + + } + + JAMA::QR qr(my_matrix); + param = qr.solve(I); + + + +// for (int i=0; i I_int(values.size(), 0.0); + + // here my param must be in the same order... + + + it = values.begin(); + for (int i=0; i(param[0]) + static_cast(param[1])*static_cast(it->first.first)+static_cast(param[2])*static_cast(it->first.first*it->first.first)+static_cast(param[3])*static_cast(it->first.first)*static_cast(it->first.second)+static_cast(param[4])*static_cast(it->first.second)+static_cast(param[5])*static_cast(it->first.second*it->first.second); + // img(x,y) = static_cast(param[0]) + static_cast(param[1])*static_cast(x)+static_cast(param[2])*static_cast(x)*static_cast(x)+static_cast(param[3])*static_cast(x)*static_cast(y)+static_cast(param[4])*static_cast(y)+static_cast(param[5])*static_cast(y)*static_cast(y); + // fill parameters in the right order: + + myparam[0] = static_cast(param[0]); // 0 + myparam[1] = static_cast(param[1]); // x + myparam[2] = static_cast(param[2]); // x^2 + myparam[3] = static_cast(param[3]); // xy + myparam[4] = static_cast(param[4]); // y + myparam[5] = static_cast(param[5]); // y^2 + +// I_int[i] = myparam[0] + myparam[1]*static_cast(it->first.first)+myparam[2]*static_cast(it->first.first*it->first.first)+myparam[3]*static_cast(it->first.first)*static_cast(it->first.second)+myparam[4]*static_cast(it->first.second)+myparam[5]*static_cast(it->first.second*it->first.second); + } + if ((b && d && a && c) && (e==0) && (f==0)){ +// I_int[i] = static_cast(param[0]) + static_cast(param[1])*static_cast(it->first.first)+static_cast(param[2])*static_cast(it->first.second)+static_cast(param[3])*static_cast(it->first.first)*static_cast(it->first.second); + + myparam[0] = static_cast(param[0]); // 0 + myparam[1] = static_cast(param[1]); // x +// myparam[2] = static_cast(param[2]); // x^2 + myparam[3] = static_cast(param[3]); // xy + myparam[4] = static_cast(param[2]); // y +// myparam[5] = static_cast(param[5]); // y^2 + } + if (b==0 && a==0 && c==0 && d==0 && e==0 && f==0) { +// I_int[i] = static_cast(param[0]); + myparam[0] = static_cast(param[0]); // 0 + } + if ((b && d && e && c && a) && f==0 ) { +// I_int[i] = static_cast(param[0]) + static_cast(param[1])*static_cast(it->first.first)+static_cast(param[2])*static_cast(it->first.first*it->first.first)+static_cast(param[3])*static_cast(it->first.first)*static_cast(it->first.second)+static_cast(param[4])*static_cast(it->first.second); + myparam[0] = static_cast(param[0]); // 0 + myparam[1] = static_cast(param[1]); // x + myparam[2] = static_cast(param[2]); // x^2 + myparam[3] = static_cast(param[3]); // xy + myparam[4] = static_cast(param[4]); // y + } + if ((b && d && e) && c==0 && a==0 && f==0 ) { +// I_int[i] = static_cast(param[0]) + static_cast(param[1])*static_cast(it->first.first)+static_cast(param[2])*static_cast(it->first.first*it->first.first); + myparam[0] = static_cast(param[0]); // 0 + myparam[1] = static_cast(param[1]); // x + myparam[2] = static_cast(param[2]); // x^2 + } + + if((b && c && d && a && f) && e==0){ +// I_int[i] = static_cast(param[0]) + static_cast(param[1])*static_cast(it->first.first)+static_cast(param[2])*static_cast(it->first.first*it->first.first)+static_cast(param[3])*static_cast(it->first.first)*static_cast(it->first.second)+static_cast(param[4])*static_cast(it->first.second)+static_cast(param[5])*static_cast(it->first.second*it->first.second); + // img(x,y) = static_cast(param[0]) + static_cast(param[1])*static_cast(x)+static_cast(param[2])*static_cast(x)*static_cast(x)+static_cast(param[3])*static_cast(x)*static_cast(y)+static_cast(param[4])*static_cast(y)+static_cast(param[5])*static_cast(y)*static_cast(y); + // fill parameters in the right order: + + myparam[0] = static_cast(param[0]); // 0 + myparam[1] = static_cast(param[1]); // x +// myparam[2] = static_cast(param[2]); // x^2 + myparam[3] = static_cast(param[2]); // xy + myparam[4] = static_cast(param[3]); // y + myparam[5] = static_cast(param[4]); // y^2 + } + + if( (b && d) && a==0 && c==0 && e==0 && f==0){ + myparam[0] = static_cast(param[0]); // 0 + myparam[1] = static_cast(param[1]); // x + } + + if (b==0 && d==0 && e==0 && (c && a && f)) { + myparam[0] = static_cast(param[0]); // 0 +// myparam[1] = static_cast(param[1]); // x +// myparam[2] = static_cast(param[2]); // x^2 +// myparam[3] = static_cast(param[2]); // xy + myparam[4] = static_cast(param[1]); // y + myparam[5] = static_cast(param[2]); // y^2 + + } + + if ((c && a) && b==0 && d==0 && e==0 && f==0) { + myparam[0] = static_cast(param[0]); // 0 + myparam[4] = static_cast(param[1]); // y + + } + + + + I_int[i] = myparam[0] + myparam[1]*static_cast(it->first.first)+myparam[2]*static_cast(it->first.first*it->first.first)+myparam[3]*static_cast(it->first.first)*static_cast(it->first.second)+myparam[4]*static_cast(it->first.second)+myparam[5]*static_cast(it->first.second*it->first.second); + ++it; + } + + + error = 0.0f; + + for (int i=0; i,float> &values) { + + + + //1. create system matrix, dimension of the matrix depends on the number of BB found + float *param = new float[values.size()+3]; + + Array2D< double > my_matrix(values.size()+3,values.size()+3, 0.0); + Array1D< double > b_vector(values.size()+3, 0.0); + Array1D< double > qr_param(values.size()+3, 0.0); + + + std::map, float>::const_iterator it_i = values.begin(); + for (int i=0; i, float>::const_iterator it_j = values.begin(); + for (int j=0; j(it_i->first.first); + float ii_2 = static_cast(it_i->first.second); + float jj_1 = static_cast(it_j->first.first); + float jj_2 = static_cast(it_j->first.second); + float dist = sqrt((ii_1-jj_1)*(ii_1-jj_1)+(ii_2-jj_2)*(ii_2-jj_2)); + // float dist = sqrt((it_i->first.first-it_j->first.first)*(it_i->first.first-it_j->first.first)+(it_i->first.second-it_j->first.second)*(it_i->first.second-it_j->first.second)); +// float dist = sqrt((values.at(i).first.first-values.at(j).first.first)*(values.at(i).first.first-values.at(j).first.first)+(values.at(i).first.second-values.at(j).first.second)*(values.at(i).first.second-values.at(j).first.second)); // does not work like this... + my_matrix[i][j] = dist*dist*log(dist); + + } + ++it_j; + + + } + + ++it_i; + } + + it_i = values.begin(); + for (int i=0; ifirst.second; // y + my_matrix[i][values.size()+2] = it_i->first.first; // x + ++it_i; + } + + it_i = values.begin(); + for (int i=0; ifirst.second; // y + my_matrix[values.size()+2][i] = it_i->first.first; // x + ++it_i; + } + + int i=0; + for (it_i = values.begin(); it_i!=values.end(); ++it_i){ + b_vector[i] = it_i->second; + ++i; + } + +// JAMA::QR qr(my_matrix); +// qr_param = my_matrix.solve(b_vector); // crashed with QR + + JAMA::SVD svd(my_matrix); + Array2D< double > U(values.size()+3,values.size()+3, 0.0); + Array2D< double > V(values.size()+3,values.size()+3, 0.0); + Array1D< double > S(values.size()+3, 0.0); + + svd.getU(U); + svd.getV(V); + svd.getSingularValues(S); + + TNT::Array2D Utran(U.dim1(), U.dim2()); + for(int r=0; r Si(U.dim1(), U.dim2(), 0.0); + for (int i=0; i inv_matrix(my_matrix.dim1(), my_matrix.dim2()); + inv_matrix = matmult(matmult(V,Si),Utran); + + + for (int i=0;i(qr_param[i]); +// std::cout << param[i] << " "; + } + +// std::cout << std::endl; + + return param; + +} + +kipl::base::TImage ReferenceImageCorrection::InterpolateBlackBodyImagewithSplines(float *parameters, std::map, float> &values, size_t *roi){ + + + + size_t dimx = roi[2]-roi[0]; + size_t dimy = roi[3]-roi[1]; + + + size_t dims[2] = {dimx,dimy}; + kipl::base::TImage interpolated_img(dims); + interpolated_img = 0.0f; + + float sumdist; + std::map, float>::const_iterator it_i; + + for (size_t x=0; xfirst.first-(x+roi[0]))*(it_i->first.first-(x+roi[0]))+(it_i->first.second-(y+roi[1]))*(it_i->first.second-(y+roi[1]))); + if (dist[ind]!=0){ + sumdist += (0.5*dist[ind]*log(dist[ind])*parameters[ind]); // correct? } + } + + ++it_i; + } + + delete [] dist; + + interpolated_img(x,y) = sumdist+parameters[values.size()]+parameters[values.size()+1]*(y+roi[1])+parameters[values.size()+2]*(x+roi[0]); + } + } + + return interpolated_img; + + + + +} + +kipl::base::TImage ReferenceImageCorrection::InterpolateBlackBodyImage(float *parameters, size_t *roi) { + + + size_t dimx = roi[2]-roi[0]; + size_t dimy = roi[3]-roi[1]; + + size_t dims[2] = {dimx,dimy}; + kipl::base::TImage interpolated_img(dims); + interpolated_img = 0.0f; + + for (size_t x=0; x(x+roi[0])+parameters[2]*static_cast(x+roi[0])*static_cast(x+roi[0])+parameters[3]*static_cast(x+roi[0])*static_cast(y+roi[1])+parameters[4]*static_cast(y+roi[1])+parameters[5]*static_cast(y+roi[1])*static_cast(y+roi[1]); + } + } + + return interpolated_img; + +} + +float ReferenceImageCorrection::ComputeInterpolationError(kipl::base::TImage&interpolated_img, kipl::base::TImage&mask, kipl::base::TImage&img) { + + float error = 0.0f; + int nValues = 0; + + for(size_t ind=0; ind(img.Size()); ind++) + { + if (mask(ind)!=0) { + error += ((interpolated_img(ind)-img(ind))/interpolated_img(ind))*((interpolated_img(ind)-img(ind))/interpolated_img(ind)); + nValues++; + } + } + + error = sqrt(1/float(nValues)*error); + + return error; + +} + +float * ReferenceImageCorrection::PrepareBlackBodyImage(kipl::base::TImage &flat, kipl::base::TImage &dark, kipl::base::TImage &bb, kipl::base::TImage &mask) +{ + + // 1. normalize image + + kipl::base::TImage norm(bb.Dims()); + kipl::base::TImage normdc(bb.Dims()); + memcpy(norm.GetDataPtr(),bb.GetDataPtr(), sizeof(float)*bb.Size()); + memcpy(normdc.GetDataPtr(),bb.GetDataPtr(), sizeof(float)*bb.Size()); + + normdc -=dark; + + norm -=dark; + norm /= (flat-=dark); + +// std::map, float> values; +// kipl::io::WriteTIFF32(norm,"normBB.tif"); +// kipl::io::WriteTIFF32(bb,"BB.tif"); +// kipl::io::WriteTIFF32(flat,"openBB.tif"); + + try{ + SegmentBlackBody(norm, mask); +// SegmentBlackBody(norm, normdc, mask, values); // try for thin plates spline + } + catch (...) { + throw ImagingException("SegmentBlackBodyNorm failed", __FILE__, __LINE__); + } + +// kipl::io::WriteTIFF32(mask,"mask.tif"); + + kipl::base::TImage BB_DC(bb.Dims()); + memcpy(BB_DC.GetDataPtr(), bb.GetDataPtr(), sizeof(float)*bb.Size()); + BB_DC-=dark; + + kipl::base::TImage interpolated_BB(bb.Dims()); + interpolated_BB = 0.0f; + + float * param = new float[6]; + param = ComputeInterpolationParameters(mask,BB_DC); + + return param; + +} + +float *ReferenceImageCorrection::PrepareBlackBodyImagewithSplines(kipl::base::TImage &flat, kipl::base::TImage &dark, kipl::base::TImage &bb, kipl::base::TImage &mask, std::map, float> &values) +{ + // 1. normalize image + + + + kipl::base::TImage norm(bb.Dims()); + kipl::base::TImage normdc(bb.Dims()); + memcpy(norm.GetDataPtr(),bb.GetDataPtr(), sizeof(float)*bb.Size()); + memcpy(normdc.GetDataPtr(),bb.GetDataPtr(), sizeof(float)*bb.Size()); + + normdc -=dark; + norm -=dark; + norm /= (flat-=dark); + + try{ + SegmentBlackBody(norm, normdc, mask, values); +// kipl::io::WriteTIFF32(mask, "maskSpline.tif"); + } + catch (...) { + throw ImagingException("SegmentBlackBodyNorm failed", __FILE__, __LINE__); + } + + float *tps_param = new float[values.size()+3]; + tps_param = SolveThinPlateSplines(values); + + + return tps_param; + +} + +float *ReferenceImageCorrection::PrepareBlackBodyImagewithSplinesAndMask(kipl::base::TImage &dark, kipl::base::TImage &bb, kipl::base::TImage &mask, std::map, float> &values) +{ + + kipl::base::TImage BB_DC(bb.Dims()); + memcpy(BB_DC.GetDataPtr(), bb.GetDataPtr(), sizeof(float)*bb.Size()); + BB_DC-=dark; + +// std::cout << "before ComputeBlackBodyCentroids(BB_DC,mask, values); in PrepareBlackBodyImagewithSplinesAndMask "<< std::endl; + + ComputeBlackBodyCentroids(BB_DC,mask, values); + + float *tps_param = new float[values.size()+3]; +// std::cout << "before SolveThinPlateSplines(values); in PrepareBlackBodyImagewithSplinesAndMask "<< std::endl; + tps_param = SolveThinPlateSplines(values); + +// std::cout << "after SolveThinPlateSplines(values); in PrepareBlackBodyImagewithSplinesAndMask "<< std::endl; + return tps_param; +} + +float * ReferenceImageCorrection::PrepareBlackBodyImage(kipl::base::TImage &flat, kipl::base::TImage &dark, kipl::base::TImage &bb, kipl::base::TImage &mask, float &error) +{ + + + // 1. normalize image + + kipl::base::TImage norm(bb.Dims()); + kipl::base::TImage normdc(bb.Dims()); + memcpy(norm.GetDataPtr(),bb.GetDataPtr(), sizeof(float)*bb.Size()); + memcpy(normdc.GetDataPtr(),bb.GetDataPtr(), sizeof(float)*bb.Size()); + + normdc -=dark; + norm -=dark; + norm /= (flat-=dark); + + try{ + SegmentBlackBody(norm, mask); + } + catch (...) { + throw ImagingException("SegmentBlackBodyNorm failed", __FILE__, __LINE__); + } + + + kipl::base::TImage BB_DC(bb.Dims()); + memcpy(BB_DC.GetDataPtr(), bb.GetDataPtr(), sizeof(float)*bb.Size()); + BB_DC-=dark; + + kipl::base::TImage interpolated_BB(bb.Dims()); + interpolated_BB = 0.0f; + + float * param = new float[6]; + float myerror; + + param = ComputeInterpolationParameters(mask,BB_DC,myerror); + error = myerror; + + + return param; + +} + +float * ReferenceImageCorrection::PrepareBlackBodyImagewithMask(kipl::base::TImage &dark, kipl::base::TImage &bb, kipl::base::TImage &mask){ + + kipl::base::TImage BB_DC(bb.Dims()); + memcpy(BB_DC.GetDataPtr(), bb.GetDataPtr(), sizeof(float)*bb.Size()); + BB_DC-=dark; + +// kipl::base::TImage interpolated_BB(bb.Dims()); +// interpolated_BB = 0.0f; + + float * param = new float[6]; + param = ComputeInterpolationParameters(mask,BB_DC); + + return param; + +} + +void ReferenceImageCorrection::SetAngles(float *ang, size_t nProj, size_t nBB){ + angles[0] = ang[0]; + angles[1] = ang[1]; + angles[2] = ang[2]; + angles[3] = ang[3]; + + m_nProj = nProj; // to set eventually around where it is used + m_nBBimages = nBB; + + +} + +void ReferenceImageCorrection::SetDoseList(float *doselist){ + + if (m_nProj!=0) { + dosesamplelist = new float[m_nProj]; + memcpy(dosesamplelist, doselist, sizeof(float)*m_nProj); + } + else { + throw ImagingException("m_nProj was not set before calling ReferenceImageCorrection::SetDoseList",__FILE__,__LINE__); + } + +} + +void ReferenceImageCorrection::SetSplinesParameters(float *ob_parameter, float *sample_parameter, size_t nBBSampleCount, size_t nProj, eBBOptions ebo, int nBBs) +{ + m_nProj = nProj; // not very smartly defined + ob_bb_parameters = new float[nBBs+3]; + sample_bb_interp_parameters = new float[(nBBs+3)*m_nProj]; + + m_nBBimages = nBBSampleCount; // store how many images with BB and sample i do have + memcpy(ob_bb_parameters, ob_parameter, sizeof(float)*(nBBs+3)); +// for (size_t i=0; i=*big_a){ // se esco dal range incremento di 1 + + + + if(curr_angle>=bb_angles[m_nBBimages-1]) { + + if (*big_a==bb_angles[m_nBBimages-1]) { // if pointers have not been modified yes, change the index, otherwise keep them as they are + index_1=index_2; + index_2 =0; + } + + small_a = &bb_angles[m_nBBimages-1]; + big_a = &bb_angles[0]; + step = (curr_angle-*small_a)/(360.0f-*small_a); + + + + } + else { + + index_1=index_2; + index_2 +=(nBBs+3); + + small_a++; + big_a++; + } + } + + + + + } + + delete [] bb_angles; + + return interpolated_param; +} + +float* ReferenceImageCorrection::InterpolateParametersGeneric(float* param){ + + // it is assumed that angles are in order + float *interpolated_param = new float[6*m_nProj]; + float curr_angle; + float *small_a; + float *big_a; + float *bb_angles = new float[m_nBBimages]; + float step; + int index_1; + int index_2; + + + for (size_t i=0; i=*big_a){ // se esco dal range incremento di 1 + + + + if(curr_angle>=bb_angles[m_nBBimages-1]) { + + if (*big_a==bb_angles[m_nBBimages-1]) { // if pointers have not been modified yes, change the index, otherwise keep them as they are + index_1=index_2; + index_2 =0; + } + + small_a = &bb_angles[m_nBBimages-1]; + big_a = &bb_angles[0]; + step = (curr_angle-*small_a)/(360.0f-*small_a); + + + + } + else { + + index_1=index_2; + index_2 +=6; + + small_a++; + big_a++; + } + } + + + + + } + + delete [] bb_angles; + + return interpolated_param; + + +} + +float* ReferenceImageCorrection::InterpolateParameters(float *param, size_t n, size_t step){ + + float *interpolated_param = new float[6*(n+1)]; +// float *int_param = new float[6*n]; + + // first copy the one that i already have + size_t index = 0; + for (size_t i=0; i<6*n; i+=step*6){ + memcpy(interpolated_param+i, param+index, sizeof(float)*6); + index +=6; + + } + + memcpy(interpolated_param+6*n, param, sizeof(float)*6); // copio i primi in coda + + + for (size_t i=0; i<6*n; i+=step*6){ + index=i; + + for (size_t j=1; j(m_OpenBeam.Size()); + float *pFlat=m_OpenBeam.GetDataPtr(); + float *pDark=m_DarkCurrent.GetDataPtr(); + +// kipl::io::WriteTIFF32(m_OpenBeam,"prepare_ob.tif"); +// kipl::io::WriteTIFF32(m_DarkCurrent,"prepare_dc.tif"); + + + if (!m_bHaveBlackBody) { + + if (m_bHaveDarkCurrent) { + #pragma omp parallel for + for (int i=0; i(m_OpenBeam.Size()); + float *pFlat=m_OpenBeam.GetDataPtr(); + float *pDark=m_DarkCurrent.GetDataPtr(); + + float dose; + float Pdose = 0.0f; + + float *pFlatBB = m_OB_BB_Interpolated.GetDataPtr(); + + // set here the PB variante... + if(bPBvariante){ + + Pdose = computedose(m_DoseBBflat_image); + dose = 1.0f/(m_fOpenBeamDose-m_fDarkDose-Pdose); + + } + else { + dose = 1.0f/(m_fOpenBeamDose-m_fDarkDose); + } + + + if (m_bHaveDarkCurrent) { + #pragma omp parallel for + for (int i=0; i(m_OpenBeam.Size()); + float *pFlat=m_OpenBeam.GetDataPtr(); + float *pDark=m_DarkCurrent.GetDataPtr(); + + float dose=1.0f/(m_fOpenBeamDose-m_fDarkDose-fdoseOB_ext); + + float *pFlatBB = m_OB_BB_ext.GetDataPtr(); + + + if (m_bHaveDarkCurrent) { + #pragma omp parallel for + for (int i=0; i &img, float dose) +{ + + float Pdose = 0.0f; + + float defaultdose=-log(1.0f/(m_fOpenBeamDose-m_fDarkDose)); +// float defaultdose= 0.0f; + + +// float logdose = log(dose<1 ? 1.0f : dose); + + + int N=static_cast(img.Size(0)*img.Size(1)); + + float *pFlat=m_OpenBeam.GetDataPtr(); + float *pDark=m_DarkCurrent.GetDataPtr(); + + + if (m_bHaveBlackBody) { + if (m_bHaveDarkCurrent) { + + + if (m_bHaveOpenBeam) { + // #pragma omp parallel for firstprivate(pFlat,pDark) + + float *pImg=img.GetDataPtr(); + float *pImgBB = m_BB_sample_Interpolated.GetDataPtr(); + + if(bPBvariante){ + Pdose = computedose(m_DoseBBsample_image); + } + + #pragma omp parallel for firstprivate(pImgBB, pFlat, pDark) + for (int i=0; i &img, float dose) +{ + +// dose = dose - m_fDarkDose; + float Pdose = 0.0f; + + + +// float logdose = log(dose<1 ? 1.0f : dose); + + int N=static_cast(img.Size(0)*img.Size(1)); + + float *pFlat=m_OpenBeam.GetDataPtr(); + float *pDark=m_DarkCurrent.GetDataPtr(); + + + if (m_bHaveBlackBody) { + if (m_bHaveDarkCurrent) { + + + if (m_bHaveOpenBeam) { + // #pragma omp parallel for firstprivate(pFlat,pDark) + + float *pImg=img.GetDataPtr(); + float *pImgBB = m_BB_sample_Interpolated.GetDataPtr(); + + if(bPBvariante){ + Pdose = computedose(m_DoseBBsample_image); + } // for now I assume I have all images.. other wise makes no much sense + + + + + + #pragma omp parallel for firstprivate(pImgBB, pDark, pFlat) + for (int i=0; i &img){ + + float *pImg=img.GetDataPtr(); + float *means=new float[img.Size(1)]; + memset(means,0,img.Size(1)*sizeof(float)); + + for (size_t y=0; y(img.Size(0)); + } + + float dose; + kipl::math::median(means,img.Size(1),&dose); + delete [] means; + return dose; + +} + +void ReferenceImageCorrection::SetExternalBBimages(kipl::base::TImage &bb_ext, kipl::base::TImage &bb_sample_ext, float &dose, float *doselist){ + + m_OB_BB_ext.Resize(bb_ext.Dims()); + m_BB_sample_ext.Resize(bb_sample_ext.Dims()); + memcpy(m_OB_BB_ext.GetDataPtr(), bb_ext.GetDataPtr(), sizeof(float)*bb_ext.Size()); + memcpy(m_BB_sample_ext.GetDataPtr(), bb_sample_ext.GetDataPtr(), sizeof(float)*bb_sample_ext.Size()); + + // kipl::io::WriteTIFF32(m_OB_BB_ext,"m_OB_BB_ext.tif"); + +// kipl::base::TImage slice(m_OB_BB_ext.Dims()); +// memcpy(slice.GetDataPtr(),m_BB_sample_ext.GetLinePtr(0,0), sizeof(float)*bb_ext.Size()); +// kipl::io::WriteTIFF32(slice,"slice.tif"); + + fdoseOB_ext = dose; + fdose_ext_list = new float[bb_sample_ext.Size(2)]; + memcpy(fdose_ext_list, doselist, sizeof(float)*bb_sample_ext.Size(2)); + +} + +} + + + + + +void string2enum(std::string str, ImagingAlgorithms::ReferenceImageCorrection::eReferenceMethod &erm) +{ + std::map methods; + methods["LogNorm"] = ImagingAlgorithms::ReferenceImageCorrection::ReferenceLogNorm; + methods["Norm"] = ImagingAlgorithms::ReferenceImageCorrection::ReferenceNorm; // to be updated with more options + + if (methods.count(str)==0) + throw ImagingException("The key string does not exist for eReferenceMethod",__FILE__,__LINE__); + + erm=methods[str]; + + +} + +std::string enum2string(const ImagingAlgorithms::ReferenceImageCorrection::eReferenceMethod &erm) +{ + std::string str; + + switch (erm) { + case ImagingAlgorithms::ReferenceImageCorrection::ReferenceLogNorm: str="LogNorm"; break; + case ImagingAlgorithms::ReferenceImageCorrection::ReferenceNorm: str="Norm"; break; + default: throw ImagingException("Unknown reference method in enum2string for eReferenceMethod",__FILE__,__LINE__); + } + return str; + +} + +std::ostream & operator<<(ostream & s, ImagingAlgorithms::ReferenceImageCorrection::eReferenceMethod erm) +{ + s< bb_options; + bb_options["noBB"] = ImagingAlgorithms::ReferenceImageCorrection::eBBOptions::noBB; + bb_options["Interpolate"] = ImagingAlgorithms::ReferenceImageCorrection::eBBOptions::Interpolate; + bb_options["Average"] = ImagingAlgorithms::ReferenceImageCorrection::eBBOptions::Average; + bb_options["OneToOne"] = ImagingAlgorithms::ReferenceImageCorrection::eBBOptions::OneToOne; + bb_options["ExternalBB"] = ImagingAlgorithms::ReferenceImageCorrection::eBBOptions::ExternalBB; + + if (bb_options.count(str)==0) + throw ImagingException("The key string does not exist for eBBOptions",__FILE__,__LINE__); + + ebo=bb_options[str]; + + +} + +std::string enum2string(const ImagingAlgorithms::ReferenceImageCorrection::eBBOptions &ebo) +{ + std::string str; + + switch (ebo) { + case ImagingAlgorithms::ReferenceImageCorrection::noBB: str="noBB"; break; + case ImagingAlgorithms::ReferenceImageCorrection::Interpolate: str="Interpolate"; break; + case ImagingAlgorithms::ReferenceImageCorrection::Average: str="Average"; break; + case ImagingAlgorithms::ReferenceImageCorrection::OneToOne: str="OneToOne"; break; + case ImagingAlgorithms::ReferenceImageCorrection::ExternalBB: str="ExternalBB"; break; + default : return "Undefined BB option"; break; + } + return str; + +} + +std::ostream & operator<<(ostream & s, ImagingAlgorithms::ReferenceImageCorrection::eBBOptions ebo) +{ + s< int_methods; + int_methods["SecondOrder"] = ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderX::SecondOrder_x; + int_methods["FirstOrder"] = ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderX::FirstOrder_x; + int_methods["ZeroOrder"] = ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderX::ZeroOrder_x; + + if (int_methods.count(str)==0) + throw ImagingException("The key string does not exist for eInterpMethod",__FILE__,__LINE__); + + eim_x=int_methods[str]; + + +} + +std::string enum2string(const ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderX &eim_x) +{ + std::string str; + + switch (eim_x) { + case ImagingAlgorithms::ReferenceImageCorrection::SecondOrder_x: str="SecondOrder"; break; + case ImagingAlgorithms::ReferenceImageCorrection::FirstOrder_x: str="FirstOrder"; break; + case ImagingAlgorithms::ReferenceImageCorrection::ZeroOrder_x: str="ZeroOrder"; break; + default : return "Undefined Interpolation method"; break; + } + return str; + +} + +std::ostream & operator<<(ostream & s, ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderX eim_x) +{ + s< int_methods; + int_methods["SecondOrder"] = ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderY::SecondOrder_y; + int_methods["FirstOrder"] = ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderY::FirstOrder_y; + int_methods["ZeroOrder"] = ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderY::ZeroOrder_y; + + if (int_methods.count(str)==0) + throw ImagingException("The key string does not exist for eInterpMethod",__FILE__,__LINE__); + + eim_y=int_methods[str]; + + +} + +std::string enum2string(const ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderY &eim_y) +{ + std::string str; + + switch (eim_y) { + case ImagingAlgorithms::ReferenceImageCorrection::SecondOrder_y: str="SecondOrder"; break; + case ImagingAlgorithms::ReferenceImageCorrection::FirstOrder_y: str="FirstOrder"; break; + case ImagingAlgorithms::ReferenceImageCorrection::ZeroOrder_y: str="ZeroOrder"; break; + default : return "Undefined Interpolation method"; break; + } + return str; + +} + +std::ostream & operator<<(ostream & s, ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderY eim_y) +{ + s< int_types; + int_types["Polynomial"] = ImagingAlgorithms::ReferenceImageCorrection::eInterpMethod::Polynomial; + int_types["ThinPlateSplines"] = ImagingAlgorithms::ReferenceImageCorrection::eInterpMethod::ThinPlateSplines; + + if (int_types.count(str)==0) + throw ImagingException("The key string does not exist for eInterpMethod",__FILE__,__LINE__); + + eint=int_types[str]; + + +} + +std::string enum2string(const ImagingAlgorithms::ReferenceImageCorrection::eInterpMethod &eint) +{ + std::string str; + + switch (eint) { + case ImagingAlgorithms::ReferenceImageCorrection::Polynomial: str="Polynomial"; break; + case ImagingAlgorithms::ReferenceImageCorrection::ThinPlateSplines: str="ThinPlateSplines"; break; + default : return "Undefined Interpolation method"; break; + } + return str; + +} + +std::ostream & operator<<(ostream & s, ImagingAlgorithms::ReferenceImageCorrection::eInterpMethod eint) +{ + s< + +#include +#include + +#include + #include "resolutionestimators.h" +#include +#include +#include + namespace ImagingQAAlgorithms { +Nonlinear::SumOfGaussians sog_dummy(1); -ResolutionEstimators::ResolutionEstimators() : - profileFunction(ResolutionEstimators::LorenzProfile), - pixelSize(0.1f), +ResolutionEstimator::ResolutionEstimator() : + profileFunction(Nonlinear::fnSumOfGaussians), profileSize(0), - dx(1.0f), - profile(nullptr) + pixelSize(0.1), + profile(nullptr), + dprofile(nullptr), + xaxis(nullptr), + fwhm(-1.0), + fn(sog_dummy) { } -ResolutionEstimators::~ResolutionEstimators() +ResolutionEstimator::~ResolutionEstimator() { removeAllocation(); } +void ResolutionEstimator::setPixelSize(double s) +{ + pixelSize=fabs(s); +} -void ResolutionEstimators::setProfile(float *p, int N, float d) +double ResolutionEstimator::getPixelSize() { + return pixelSize; +} +void ResolutionEstimator::setProfile(float *p, int N, double d) +{ + (void)d; + createAllocation(N); + std::copy_n(p,N,profile); + analysis(); } -float ResolutionEstimators::getFWHM() +void ResolutionEstimator::setProfile(double *p, int N, double d) { - return -1.0f; + (void)d; + createAllocation(N); + std::copy_n(p,N,profile); + analysis(); } -float ResolutionEstimators::getMTFresolution(float level) +void ResolutionEstimator::setProfile(std::vector &p, double d) { - return -1.0f; + (void)d; + size_t N=p.size(); + createAllocation(N); + for (size_t i=0; i > ResolutionEstimators::getEdgeDerivative(float smooth) +void ResolutionEstimator::setProfile(std::vector &p, double d) { - vector > d; + (void)d; + size_t N=p.size(); + createAllocation(N); + for (size_t i=0; i &p, double d) +{ + (void)d; + size_t N=p.dim1(); + createAllocation(N); + for (size_t i=0; i > ResolutionEstimators::getMTF() +float ResolutionEstimator::getMTFresolution(float level) +{ + (void)level; + + return -1.0f; +} + +void ResolutionEstimator::getEdgeDerivative(std::vector &x, std::vector &y, bool returnFit, float smooth) +{ + (void) smooth; + x.clear(); + y.clear(); + if (returnFit==true) { + for (int i=0; i &w, std::vector &a) { - vector > d; - return d; } -void ResolutionEstimators::createAllocation(int N) +void ResolutionEstimator::createAllocation(int N) { removeAllocation(); - profile=new float[N]; + profile=new double[N]; + dprofile=new double[N]; + xaxis=new double[N]; profileSize=N; } -void ResolutionEstimators::removeAllocation() +void ResolutionEstimator::removeAllocation() { if (profile!=nullptr) { delete [] profile; + profile=nullptr; profileSize=0; } + + if (dprofile!=nullptr) { + delete [] dprofile; + dprofile=nullptr; + } + + if (xaxis!=nullptr) { + delete [] xaxis; + xaxis=nullptr; + } } + +void ResolutionEstimator::prepareXAxis() +{ + for (int i=0; i x(profileSize); + TNT::Array1D y(profileSize); + TNT::Array1D sig(profileSize); + + for (int i=0; i +#include +#include +#include + #include +#include namespace ImagingQAAlgorithms { -class IMAGINGQAALGORITHMSSHARED_EXPORT ResolutionEstimators +class IMAGINGQAALGORITHMSSHARED_EXPORT ResolutionEstimator { public: - enum eProfileFunction { - GaussProfile, - LorenzProfile, - VoightProfile - }; - ResolutionEstimators(); - ~ResolutionEstimators(); + ResolutionEstimator(); + ~ResolutionEstimator(); - eProfileFunction profileFunction; - float pixelSize; + Nonlinear::eProfileFunction profileFunction; - void setProfile(float *p, int N, float d=1.0f); + void setPixelSize(double s); + double getPixelSize(); + void setProfile(float *p, int N, double d=1.0f); + void setProfile(double *p, int N, double d=1.0f); + void setProfile(std::vector &p, double d=1.0); + void setProfile(std::vector &p, double d=1.0); + void setProfile(TNT::Array1D &p, double d=1.0); float getFWHM(); float getMTFresolution(float level=0.1f); - vector > getEdgeDerivative(float smooth=0.0f); - vector > getMTF(); + void getEdgeDerivative(std::vector &x, std::vector &y, bool returnFit=false, float smooth=0.0f); + void getMTF(std::vector &w, std::vector &a); protected: void createAllocation(int N); void removeAllocation(); + void prepareXAxis(); + void analysis(); + void analyzeLineSpread(); + void analyzeMTF(); + void diffProfile(); int profileSize; - float dx; - float *profile; + double pixelSize; + double *profile; + double *dprofile; + double *xaxis; + double fwhm; + Nonlinear::FitFunctionBase &fn; }; } + + + #endif // RESOLUTIONESTIMATORS_H diff --git a/core/algorithms/UnitTests/tImagingQAAlgorithms/tst_timagingqaalgorithmstest.cpp b/core/algorithms/UnitTests/tImagingQAAlgorithms/tst_timagingqaalgorithmstest.cpp index dcc955987..e6e4c4f9b 100644 --- a/core/algorithms/UnitTests/tImagingQAAlgorithms/tst_timagingqaalgorithmstest.cpp +++ b/core/algorithms/UnitTests/tImagingQAAlgorithms/tst_timagingqaalgorithmstest.cpp @@ -10,6 +10,7 @@ #include #include +#include class TImagingQAAlgorithmsTest : public QObject { @@ -20,6 +21,8 @@ class TImagingQAAlgorithmsTest : public QObject private Q_SLOTS: void testContrastSampleAnalysis(); + void testResEstAdmin(); + void testResEstAlg(); }; TImagingQAAlgorithmsTest::TImagingQAAlgorithmsTest() @@ -58,6 +61,13 @@ void TImagingQAAlgorithmsTest::testContrastSampleAnalysis() } + + +void TImagingQAAlgorithmsTest::testResEstAlg() +{ + +} + QTEST_APPLESS_MAIN(TImagingQAAlgorithmsTest) #include "tst_timagingqaalgorithmstest.moc" diff --git a/core/kipl/UnitTests/tKiplMath/tst_tkiplmathtest.cpp b/core/kipl/UnitTests/tKiplMath/tst_tkiplmathtest.cpp index e0f50175d..7f4cd031e 100644 --- a/core/kipl/UnitTests/tKiplMath/tst_tkiplmathtest.cpp +++ b/core/kipl/UnitTests/tKiplMath/tst_tkiplmathtest.cpp @@ -1,7 +1,9 @@ #include +#include #include #include +#include #include #include @@ -12,6 +14,7 @@ #include #include #include +#include #include @@ -29,8 +32,11 @@ class TKiplMathTest : public QObject private Q_SLOTS: void testCOG(); void testCircularHoughTransform(); - void testNonLinFit_fitfunctions(); + void testNonLinFit_enums(); + void testNonLinFit_GaussianFunction(); void testNonLinFit_fitter(); + void testFindPeaks(); + void testStatistics(); void testSignFunction(); }; @@ -127,15 +133,130 @@ void TKiplMathTest::testCircularHoughTransform() kipl::io::WriteTIFF32(chm,"chtg_map.tif"); } -void TKiplMathTest::testNonLinFit_fitfunctions() +void TKiplMathTest::testNonLinFit_enums() { - // kipl::Nonlinear::SumOfGaussians sog; + std::string val; + Nonlinear::eProfileFunction e; + + val="GaussProfile"; + string2enum(val,e); + QCOMPARE(e,Nonlinear::eProfileFunction::fnSumOfGaussians); + val="LorenzProfile"; + string2enum(val,e); + QCOMPARE(e,Nonlinear::eProfileFunction::fnLorenzian); + val="VoightProfile"; + string2enum(val,e); + QCOMPARE(e,Nonlinear::eProfileFunction::fnVoight); + + QCOMPARE(enum2string(Nonlinear::eProfileFunction::fnSumOfGaussians),std::string("GaussProfile")); + QCOMPARE(enum2string(Nonlinear::eProfileFunction::fnLorenzian),std::string("LorenzProfile")); + QCOMPARE(enum2string(Nonlinear::eProfileFunction::fnVoight),std::string("VoightProfile")); + + ostringstream msg; + + msg.str(""); + msg< dyda(3); + + y0=sog(x); + sog(x,y1,dyda); + QCOMPARE(y0,y1); +} void TKiplMathTest::testNonLinFit_fitter() { + int N=100; + + Array1D x(N); + Array1D y(N); + Array1D sig(N); + + Nonlinear::SumOfGaussians sog0(1),sog(1); + sog0[0]=2; //A + sog0[1]=0; //m + sog0[2]=1; //s + + sog[0]=1; //A + sog[1]=0.5; //m + sog[2]=1.5; //s + + for (int i=0; i + +#include + +namespace kipl { +namespace math { + +size_t findPeaks(float *data, size_t N, float m, float level, std::list &peaks) +{ + peaks.clear(); + + size_t start=0L; + size_t stop=0L; + bool current=false; + bool previous=false; + previous = level < fabs(data[0]-m) ; + + for (size_t i=1; i +#include #include #include #include +#include +#include #include -#include +#include #include "../../include/math/nonlinfit.h" #include "../../include/math/jama_inverses.h" +#include "../../include/math/mathconstants.h" #include "../../include/logging/logger.h" +#include "../../include/base/KiplException.h" +#include "../../include/strings/miscstring.h" using namespace TNT; using namespace JAMA; namespace Nonlinear { - int stddev(long double *x,long double *y,int ndata,CBaseFunction &fn,long double *sig); - void mrqmin(long double *x,long double *y,long double *sig,int ndata, - Array2D &covar, Array2D &alpha, - long double &chisq, - CBaseFunction &fn, - long double &alamda); +LevenbergMarquardt::LevenbergMarquardt(const double TOL) : + tol(TOL) +{ + // Constructor. +} - void mrqcof(long double *x,long double *y,long double *sig,int ndata, - Array2D &alpha, - Array1D &beta, - long double &chisq, - CBaseFunction &fn); +void LevenbergMarquardt::fit(Array1D &x, Array1D &y, + Array1D &sig, + Nonlinear::FitFunctionBase &fn) +{ + // Iterate to reduce the 2 of a fit between a set of data points x[0..ndat-1], y[0..ndat-1] + // with individual standard deviations sig[0..ndat-1], and a nonlinear function that depends + // on ma coefficients a[0..ma-1]. When 2 is no longer decreasing, set best-fit values + // for the parameters a[0..ma-1], and chisq D 2, covar[0..ma-1][0..ma-1], and + // alpha[0..ma-1][0..ma-1]. (Parameters held fixed will return zero covariances.) + ma=fn.getNpars(); + mfit=fn.getNpars2fit(); + if ((x.dim1()!=y.dim1()) || (x.dim1()!=sig.dim1())) + throw kipl::base::KiplException("Array size missmatch for the fitter",__FILE__,__LINE__); - void covsrt(Array2D &covar, CBaseFunction &fn); + ndat=x.dim1(); - //###################################### + covar=Array2D(ma,ma); + alpha=Array2D(ma,ma); - int LevenbergMarquardt(double *_x,double *_y, int ndata, CBaseFunction &fn, double eps,double *s) - { - kipl::logging::Logger logger("LevenbergMarquardt"); - std::stringstream msg; - - // int npars=fn.getNpars(); - int mfit=fn.getNpars2fit(); - Array2D covar(mfit,mfit),alpha(mfit,mfit); - long double chisq,chiold,alambda; - long double *x=new long double[ndata]; - long double *y=new long double[ndata]; - - - long double *sig=new long double[ndata]; - - int i,n; - - for (i=0; i beta(ma),da(ma); + Array1D a(ma),atry(ma); + Array2D oneda(mfit,1), temp(mfit,mfit); - // solve the final parameter-set - alambda=0; - if (!s) - stddev(x,y,ndata,fn,sig); - mrqmin(x,y,sig,ndata,covar,alpha,chisq,fn,alambda); - delete [] sig; - delete [] x; - delete [] y; - return 1; - } + fn.getPars(a); + mrqcof(fn,x,y,sig,alpha,beta); // Initialization. - int stddev(long double *x,long double *y,int ndata, - CBaseFunction &fn, - long double *sig) - { - long double yest,sigma; + fn.getPars(atry); - sigma=0; + ochisq=chisq; - int i; - for (i=0; i &covar,Array2D &alpha, - long double &chisq, - CBaseFunction &fn, - long double &alamda) - { - kipl::logging::Logger logger("mrqmin"); - std::stringstream msg; - int j,k,l; - int ma=fn.getNpars(); - static int mfit; - static long double ochisq; - static Array1D atry,beta,da,oneda; - - if (alamda < 0.0) { - logger(kipl::logging::Logger::LogVerbose,"Initializing vectors"); - - atry=Array1D(ma); - beta=Array1D(ma); - da=Array1D(ma); - mfit=fn.getNpars2fit(); - oneda=Array1D(mfit); - alamda=0.001; - mrqcof(x,y,sig,ndata,alpha,beta,chisq,fn); - ochisq=(chisq); - for (j=0;j X(covar); - oneda=X.solve(oneda); + for (k=0;k X(covar); logger(kipl::logging::Logger::LogVerbose,"Solving equation system with SVD"); + oneda[j][0]=beta[j]; + } + gaussj(temp,oneda); //Matrix solution. - for (j=0;j tmp(ma); + if (done==NDONE) { //Converged. Clean up and return. + covsrt(covar,fn); + covsrt(alpha,fn); - for (j=0,l=0;l &alpha, - Array1D &beta, - long double &chisq, - CBaseFunction &fn) - { - int i,j,k,l,m,mfit=0; - long double ymod,wt,sig2i,dy; - int ma=fn.getNpars(); + fn.setPars(atry); + mrqcof(fn,x,y,sig,covar,da); - Array1D dyda(ma); + if (abs(chisq-ochisq) < std::max(tol,tol*chisq)) done++; - mfit=fn.getNpars2fit(); + if (chisq < ochisq) { //Success, accept the new solution. + alamda *= 0.1; + ochisq=chisq; + for (j=0;j &x, Array1D &y, + Array1D &sig, Array2D &alpha, Array1D &beta) +{ +//Used by fit to evaluate the linearized fitting matrix alpha, and vector beta as in (15.5.8), and to calculate 2. + int i,j,k,l,m; + double ymod,wt,sig2i,dy; + Array1D dyda(ma); + for (j=0; j &covar, CBaseFunction &fn) - { - int i,j,k, mfit=fn.getNpars2fit(); - - int ma=covar.dim2(); - - for (i=mfit+1;i<=ma;i++) - for (j=1;j<=i;j++) covar[i-1][j-1]=covar[j-1][i-1]=0.0; - k=mfit-1; - for (j=ma-1;j>=0;j--) { - if (fn.IsLocked(j)) { - for (i=0;i &covar, Nonlinear::FitFunctionBase &fn) +{ +//Expand in storage the covariance matrix covar, so as to take into account parameters that +//are being held fixed. (For the latter, return zero covariances.) + int i,j,k; + for (i=mfit;i=0;j--) { + if (fn.isFree(j)) { + for (i=0;i &a, Array2D &b) +//Linear equation solution by Gauss-Jordan elimination, equation (2.1.1) above. The input matrix +//is a[0..n-1][0..n-1]. b[0..n-1][0..m-1] is input containing the m right-hand side vectors. +//On output, a is replaced by its matrix inverse, and b is replaced by the corresponding set of +//solution vectors. +{ + int i,icol,irow,j,k,l,ll,n=a.dim1(),m=b.dim2(); + double big,dum,pivinv; + Array1D indxc(n),indxr(n),ipiv(n); //These integer arrays are used for bookkeeping on + for (j=0;j= big) { + big=abs(a[j][k]); + irow=j; + icol=k; + } + } + } + ++(ipiv[icol]); + + if (irow != icol) { + for (l=0;l=0;l--) { + if (indxr[l] != indxc[l]) + for (k=0;k(n); + m_lock=new bool[n]; + std::fill(m_lock,m_lock+n,true); m_pars2fit=n; m_Npars=n; } - long double & CBaseFunction::operator[](int n) + double & FitFunctionBase::operator[](int n) { if (n &pars) { - memcpy(m_pars,pars,sizeof(long double)*m_Npars); + m_pars=pars; - return 1; - } + return m_pars.dim1(); + } + + int FitFunctionBase::getPars(Array1D &pars) + { + return 0; + } - int CBaseFunction::getNpars() + int FitFunctionBase::getNpars() { return m_Npars; } - int CBaseFunction::setLock(int *lv) + int FitFunctionBase::setLock(bool *lv) { m_pars2fit=0; + std::copy(lv,lv+m_Npars,m_lock); + for (int i=0; i & dyda) + int SumOfGaussians::operator()(double x, double &y, Array1D & dyda) { int i; long double fac,ex,arg; if (dyda.dim()!=m_Npars) - dyda=Array1D(m_Npars); + dyda=Array1D(m_Npars); y=0.0; for (i=0;i & UNUSED(hes)) + int SumOfGaussians::Hessian(double UNUSED(x), Array2D & UNUSED(hes)) { cerr<<"The Hessian is not available"< & UNUSED(jac)) + int SumOfGaussians::Jacobian(double UNUSED(x), Array2D & UNUSED(jac)) { cerr<<"The Jacobian is not available"<second; + + +} + +std::string enum2string(Nonlinear::eProfileFunction e) +{ + switch(e) { + case Nonlinear::fnSumOfGaussians: + return "GaussProfile"; + break; + case Nonlinear::fnLorenzian: + return "LorenzProfile"; + break; + case Nonlinear::fnVoight: + return "VoightProfile"; + break; + } + + return "GaussProfile"; +} + +ostream &operator<<(ostream &s, Nonlinear::eProfileFunction e) +{ + std::string str; + str=enum2string(e); + + s< Read(std::string filename, - kipl::base::eImageFlip flip, - kipl::base::eImageRotate rotate, - float binning, - size_t const * const nCrop, size_t idx=0L); + kipl::base::eImageFlip flip=kipl::base::ImageFlipNone, + kipl::base::eImageRotate rotate=kipl::base::ImageRotateNone, + float binning=1.0f, + size_t const * const nCrop=nullptr, size_t idx=0L); /// Reading a single file with file name given by a file mask and an index number. /// \param path Path to the location where the file is saved @@ -72,8 +72,8 @@ class READERCONFIGSHARED_EXPORT ImageReader kipl::base::TImage Read(ImageLoader &loader, kipl::base::eImageFlip flip, kipl::base::eImageRotate rotate, - float binning, - size_t const * const nCrop); + float binning=1.0f, + size_t const * const nCrop=nullptr); /// Get the image dimensions for an image file using a file mask /// \param path The path where image is stored diff --git a/frameworks/imageprocessing/ProcessFramework/include/KiplProcessConfig.h b/frameworks/imageprocessing/ProcessFramework/include/KiplProcessConfig.h index 1e63390f6..79dd49195 100644 --- a/frameworks/imageprocessing/ProcessFramework/include/KiplProcessConfig.h +++ b/frameworks/imageprocessing/ProcessFramework/include/KiplProcessConfig.h @@ -78,6 +78,10 @@ class PROCESSFRAMEWORKSHARED_EXPORT KiplProcessConfig : public ConfigBase private: virtual void ParseConfig(xmlTextReaderPtr reader, std::string sName); virtual void ParseProcessChain(xmlTextReaderPtr reader); + /// Sanity check on the number of slices to be reconstruct during Config + virtual std::string SanitySlicesCheck() {return "";} + /// Sanity message that warns about the number of slices that are being configured + virtual std::string SanityMessage(bool mess) {return "";} }; #endif diff --git a/frameworks/imageprocessing/ProcessFramework/qt/ProcessFramework/ProcessFramework.pro b/frameworks/imageprocessing/ProcessFramework/qt/ProcessFramework/ProcessFramework.pro index c33a4ed5a..e701c71fe 100644 --- a/frameworks/imageprocessing/ProcessFramework/qt/ProcessFramework/ProcessFramework.pro +++ b/frameworks/imageprocessing/ProcessFramework/qt/ProcessFramework/ProcessFramework.pro @@ -27,8 +27,8 @@ unix:!symbian { INCLUDEPATH += /opt/local/include INCLUDEPATH += /opt/local/include/libxml2 QMAKE_LIBDIR += /opt/local/lib - QMAKE_INFO_PLIST = Info.plist - ICON = muhrec3.icns + # QMAKE_INFO_PLIST = Info.plist + # ICON = muhrec3.icns } else { QMAKE_CXXFLAGS += -fPIC -fopenmp -O2 @@ -51,6 +51,26 @@ win32 { QMAKE_CXXFLAGS += /openmp /O2 } +unix:mac { +exists($$PWD/../../../../../external/mac/lib/*NeXus*) { + + message("-lNeXus exists") + DEFINES *= HAVE_NEXUS + + INCLUDEPATH += $$PWD/../../../../../external/mac/include/ $$PWD/../../../../../external/mac/include/nexus $$PWD/../../../../../external/mac/include/hdf5 + DEPENDPATH += $$PWD/../../../../../external/mac/include/ $$PWD/../../../../../external/mac/include/nexus $$PWD/../../../../../external/mac/include/hdf5 + QMAKE_LIBDIR += $$PWD/../../../../../external/mac/lib/ + + LIBS += -lNeXus.1.0.0 -lNeXusCPP.1.0.0 + + +} +else { +message("-lNeXus does not exists $$HEADERS") +} + +} + DEFINES += PROCESSFRAMEWORK_LIBRARY SOURCES += \ diff --git a/frameworks/imageprocessing/modules/ImagingModules/src/referenceimagecorrectionmodule.cpp b/frameworks/imageprocessing/modules/ImagingModules/src/referenceimagecorrectionmodule.cpp index 896c5c79d..781c01d9a 100644 --- a/frameworks/imageprocessing/modules/ImagingModules/src/referenceimagecorrectionmodule.cpp +++ b/frameworks/imageprocessing/modules/ImagingModules/src/referenceimagecorrectionmodule.cpp @@ -1,4 +1,4 @@ -#include +//#include #include "referenceimagecorrectionmodule.h" #include diff --git a/frameworks/tomography/Preprocessing/StdPreprocModules/include/bblognorm.h b/frameworks/tomography/Preprocessing/StdPreprocModules/include/bblognorm.h new file mode 100644 index 000000000..bc3435c1c --- /dev/null +++ b/frameworks/tomography/Preprocessing/StdPreprocModules/include/bblognorm.h @@ -0,0 +1,156 @@ +#ifndef BBLOGNORM_H +#define BBLOGNORM_H + +#include "StdPreprocModules_global.h" + +#include +#include +#include + +#include + +#include +#include + +#include "PreprocEnums.h" +#include + +//#include "../include/NormPlugins.h" + +class STDPREPROCMODULESSHARED_EXPORT BBLogNorm : public PreprocModuleBase +{ +public: + BBLogNorm(kipl::interactors::InteractionBase *interactor=nullptr); + virtual ~BBLogNorm(); + + virtual int Configure(ReconConfig config, std::map parameters); /// Configure all parameters and calls PrepareBBData + virtual int ConfigureDLG(ReconConfig config, std::map parameters); /// Configure all parameters and does not call PrepareBBData + virtual std::map GetParameters(); + virtual void LoadReferenceImages(size_t *roi); /// load all images that are needed for referencing in the current roi + virtual bool SetROI(size_t *roi); /// set the current roi to be processed + + virtual int ProcessCore(kipl::base::TImage & img, std::map & coeff); + virtual int ProcessCore(kipl::base::TImage & img, std::map & coeff); + virtual void SetReferenceImages(kipl::base::TImage dark, kipl::base::TImage flat); /// set references images + virtual float GetInterpolationError(kipl::base::TImage &mask); /// computes and returns interpolation error and mask on OB image with BBs + virtual kipl::base::TImage GetMaskImage(); + virtual void PrepareBBData(); /// read all data (entire projection) that I need and prepare them for the BB correction, it is now called in LoadReferenceImages + virtual void LoadExternalBBData(size_t *roi); /// load BB images pre-processed elsewhere + +protected: + ReconConfig m_Config; + std::string path; /// path, maybe not used + std::string flatname; /// name mask for OB image + std::string darkname; /// name mask for DC image + std::string blackbodyname; /// name mask for OB image with BBs + std::string blackbodysamplename; /// name mask for sample image with BBs + + std::string blackbodyexternalname; + std::string blackbodysampleexternalname; + + size_t nBBextCount; /// number of preprocessed BB images; + size_t nBBextFirstIndex; /// first index in filneame for preprocessed BB images + + size_t nOBCount; /// number of OB images + size_t nOBFirstIndex; /// first index in filename for OB images + size_t nDCCount; /// number of DC images + size_t nDCFirstIndex; /// first index in filename for DC images + size_t nBBCount; /// number of open beam images with BB + size_t nBBFirstIndex; /// first index in filename for OB images with BB + size_t nBBSampleCount; /// number of sample images with BB + size_t nBBSampleFirstIndex; /// first index in filename for sample images with BB + + float fFlatDose; /// dose value in open beam images in dose roi + float fDarkDose; /// dose value in dark current images in dose roi + float fBlackDose; /// dose value in black body images in BB dose roi + float fBlackDoseSample; /// dose values in black body images with sample in BB dose roi + float fdarkBBdose; /// dose value in dark current images within BB dose roi + float fFlatBBdose; /// dose value in open beam image within BB dose roi + + float tau; /// mean pattern transmission, default 0.97 + float thresh; /// manual threshold + + bool bUseNormROI; /// boolean value on the use of the norm roi + bool bUseLUT; /// boolean value on the use of LUT (not used) + bool bUseWeightedMean; + bool bUseBB; /// boolean value on the use of BBs, to be set when calling PrepareBBData + bool bUseExternalBB; /// boolean value on the use of externally produced BBs + bool bUseNormROIBB; /// boolean value on the use of the norm roi on BBs + bool bSameMask; /// boolean value on the use of the same mask computed for OB images with BB also for sample image with BB, in case of false the mask is recomputed on the first available image with BB. This implies that exists an image with the sample and without BB and the sample is in the exact same position + bool bUseManualThresh; /// boolean value on the use of a manual threshold instead of Otsu + bool bPBvariante; + + size_t nNormRegion[4]; + size_t nOriginalNormRegion[4]; + size_t BBroi[4]; /// region of interest to be set for BB segmentation + size_t doseBBroi[4]; /// region of interest for dose computation in BB images + + size_t radius; /// radius used to select circular region within the BBs to be used for interpolation + size_t min_area; /// minimal area to be used for BB segmentation: if smaller, segmented BB is considered as noise and not considered for background computation + float ferror; /// interpolation error, computed on the open beam with BBs image + float ffirstAngle; /// first angle for BB sample image, used for BB interpolation option + float flastAngle; /// last angle for BB sample image, used for BB interpolation option + + float *ob_bb_param; + float *sample_bb_param; + + int GetnProjwithAngle(float angle); /// compute the index of projection data at a given angle + + + kipl::base::TImage mMaskBB; + kipl::base::TImage mdark; + kipl::base::TImage mflat; + + virtual kipl::base::TImage ReferenceLoader(std::string fname, + int firstIndex, + int N, + size_t *roi, + float initialDose, + float doseBias, + ReconConfig &config, float &dose); /// Loader function and dose computation for standard reference images (OB and DC) + + + virtual kipl::base::TImage BBLoader(std::string fname, + int firstIndex, + int N, + float initialDose, + float doseBias, + ReconConfig &config, float &dose); /// Loader function and dose computation for BB reference images (OB with BB and sample with BB) + + virtual float DoseBBLoader(std::string fname, + int firstIndex, + float initialDose, + float doseBias, + ReconConfig &config); /// Loader function that only compute Dose in the BB dose roi , whitout loading the entire image + + virtual kipl::base::TImage BBExternalLoader(std::string fname, + ReconConfig &config, + size_t *roi, + float &dose); /// Loader function for externally created BB, open beam case (only 1 image) + virtual kipl::base::TImage BBExternalLoader(std::string fname, + int N, + size_t *roi, + int firstIndex, + ReconConfig &config, float *doselist); /// Loader function for externally created BB, sample image case (nProj images with filemask) + + + float computedose(kipl::base::TImage&img); + + void PreparePolynomialInterpolationParameters(); /// get the interpolation parameters for the polynomial case + int PrepareSplinesInterpolationParameters(); /// get the interpolation parameters for the thin plates spline case + +private: + int m_nWindow; /// apparentely not used + ImagingAlgorithms::AverageImage::eAverageMethod m_ReferenceAverageMethod; /// method chosen for averaging Referencing images + ImagingAlgorithms::ReferenceImageCorrection::eReferenceMethod m_ReferenceMethod;/// method chosen for Referencing (BBLogNorm or LogNorm, only BBLogNorm is implemented at the moment) + ImagingAlgorithms::ReferenceImageCorrection::eBBOptions m_BBOptions; /// options for BB image reference correction (Interpolate, Average, OneToOne) + ImagingAlgorithms::ReferenceImageCorrection m_corrector; /// instance of ReferenceImageCorrection + ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderX m_xInterpOrder; /// order chosen for interpolation along the X direction + ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderY m_yInterpOrder; /// order chosen for interpolation along the Y direction + ImagingAlgorithms::ReferenceImageCorrection::eInterpMethod m_InterpMethod; /// interpolation method + +}; + + + +#endif // BBLOGNORM_H diff --git a/frameworks/tomography/Preprocessing/StdPreprocModules/qt/StdPreprocModules/StdPreprocModules.pro b/frameworks/tomography/Preprocessing/StdPreprocModules/qt/StdPreprocModules/StdPreprocModules.pro index c6f85e8dd..9f812d50b 100644 --- a/frameworks/tomography/Preprocessing/StdPreprocModules/qt/StdPreprocModules/StdPreprocModules.pro +++ b/frameworks/tomography/Preprocessing/StdPreprocModules/qt/StdPreprocModules/StdPreprocModules.pro @@ -38,7 +38,8 @@ SOURCES += \ ../../src/TranslateProjectionsModule.cpp \ ../../src/MorphSpotCleanModule.cpp \ ../../src/GammaSpotCleanModule.cpp \ - ../../src/CameraStripeClean.cpp + ../../src/CameraStripeClean.cpp \ + ../../src/bblognorm.cpp HEADERS += \ ../../include/WaveletRingClean.h \ @@ -63,7 +64,9 @@ HEADERS += \ ../../include/MorphSpotCleanModule.h \ ../../include/GammaSpotCleanModule.h \ ../../include/StdPreprocModules_global.h \ - ../../include/CameraStripeClean.h + ../../include/CameraStripeClean.h \ + ../../include/bblognorm.h + symbian { MMP_RULES += EXPORTUNFROZEN diff --git a/frameworks/tomography/Preprocessing/StdPreprocModules/src/StdPreprocModules.cpp b/frameworks/tomography/Preprocessing/StdPreprocModules/src/StdPreprocModules.cpp index 8e8651691..8ddf8e54f 100644 --- a/frameworks/tomography/Preprocessing/StdPreprocModules/src/StdPreprocModules.cpp +++ b/frameworks/tomography/Preprocessing/StdPreprocModules/src/StdPreprocModules.cpp @@ -31,6 +31,7 @@ #include "../include/MorphSpotCleanModule.h" #include "../include/GammaSpotCleanModule.h" #include "../include/CameraStripeClean.h" +#include "../include/bblognorm.h" #include #include @@ -56,6 +57,9 @@ STDPREPROCMODULESSHARED_EXPORT void * GetModule(const char *application, const c if (name!=NULL) { std::string sName=name; + if (sName=="BBLogNorm") + return new BBLogNorm; + if (sName=="FullLogNorm") return new FullLogNorm; @@ -186,10 +190,9 @@ STDPREPROCMODULESSHARED_EXPORT int GetModuleList(const char *application, void * FullNorm fnorm; modulelist->operator []("FullNorm")=fnorm.GetParameters(); -#ifdef USE_UNPUBLISHED - RobustLogNorm robnorm; - modulelist->operator[]("RobustLogNorm")=robnorm.GetParameters(); -#endif + BBLogNorm bbnorm; + modulelist->operator[]("BBLogNorm")=bbnorm.GetParameters(); + LogProjection lproj; modulelist->operator []("LogProjection")=lproj.GetParameters(); diff --git a/frameworks/tomography/Preprocessing/StdPreprocModules/src/bblognorm.cpp b/frameworks/tomography/Preprocessing/StdPreprocModules/src/bblognorm.cpp new file mode 100644 index 000000000..e2efddf8e --- /dev/null +++ b/frameworks/tomography/Preprocessing/StdPreprocModules/src/bblognorm.cpp @@ -0,0 +1,1881 @@ +#include + +#include +#include +#include +#include +#include + +#include + +#include "../include/bblognorm.h" + + +BBLogNorm::BBLogNorm(kipl::interactors::InteractionBase *interactor) : + PreprocModuleBase("BBLogNorm", interactor), + // to check which one do i need: to be removed: m_nWindow and bUseWeightedMean + nOBCount(0), + nOBFirstIndex(1), + nBBSampleCount(0), + nBBSampleFirstIndex(1), + radius(2), + nDCCount(0), + nDCFirstIndex(1), + nBBCount(0), + nBBFirstIndex(1), + fFlatDose(1.0f), + fBlackDose(1.0f), + fDarkDose(0.0f), + fdarkBBdose(0.0f), + fFlatBBdose(1.0f), + bUseNormROI(true), + bUseLUT(false), + bUseWeightedMean(false), + bUseBB(false), + bUseNormROIBB(false), + m_nWindow(5), + tau(0.97f), + bPBvariante(true), + m_ReferenceAverageMethod(ImagingAlgorithms::AverageImage::ImageWeightedAverage), + m_ReferenceMethod(ImagingAlgorithms::ReferenceImageCorrection::ReferenceLogNorm), + m_BBOptions(ImagingAlgorithms::ReferenceImageCorrection::Interpolate), + m_xInterpOrder(ImagingAlgorithms::ReferenceImageCorrection::SecondOrder_x), + m_yInterpOrder(ImagingAlgorithms::ReferenceImageCorrection::SecondOrder_y), + m_InterpMethod(ImagingAlgorithms::ReferenceImageCorrection::Polynomial), + ferror(0.0f), + ffirstAngle(0.0f), + flastAngle(360.0f), + nBBextCount(0), + nBBextFirstIndex(0), + bUseExternalBB(false), + bSameMask(true), + bUseManualThresh(false), + min_area(20), + thresh(0) +{ + + doseBBroi[0] = doseBBroi[1] = doseBBroi[2] = doseBBroi[3]=0; + BBroi[0] = BBroi[1] = BBroi[2] = BBroi[3] = 0; + blackbodyname = "./"; + blackbodysamplename = "./"; + blackbodyexternalname = "./"; + blackbodysampleexternalname = "./"; + +} + +BBLogNorm::~BBLogNorm() +{ + +} + + +int BBLogNorm::Configure(ReconConfig config, std::map parameters) +{ + + m_Config = config; + path = config.ProjectionInfo.sReferencePath; + flatname = config.ProjectionInfo.sOBFileMask; + darkname = config.ProjectionInfo.sDCFileMask; + + nOBCount = config.ProjectionInfo.nOBCount; + nOBFirstIndex = config.ProjectionInfo.nOBFirstIndex; + + nDCCount = config.ProjectionInfo.nDCCount; + nDCFirstIndex = config.ProjectionInfo.nDCFirstIndex; + + + m_nWindow = GetIntParameter(parameters,"window"); + string2enum(GetStringParameter(parameters,"avgmethod"),m_ReferenceAverageMethod); + string2enum(GetStringParameter(parameters,"refmethod"), m_ReferenceMethod); + string2enum(GetStringParameter(parameters,"BBOption"), m_BBOptions); + string2enum(GetStringParameter(parameters, "X_InterpOrder"), m_xInterpOrder); + string2enum(GetStringParameter(parameters, "Y_InterpOrder"), m_yInterpOrder); + string2enum(GetStringParameter(parameters,"InterpolationMethod"), m_InterpMethod); + bPBvariante = kipl::strings::string2bool(GetStringParameter(parameters,"PBvariante")); + + + blackbodyname = GetStringParameter(parameters,"BB_OB_name"); + nBBCount = GetIntParameter(parameters,"BB_counts"); + nBBFirstIndex = GetIntParameter(parameters, "BB_first_index"); + blackbodysamplename = GetStringParameter(parameters,"BB_samplename"); + nBBSampleFirstIndex = GetIntParameter(parameters, "BB_sample_firstindex"); + nBBSampleCount = GetIntParameter(parameters,"BB_samplecounts"); + + blackbodyexternalname = GetStringParameter(parameters, "BB_OB_ext_name"); + blackbodysampleexternalname = GetStringParameter(parameters, "BB_sample_ext_name"); + nBBextCount = GetIntParameter(parameters, "BB_ext_samplecounts"); + nBBextFirstIndex = GetIntParameter(parameters, "BB_ext_firstindex"); + + tau = GetFloatParameter(parameters, "tau"); + radius = GetIntParameter(parameters, "radius"); + min_area = GetIntParameter(parameters, "min_area"); + GetUIntParameterVector(parameters, "BBroi", BBroi, 4); + GetUIntParameterVector(parameters, "doseBBroi", doseBBroi, 4); + ffirstAngle = GetFloatParameter(parameters, "firstAngle"); + flastAngle = GetFloatParameter(parameters, "lastAngle"); + bSameMask = kipl::strings::string2bool(GetStringParameter(parameters,"SameMask")); + bUseManualThresh = kipl::strings::string2bool(GetStringParameter(parameters,"ManualThreshold")); + thresh = GetFloatParameter(parameters,"thresh"); + + m_corrector.SetManualThreshold(bUseManualThresh,thresh); +// std::cout << bUseManualThresh << " " << thresh << std::endl; + + memcpy(nOriginalNormRegion,config.ProjectionInfo.dose_roi,4*sizeof(size_t)); + + size_t roi_bb_x= BBroi[2]-BBroi[0]; + size_t roi_bb_y = BBroi[3]-BBroi[1]; + + // do i need this here? + if (roi_bb_x>0 && roi_bb_y>0) {} + else { + memcpy(BBroi, m_Config.ProjectionInfo.projection_roi, sizeof(size_t)*4); // use the same as projections in case.. if i don't I got an Exception + } + + //check on dose BB roi size + if ((doseBBroi[2]-doseBBroi[0])<=0 || (doseBBroi[3]-doseBBroi[1])<=0){ + bUseNormROIBB=false; + } + else { + bUseNormROIBB = true; + } + + if ((m_Config.ProjectionInfo.dose_roi[2]-m_Config.ProjectionInfo.dose_roi[0])<=0 || (m_Config.ProjectionInfo.dose_roi[3]-m_Config.ProjectionInfo.dose_roi[1])<=0 ){ + bUseNormROI=false; + throw ReconException("No roi is selected for dose correction. This is necessary for accurate BB referencing",__FILE__, __LINE__); + } + else{ + bUseNormROI=true; + } + + if (enum2string(m_ReferenceMethod)=="LogNorm"){ + m_corrector.SetComputeMinusLog(true); + } + else { + m_corrector.SetComputeMinusLog(false); + } + + switch (m_BBOptions){ + case (ImagingAlgorithms::ReferenceImageCorrection::noBB): { + bUseBB = false; + bUseExternalBB = false; + break; + } + case (ImagingAlgorithms::ReferenceImageCorrection::Interpolate): { + bUseBB = true; + bUseExternalBB = false; + break; + } + case (ImagingAlgorithms::ReferenceImageCorrection::Average): { + bUseBB = true; + bUseExternalBB = false; + break; + } + case (ImagingAlgorithms::ReferenceImageCorrection::OneToOne): { + bUseBB = true; + bUseExternalBB = false; + break; + } + case (ImagingAlgorithms::ReferenceImageCorrection::ExternalBB): { + bUseBB = false; // to evaluate + bUseExternalBB = true; + break; + } + default: throw ReconException("Unknown BBOption method in BBLogNorm::Configure",__FILE__,__LINE__); + + } + + if (bUseBB && nBBCount!=0 && nBBSampleCount!=0) { + PrepareBBData(); + } + + + return 1; +} + +int BBLogNorm::ConfigureDLG(ReconConfig config, std::map parameters) +{ + + m_Config = config; + path = config.ProjectionInfo.sReferencePath; + flatname = config.ProjectionInfo.sOBFileMask; + darkname = config.ProjectionInfo.sDCFileMask; + + nOBCount = config.ProjectionInfo.nOBCount; + nOBFirstIndex = config.ProjectionInfo.nOBFirstIndex; + + nDCCount = config.ProjectionInfo.nDCCount; + nDCFirstIndex = config.ProjectionInfo.nDCFirstIndex; + + + m_nWindow = GetIntParameter(parameters,"window"); + string2enum(GetStringParameter(parameters,"avgmethod"),m_ReferenceAverageMethod); + string2enum(GetStringParameter(parameters,"refmethod"), m_ReferenceMethod); + string2enum(GetStringParameter(parameters,"BBOption"), m_BBOptions); + string2enum(GetStringParameter(parameters, "X_InterpOrder"), m_xInterpOrder); + string2enum(GetStringParameter(parameters, "Y_InterpOrder"), m_yInterpOrder); + string2enum(GetStringParameter(parameters,"InterpolationMethod"), m_InterpMethod); + bPBvariante = kipl::strings::string2bool(GetStringParameter(parameters,"PBvariante")); + + + blackbodyname = GetStringParameter(parameters,"BB_OB_name"); + nBBCount = GetIntParameter(parameters,"BB_counts"); + nBBFirstIndex = GetIntParameter(parameters, "BB_first_index"); + blackbodysamplename = GetStringParameter(parameters,"BB_samplename"); + nBBSampleFirstIndex = GetIntParameter(parameters, "BB_sample_firstindex"); + nBBSampleCount = GetIntParameter(parameters,"BB_samplecounts"); + + blackbodyexternalname = GetStringParameter(parameters, "BB_OB_ext_name"); + blackbodysampleexternalname = GetStringParameter(parameters, "BB_sample_ext_name"); + nBBextCount = GetIntParameter(parameters, "BB_ext_samplecounts"); + nBBextFirstIndex = GetIntParameter(parameters, "BB_ext_firstindex"); + + tau = GetFloatParameter(parameters, "tau"); + radius = GetIntParameter(parameters, "radius"); + min_area = GetIntParameter(parameters, "min_area"); + GetUIntParameterVector(parameters, "BBroi", BBroi, 4); + GetUIntParameterVector(parameters, "doseBBroi", doseBBroi, 4); + ffirstAngle = GetFloatParameter(parameters, "firstAngle"); + flastAngle = GetFloatParameter(parameters, "lastAngle"); + bSameMask = kipl::strings::string2bool(GetStringParameter(parameters,"SameMask")); + bUseManualThresh = kipl::strings::string2bool(GetStringParameter(parameters,"ManualThreshold")); + thresh = GetFloatParameter(parameters,"thresh"); + + m_corrector.SetManualThreshold(bUseManualThresh,thresh); +// std::cout << bUseManualThresh << " " << thresh << std::endl; + + memcpy(nOriginalNormRegion,config.ProjectionInfo.dose_roi,4*sizeof(size_t)); + + size_t roi_bb_x= BBroi[2]-BBroi[0]; + size_t roi_bb_y = BBroi[3]-BBroi[1]; + + // do i need this here? + if (roi_bb_x>0 && roi_bb_y>0) {} + else { + memcpy(BBroi, m_Config.ProjectionInfo.projection_roi, sizeof(size_t)*4); // use the same as projections in case.. if i don't I got an Exception + } + + //check on dose BB roi size + if ((doseBBroi[2]-doseBBroi[0])<=0 || (doseBBroi[3]-doseBBroi[1])<=0){ + bUseNormROIBB=false; + } + else { + bUseNormROIBB = true; + } + + if ((m_Config.ProjectionInfo.dose_roi[2]-m_Config.ProjectionInfo.dose_roi[0])<=0 || (m_Config.ProjectionInfo.dose_roi[3]-m_Config.ProjectionInfo.dose_roi[1])<=0 ){ + bUseNormROI=false; + throw ReconException("No roi is selected for dose correction. This is necessary for accurate BB referencing",__FILE__, __LINE__); + } + else{ + bUseNormROI=true; + } + + if (enum2string(m_ReferenceMethod)=="LogNorm"){ + m_corrector.SetComputeMinusLog(true); + } + else { + m_corrector.SetComputeMinusLog(false); + } + + switch (m_BBOptions){ + case (ImagingAlgorithms::ReferenceImageCorrection::noBB): { + bUseBB = false; + bUseExternalBB = false; + break; + } + case (ImagingAlgorithms::ReferenceImageCorrection::Interpolate): { + bUseBB = true; + bUseExternalBB = false; + break; + } + case (ImagingAlgorithms::ReferenceImageCorrection::Average): { + bUseBB = true; + bUseExternalBB = false; + break; + } + case (ImagingAlgorithms::ReferenceImageCorrection::OneToOne): { + bUseBB = true; + bUseExternalBB = false; + break; + } + case (ImagingAlgorithms::ReferenceImageCorrection::ExternalBB): { + bUseBB = false; // to evaluate + bUseExternalBB = true; + break; + } + default: throw ReconException("Unknown BBOption method in BBLogNorm::Configure",__FILE__,__LINE__); + + } + + + return 1; +} + +bool BBLogNorm::SetROI(size_t *roi) { + + std::stringstream msg; + msg<<"ROI=["< BBLogNorm::GetParameters() { + std::map parameters; + + parameters["window"] = kipl::strings::value2string(m_nWindow); + parameters["avgmethod"] = enum2string(m_ReferenceAverageMethod); + parameters["refmethod"] = enum2string(m_ReferenceMethod); + parameters["BB_OB_name"] = blackbodyname; + parameters["BB_counts"] = kipl::strings::value2string(nBBCount); + parameters["BB_first_index"] = kipl::strings::value2string(nBBFirstIndex); + parameters["BB_samplename"] = blackbodysamplename; + parameters["BB_samplecounts"] = kipl::strings::value2string(nBBSampleCount); + parameters["BB_sample_firstindex"] = kipl::strings::value2string(nBBSampleFirstIndex); + parameters["tau"] = kipl::strings::value2string(tau); + parameters["radius"] = kipl::strings::value2string(radius); + parameters["BBroi"] = kipl::strings::value2string(BBroi[0])+" "+kipl::strings::value2string(BBroi[1])+" "+kipl::strings::value2string(BBroi[2])+" "+kipl::strings::value2string(BBroi[3]); + parameters["doseBBroi"] = kipl::strings::value2string(doseBBroi[0])+" "+kipl::strings::value2string(doseBBroi[1])+" "+kipl::strings::value2string(doseBBroi[2])+" "+kipl::strings::value2string(doseBBroi[3]); + parameters["PBvariante"] = kipl::strings::bool2string(bPBvariante); + parameters["BBOption"] = enum2string(m_BBOptions); + parameters["firstAngle"] = kipl::strings::value2string(ffirstAngle); + parameters["lastAngle"] = kipl::strings::value2string(flastAngle); + parameters["X_InterpOrder"] = enum2string(m_xInterpOrder); + parameters["Y_InterpOrder"] = enum2string(m_yInterpOrder); + parameters["InterpolationMethod"] = enum2string(m_InterpMethod); + parameters["BB_OB_ext_name"] = blackbodyexternalname; + parameters["BB_sample_ext_name"] = blackbodysampleexternalname; + parameters["BB_ext_samplecounts"] = kipl::strings::value2string(nBBextCount); + parameters["BB_ext_firstindex"] = kipl::strings::value2string(nBBextFirstIndex); + parameters["SameMask"] = kipl::strings::bool2string(bSameMask); + parameters["min_area"] = kipl::strings::value2string(min_area); + parameters["ManualThreshold"] = kipl::strings::bool2string(bUseManualThresh); + parameters["thresh"]= kipl::strings::value2string(thresh); + + return parameters; +} + +void BBLogNorm::LoadReferenceImages(size_t *roi) +{ + + if (flatname.empty() && nOBCount!=0) + throw ReconException("The flat field image mask is empty",__FILE__,__LINE__); + if (darkname.empty() && nDCCount!=0) + throw ReconException("The dark current image mask is empty",__FILE__,__LINE__); + + + kipl::base::TImage myflat, mydark; + + fDarkDose=0.0f; + fFlatDose=1.0f; + std::string flatmask=path+flatname; + std::string darkmask=path+darkname; + + mydark = ReferenceLoader(darkmask,m_Config.ProjectionInfo.nDCFirstIndex,m_Config.ProjectionInfo.nDCCount,roi,0.0f,0.0f,m_Config,fDarkDose); + myflat = ReferenceLoader(flatmask,m_Config.ProjectionInfo.nOBFirstIndex,m_Config.ProjectionInfo.nOBCount,roi,1.0f,0.0f,m_Config,fFlatDose); // i don't use the bias.. beacuse i think i use it later on + SetReferenceImages(mydark,myflat); + +// switch (m_BBOptions){ +// case (ImagingAlgorithms::ReferenceImageCorrection::noBB): { +// bUseBB = false; +// bUseExternalBB = false; +// break; +// } +// case (ImagingAlgorithms::ReferenceImageCorrection::Interpolate): { +// bUseBB = true; +// bUseExternalBB = false; +// break; +// } +// case (ImagingAlgorithms::ReferenceImageCorrection::Average): { +// bUseBB = true; +// bUseExternalBB = false; +// break; +// } +// case (ImagingAlgorithms::ReferenceImageCorrection::OneToOne): { +// bUseBB = true; +// bUseExternalBB = false; +// break; +// } +// case (ImagingAlgorithms::ReferenceImageCorrection::ExternalBB): { +// bUseBB = false; // to evaluate +// bUseExternalBB = true; +// break; +// } +// default: throw ReconException("Unknown BBOption method in RobustLogNorm::Configure",__FILE__,__LINE__); + +// } + + + if (bUseExternalBB && nBBextCount!=0){ + LoadExternalBBData(roi); // they must be ready for SetReferenceImages + } + + +// if (bUseBB && nBBCount!=0 && nBBSampleCount!=0) { +// PrepareBBData(); +// } + + m_corrector.SetReferenceImages(&mflat, &mdark, (bUseBB && nBBCount!=0 && nBBSampleCount!=0), (bUseExternalBB && nBBextCount!=0), fFlatDose, fDarkDose, (bUseNormROIBB && bUseNormROI), roi, m_Config.ProjectionInfo.dose_roi); + +} + +void BBLogNorm::LoadExternalBBData(size_t *roi){ + + + if (blackbodyexternalname.empty()) + throw ReconException("The pre-processed open beam with BB image mask is empty", __FILE__, __LINE__); + if (blackbodysampleexternalname.empty() || nBBextCount==0) + throw ReconException("The pre-processed sample with BB image mask is empty", __FILE__, __LINE__); + + + kipl::base::TImage bb_ext; + kipl::base::TImage bb_sample_ext; + float dose; + float *doselist = new float[nBBextCount]; + + bb_ext = BBExternalLoader(blackbodyexternalname, m_Config, roi, dose); +// kipl::io::WriteTIFF32(bb_ext,"bb_ext.tif"); +// std::cout << "dose: " << dose << std::endl; + bb_sample_ext = BBExternalLoader(blackbodysampleexternalname, nBBextCount, roi, nBBextFirstIndex, m_Config, doselist); + + m_corrector.SetExternalBBimages(bb_ext, bb_sample_ext, dose, doselist); + +} + +void BBLogNorm::PrepareBBData(){ + + logger(kipl::logging::Logger::LogMessage,"PrepareBBData begin--"); + std::cout << "PrepareBBData begin--" << std::endl; + if (flatname.empty() && nOBCount!=0) + throw ReconException("The flat field image mask is empty",__FILE__,__LINE__); + if (darkname.empty() && nDCCount!=0) + throw ReconException("The dark current image mask is empty",__FILE__,__LINE__); + + if (blackbodyname.empty() && nBBCount!=0) + throw ReconException("The open beam image with BBs image mask is empty",__FILE__,__LINE__); + if (blackbodysamplename.empty() && nBBSampleCount!=0) + throw ReconException("The sample image with BBs image mask is empty", __FILE__,__LINE__); + + + + int diffroi[4] = {int(BBroi[0]), int(BBroi[1]), int(BBroi[2]), int(BBroi[3])}; + + m_corrector.setDiffRoi(diffroi); + m_corrector.SetRadius(radius); + m_corrector.SetTau(tau); + m_corrector.SetPBvariante(bPBvariante); + m_corrector.SetInterpolationOrderX(m_xInterpOrder); + m_corrector.SetInterpolationOrderY(m_yInterpOrder); + m_corrector.SetMinArea(min_area); + m_corrector.SetInterpolationMethod(m_InterpMethod); + +// float *bb_ob_param; +// float *bb_sample_parameters; + + size_t nProj=(m_Config.ProjectionInfo.nLastIndex-m_Config.ProjectionInfo.nFirstIndex+1)/m_Config.ProjectionInfo.nProjectionStep; + + switch (m_InterpMethod) { + case (ImagingAlgorithms::ReferenceImageCorrection::Polynomial): { + PreparePolynomialInterpolationParameters(); + + if (nBBCount!=0 && nBBSampleCount!=0) { + m_corrector.SetInterpParameters(ob_bb_param, sample_bb_param,nBBSampleCount, nProj, m_BBOptions); + } + + break; + } + case(ImagingAlgorithms::ReferenceImageCorrection::ThinPlateSplines):{ + std::cout << "ThinPlateSplines" << std::endl; + logger(kipl::logging::Logger::LogMessage,"ThinPlateSplines"); + + int nBBs = PrepareSplinesInterpolationParameters(); + + logger(kipl::logging::Logger::LogMessage,"After PrepareSplinesInterpolationParameters "); + + if (nBBCount!=0 && nBBSampleCount!=0) { + m_corrector.SetSplinesParameters(ob_bb_param, sample_bb_param, nBBSampleCount, nProj, m_BBOptions, nBBs); // i also need the coordinates. + } + break; + } + default: throw ReconException("Unknown m_InterpMethod in BBLogNorm::PrepareBBData()", __FILE__, __LINE__); + } + + + +} + +void BBLogNorm::PreparePolynomialInterpolationParameters() +{ + + kipl::base::TImage flat, dark, bb, sample, samplebb; + + std::string flatmask=path+flatname; + std::string darkmask=path+darkname; + + + fdarkBBdose=0.0f; + fFlatBBdose=1.0f; + + // reload the OB and DC into the BBroi and doseBBroi + dark = BBLoader(darkmask,m_Config.ProjectionInfo.nDCFirstIndex,m_Config.ProjectionInfo.nDCCount,0.0f,0.0f,m_Config,fdarkBBdose); + flat = BBLoader(flatmask,m_Config.ProjectionInfo.nOBFirstIndex,m_Config.ProjectionInfo.nOBCount,1.0f,0.0f,m_Config,fFlatBBdose); // to check if i have to use dosebias to remove the fdarkBBdose + + // now load OB image with BBs + + + float *bb_ob_param = new float[6]; + float *bb_sample_parameters; + + bb = BBLoader(blackbodyname,nBBFirstIndex,nBBCount,1.0f,fdarkBBdose,m_Config,fBlackDose); // this is for mask computation and dose correction (small roi) + + kipl::base::TImage obmask(bb.Dims()); + + + bb_ob_param = m_corrector.PrepareBlackBodyImage(flat,dark,bb, obmask, ferror); + + + if (bPBvariante) { + kipl::base::TImage mybb = m_corrector.InterpolateBlackBodyImage(bb_ob_param,doseBBroi); + float mydose = computedose(mybb); + fBlackDose = fBlackDose + ((1.0/tau-1.0)*mydose); + } + + + if(bUseNormROI && bUseNormROIBB){ + fBlackDose = fBlackDose<1 ? 1.0f : fBlackDose; + for (size_t i=0; i<6; i++){ + bb_ob_param[i]= bb_ob_param[i]*(fFlatBBdose-fdarkBBdose); + bb_ob_param[i]= bb_ob_param[i]/(fBlackDose*tau); // now the dose is already computed for I_OB_BB + } + } + + ob_bb_param = new float[6]; + memcpy(ob_bb_param, bb_ob_param, sizeof(float)*6); +// ob_bb_param[0] = 0.0f; +// ob_bb_param[1] = 0.0f; +// ob_bb_param[2] = 0.0f; +// ob_bb_param[3] = 0.0f; +// ob_bb_param[4] = 0.0f; +// ob_bb_param[5] = 0.0f; + + + // load sample images with BBs and sample images + + float *temp_parameters; + size_t nProj=(m_Config.ProjectionInfo.nLastIndex-m_Config.ProjectionInfo.nFirstIndex+1)/m_Config.ProjectionInfo.nProjectionStep; + size_t step = (nProj)/(nBBSampleCount); + + float angles[4] = {m_Config.ProjectionInfo.fScanArc[0], m_Config.ProjectionInfo.fScanArc[1], ffirstAngle, flastAngle}; + m_corrector.SetAngles(angles, nProj, nBBSampleCount); + +// std::cout << "doselist: " << std::endl; + + float *doselist = new float[nProj]; + for (size_t i=0; i mask(sample.Dims()); + mask = 0.0f; + temp_parameters = m_corrector.PrepareBlackBodyImage(sample,dark,samplebb, mask); + mMaskBB = mask; // or memcpy + } + + + + if (bUseNormROIBB && bUseNormROI){ + // prenormalize interpolation parameters with dose + + current_dose = fBlackDoseSample; + + if (bPBvariante) { + + kipl::base::TImage mybb = m_corrector.InterpolateBlackBodyImage(temp_parameters,doseBBroi); + float mydose = computedose(mybb); + current_dose = current_dose + ((1.0/tau-1.0)*mydose); + } + + + current_dose = current_dose<1 ? 1.0f : current_dose; + + + + for(size_t j=0; j<6; j++) { + + temp_parameters[j]/=(current_dose); + + } + } + + memcpy(bb_sample_parameters, temp_parameters, sizeof(float)*6); + + } + + else { + + temp_parameters = m_corrector.PrepareBlackBodyImagewithMask(dark,samplebb,mMaskBB); + current_dose = fBlackDoseSample; + + if (bPBvariante) { + kipl::base::TImage mybb = m_corrector.InterpolateBlackBodyImage(temp_parameters,doseBBroi); + float mydose = computedose(mybb); + current_dose = current_dose + ((1.0/tau-1.0)*mydose); + } + + current_dose = current_dose<1 ? 1.0f : current_dose; + + for(size_t j=0; j<6; j++) { + temp_parameters[j]/=(current_dose); + } + + + memcpy(bb_sample_parameters+i*6, temp_parameters, sizeof(float)*6); + + } + + + + } + } + + memcpy(sample_bb_param, bb_sample_parameters, sizeof(float)*6*nBBSampleCount); + break; + } + + case (ImagingAlgorithms::ReferenceImageCorrection::Average): { + + bb_sample_parameters = new float[6]; + sample_bb_param = new float[6]; + temp_parameters = new float[6]; + float * mask_parameters = new float[6]; + +// float angles[4] = {m_Config.ProjectionInfo.fScanArc[0], m_Config.ProjectionInfo.fScanArc[1], ffirstAngle, flastAngle}; +// m_corrector.SetAngles(angles, nProj, nBBSampleCount); + +//// std::cout << "doselist: " << std::endl; + +// float *doselist = new float[nProj]; +// for (size_t i=0; i samplebb_temp; + float dose_temp; + samplebb_temp = BBLoader(blackbodysamplename, nBBSampleFirstIndex,1,1.0f,0.0f, m_Config, dose_temp); + samplebb = BBLoader(blackbodysamplename, nBBSampleFirstIndex,nBBSampleCount,1.0f,fdarkBBdose, m_Config, fBlackDoseSample); + + + float dosesample; // used for the correct dose roi computation (doseBBroi) + float current_dose; + + int index; + index = GetnProjwithAngle(ffirstAngle); + sample = BBLoader(m_Config.ProjectionInfo.sFileMask, m_Config.ProjectionInfo.nFirstIndex+index, 1, 1.0f,fdarkBBdose,m_Config, dosesample); // load the projection with angle closest to the first BB sample data + + + if (bSameMask){ + mMaskBB = obmask;} + else { + kipl::base::TImage mask(sample.Dims()); + mask = 0.0f; + mask_parameters= m_corrector.PrepareBlackBodyImage(sample,dark,samplebb_temp, mask); // this is just to compute the mask + mMaskBB = mask; // or memcpy + } + + temp_parameters= m_corrector.PrepareBlackBodyImagewithMask(dark,samplebb, mMaskBB); + + + if (bUseNormROIBB && bUseNormROI){ + // prenormalize interpolation parameters with dose + + current_dose = fBlackDoseSample; + + if (bPBvariante) { + + kipl::base::TImage mybb = m_corrector.InterpolateBlackBodyImage(temp_parameters,doseBBroi); + float mydose = computedose(mybb); + current_dose+= ((1.0/tau-1.0)*mydose); + } + + + current_dose = current_dose<1 ? 1.0f : current_dose; + + for(size_t j=0; j<6; j++) { + + temp_parameters[j]/=current_dose; +// temp_parameters[j]*=(dosesample/tau); + } +// std::cout << std::endl; + } + + memcpy(sample_bb_param, temp_parameters, sizeof(float)*6); +// memcpy(sample_bb_param, bb_sample_parameters, sizeof(float)*6); + delete [] mask_parameters; + + break; + } + + case (ImagingAlgorithms::ReferenceImageCorrection::OneToOne): { +// std::cout << "OneToOne" << std::endl; + + bb_sample_parameters = new float[6*nBBSampleCount]; + sample_bb_param = new float[6*nBBSampleCount]; + temp_parameters = new float[6]; + + + float dosesample; + float current_dose; + + for (size_t i=0; i mask(sample.Dims()); + mask = 0.0f; + temp_parameters= m_corrector.PrepareBlackBodyImage(sample,dark,samplebb, mask); // this is just to compute the mask + mMaskBB = mask; // or memcpy + } + + if (bUseNormROIBB && bUseNormROI){ + // prenormalize interpolation parameters with dose + + current_dose= fBlackDoseSample; + + if (bPBvariante) { + + kipl::base::TImage mybb = m_corrector.InterpolateBlackBodyImage(temp_parameters,doseBBroi); // previously doseBBroi + float mydose = computedose(mybb); + current_dose += ((1.0/tau-1.0)*mydose); + } + + + current_dose = current_dose<1 ? 1.0f : current_dose; + + for(size_t j=0; j<6; j++) { + + temp_parameters[j]/=current_dose; +// temp_parameters[j]*=(dosesample/tau); + + } + } + + memcpy(bb_sample_parameters, temp_parameters, sizeof(float)*6); + + } + + else { + + temp_parameters = m_corrector.PrepareBlackBodyImagewithMask(dark,samplebb,mMaskBB); + current_dose= fBlackDoseSample; + + if (bPBvariante) { + kipl::base::TImage mybb = m_corrector.InterpolateBlackBodyImage(temp_parameters,doseBBroi); // previously doseBBroi + float mydose = computedose(mybb); + current_dose+= ((1.0/tau-1.0)*mydose); + } + + current_dose = current_dose<1 ? 1.0f : current_dose; + + + for(size_t j=0; j<6; j++) { + temp_parameters[j]/=current_dose; +// temp_parameters[j]*=(dosesample/tau); + } + + memcpy(bb_sample_parameters+i*6, temp_parameters, sizeof(float)*6); + + + } + + + + } + + memcpy(sample_bb_param, bb_sample_parameters, sizeof(float)*6*nBBSampleCount); + break; + } + + case (ImagingAlgorithms::ReferenceImageCorrection::noBB): { + throw ReconException("trying to switch to case ImagingAlgorithms::ReferenceImageCorrection::noBB in PrepareBBdata",__FILE__,__LINE__); + break; + } + case (ImagingAlgorithms::ReferenceImageCorrection::ExternalBB) : { + throw ReconException("trying to switch to case ImagingAlgorithms::ReferenceImageCorrection::ExternalBB in PrepareBBdata",__FILE__,__LINE__); + } + + default: throw ReconException("trying to switch to unknown BBOption in PrepareBBdata",__FILE__,__LINE__); + + } + +// delete [] temp_parameters; +// delete [] bb_ob_param; +// delete [] bb_sample_parameters; +} + +int BBLogNorm::PrepareSplinesInterpolationParameters() { + + kipl::base::TImage flat, dark, bb, sample, samplebb; + + std::string flatmask=path+flatname; + std::string darkmask=path+darkname; + + + fdarkBBdose=0.0f; + fFlatBBdose=1.0f; + + // reload the OB and DC into the BBroi and doseBBroi + dark = BBLoader(darkmask,m_Config.ProjectionInfo.nDCFirstIndex,m_Config.ProjectionInfo.nDCCount,0.0f,0.0f,m_Config,fdarkBBdose); + flat = BBLoader(flatmask,m_Config.ProjectionInfo.nOBFirstIndex,m_Config.ProjectionInfo.nOBCount,1.0f,0.0f,m_Config,fFlatBBdose); // + bb = BBLoader(blackbodyname,nBBFirstIndex,nBBCount,1.0f,fdarkBBdose,m_Config,fBlackDose); + + kipl::base::TImage obmask(bb.Dims()); + + float *bb_ob_param = new float[100]; // now they are not 6.. attention + float *bb_sample_parameters; + std::map, float> values; + std::map, float> values_bb; + + + bb_ob_param = m_corrector.PrepareBlackBodyImagewithSplines(flat,dark,bb, obmask, values); + +// kipl::base::TImage mythinimage = m_corrector.InterpolateBlackBodyImagewithSplines(bb_ob_param, values, BBroi); +// kipl::io::WriteTIFF32(mythinimage,"BBob_image.tif"); // this is now correct! + + + if (bPBvariante) { + kipl::base::TImage mybb = m_corrector.InterpolateBlackBodyImagewithSplines(bb_ob_param,values, doseBBroi); +// kipl::io::WriteTIFF32(mybb,"BBdose_image.tif"); // also correct + float mydose = computedose(mybb); + fBlackDose = fBlackDose + ((1.0/tau-1.0)*mydose); + } + + m_corrector.SetSplineObValues(values); + + if(bUseNormROI && bUseNormROIBB){ + fBlackDose = fBlackDose<1 ? 1.0f : fBlackDose; + for (size_t i=0; i mythinimage = m_corrector.InterpolateBlackBodyImagewithSplines(bb_ob_param, values, BBroi); +// kipl::io::WriteTIFF32(mythinimage,"BBob_image.tif"); // this is now correct! No such a big difference before and after normalization.. + + ob_bb_param = new float[values.size()+3]; + memcpy(ob_bb_param, bb_ob_param, sizeof(float)*(values.size()+3)); + +// for (size_t i=0; i mask(sample.Dims()); + mask = 0.0f; + temp_parameters = m_corrector.PrepareBlackBodyImagewithSplines(sample,dark,samplebb,mask,values_bb); + m_corrector.SetSplineSampleValues(values_bb); + +// kipl::base::TImage mythinimage = m_corrector.InterpolateBlackBodyImagewithSplines(temp_parameters, values_bb, BBroi); +// kipl::io::WriteTIFF32(mythinimage,"BBsample_image.tif"); // this is now correct! + + + mMaskBB = mask; // or memcpy + } + + + + if (bUseNormROIBB && bUseNormROI){ + // prenormalize interpolation parameters with dose + + current_dose = fBlackDoseSample; +// std:cout << "normalize dose" << std::endl; + + if (bPBvariante) { + +// kipl::base::TImage mybb = m_corrector.InterpolateBlackBodyImage(temp_parameters,doseBBroi); + kipl::base::TImage mybb = m_corrector.InterpolateBlackBodyImagewithSplines(temp_parameters, values_bb, doseBBroi); + float mydose = computedose(mybb); + current_dose = current_dose + ((1.0/tau-1.0)*mydose); + } + + + current_dose = current_dose<1 ? 1.0f : current_dose; + + + + for(size_t j=0; j mybb = m_corrector.InterpolateBlackBodyImagewithSplines(temp_parameters,values_bb,doseBBroi); +// kipl::base::TImage mybb = m_corrector.InterpolateBlackBodyImage(temp_parameters,doseBBroi); + float mydose = computedose(mybb); + current_dose = current_dose + ((1.0/tau-1.0)*mydose); + } + + current_dose = current_dose<1 ? 1.0f : current_dose; + + for(size_t j=0; j<(values_bb.size()+3); j++) { + temp_parameters[j]/=(current_dose); + } + + + memcpy(bb_sample_parameters+i*(values_bb.size()+3), temp_parameters, sizeof(float)*(values_bb.size()+3)); + + } + + + } + } + + memcpy(sample_bb_param, bb_sample_parameters, sizeof(float)*(values.size()+3)*nBBSampleCount); + break; + } + + case (ImagingAlgorithms::ReferenceImageCorrection::Average): { + + + bb_sample_parameters = new float[values.size()+3]; // i am assuming there is the same number of BBs + sample_bb_param = new float[values.size()+3]; + temp_parameters = new float[values.size()+3]; + float * mask_parameters = new float[values.size()+3]; + +// float angles[4] = {m_Config.ProjectionInfo.fScanArc[0], m_Config.ProjectionInfo.fScanArc[1], ffirstAngle, flastAngle}; +// m_corrector.SetAngles(angles, nProj, nBBSampleCount); + +// std::cout << "doselist: " << std::endl; + +// float *doselist = new float[nProj]; +// for (size_t i=0; i samplebb_temp; + float dose_temp; + samplebb_temp = BBLoader(blackbodysamplename, nBBSampleFirstIndex,1,1.0f,0.0f, m_Config, dose_temp); + samplebb = BBLoader(blackbodysamplename, nBBSampleFirstIndex,nBBSampleCount,1.0f,fdarkBBdose, m_Config, fBlackDoseSample); + + + float dosesample; // used for the correct dose roi computation (doseBBroi) + float current_dose; + + int index; + index = GetnProjwithAngle(ffirstAngle); + sample = BBLoader(m_Config.ProjectionInfo.sFileMask, m_Config.ProjectionInfo.nFirstIndex+index, 1, 1.0f,fdarkBBdose,m_Config, dosesample); // load the projection with angle closest to the first BB sample data + + + if (bSameMask){ + mMaskBB = obmask; + values_bb = values; + mask_parameters = m_corrector.PrepareBlackBodyImagewithSplinesAndMask(dark,samplebb, mMaskBB, values_bb); +// + } + else { + kipl::base::TImage mask(sample.Dims()); + mask = 0.0f; + mask_parameters = m_corrector.PrepareBlackBodyImagewithSplines(sample,dark, samplebb_temp, mask,values_bb); +// mask_parameters= m_corrector.PrepareBlackBodyImage(sample,dark,samplebb_temp, mask); // this is just to compute the mask + mMaskBB = mask; // or memcpy + } + + m_corrector.SetSplineSampleValues(values_bb); + + temp_parameters = m_corrector.PrepareBlackBodyImagewithSplinesAndMask(dark,samplebb,mMaskBB,values_bb); +// temp_parameters= m_corrector.PrepareBlackBodyImagewithMask(dark,samplebb, mMaskBB); + + + if (bUseNormROIBB && bUseNormROI){ + // prenormalize interpolation parameters with dose + + current_dose = fBlackDoseSample; + + if (bPBvariante) { + +// kipl::base::TImage mybb = m_corrector.InterpolateBlackBodyImage(temp_parameters,doseBBroi); + kipl::base::TImage mybb = m_corrector.InterpolateBlackBodyImagewithSplines(temp_parameters,values_bb, doseBBroi); + float mydose = computedose(mybb); + current_dose+= ((1.0/tau-1.0)*mydose); + } + + + current_dose = current_dose<1 ? 1.0f : current_dose; + + for(size_t j=0; j<(values_bb.size()+3); j++) { + + temp_parameters[j]/=current_dose; +// temp_parameters[j]*=(dosesample/tau); + } +// std::cout << std::endl; + } + + memcpy(sample_bb_param, temp_parameters, sizeof(float)*(values.size()+3)); +// memcpy(sample_bb_param, bb_sample_parameters, sizeof(float)*(values.size()+3)); + delete [] mask_parameters; + + break; + } + + case (ImagingAlgorithms::ReferenceImageCorrection::OneToOne): { + + bb_sample_parameters = new float[(values.size()+3)*nBBSampleCount]; + sample_bb_param = new float[(values.size()+3)*nBBSampleCount]; + temp_parameters = new float[values.size()+3]; + + float dosesample; + float current_dose; + + for (size_t i=0; i mask(sample.Dims()); + mask = 0.0f; + temp_parameters = m_corrector.PrepareBlackBodyImagewithSplines(sample,dark,samplebb,mask,values_bb); +// temp_parameters= m_corrector.PrepareBlackBodyImage(sample,dark,samplebb, mask); // this is just to compute the mask + mMaskBB = mask; // or memcpy + m_corrector.SetSplineSampleValues(values_bb); + } + + if (bUseNormROIBB && bUseNormROI){ +// prenormalize interpolation parameters with dose + + current_dose= fBlackDoseSample; + + + if (bPBvariante) { + kipl::base::TImage mybb = m_corrector.InterpolateBlackBodyImagewithSplines(temp_parameters,values_bb,doseBBroi); +// kipl::base::TImage mybb = m_corrector.InterpolateBlackBodyImage(temp_parameters,doseBBroi); // previously doseBBroi + float mydose = computedose(mybb); + current_dose += ((1.0/tau-1.0)*mydose); + } + + + current_dose = current_dose<1 ? 1.0f : current_dose; + + for(size_t j=0; j<(values.size()+3); j++) { + + temp_parameters[j]/=current_dose; +// temp_parameters[j]*=(dosesample/tau); + + } + } + + memcpy(bb_sample_parameters, temp_parameters, sizeof(float)*(values.size()+3)); + + + } + + else { + + temp_parameters = m_corrector.PrepareBlackBodyImagewithSplinesAndMask(dark,samplebb,mMaskBB,values_bb); +// temp_parameters = m_corrector.PrepareBlackBodyImagewithMask(dark,samplebb,mMaskBB); + current_dose= fBlackDoseSample; + + if (bPBvariante) { + kipl::base::TImage mybb = m_corrector.InterpolateBlackBodyImagewithSplines(temp_parameters, values_bb, doseBBroi); +// kipl::base::TImage mybb = m_corrector.InterpolateBlackBodyImage(temp_parameters,doseBBroi); // previously doseBBroi + float mydose = computedose(mybb); + current_dose+= ((1.0/tau-1.0)*mydose); + } + + current_dose = current_dose<1 ? 1.0f : current_dose; + + + for(size_t j=0; j<(values.size()+3); j++) { + temp_parameters[j]/=current_dose; +// temp_parameters[j]*=(dosesample/tau); + } + + memcpy(bb_sample_parameters+i*(values.size()+3), temp_parameters, sizeof(float)*(values.size()+3)); + + + } + + float dose = dosesample/(current_dose*tau); + +// ofstream spline_values; +// spline_values.open(("tps_points_"+std::to_string(i)+".txt").c_str()); +// for (std::map, float>::const_iterator it = values_bb.begin(); it != values_bb.end(); ++it) +// { +// spline_values << it->first.first << " " << it->first.second << " " << it->second << std::endl; +// } + +// spline_values.close(); +// std::cout << "image #: " << i << std::endl; + } + +// std::cout << "before mempcy" << std::endl; + memcpy(sample_bb_param, bb_sample_parameters, sizeof(float)*(values.size()+3)*nBBSampleCount); +// std::cout << "after memcpy" << std::endl; + break; + } + + case (ImagingAlgorithms::ReferenceImageCorrection::noBB): { + throw ReconException("trying to switch to case ImagingAlgorithms::ReferenceImageCorrection::noBB in PrepareBBdata",__FILE__,__LINE__); + break; + } + case (ImagingAlgorithms::ReferenceImageCorrection::ExternalBB) : { + throw ReconException("trying to switch to case ImagingAlgorithms::ReferenceImageCorrection::ExternalBB in PrepareBBdata",__FILE__,__LINE__); + } + + default: throw ReconException("trying to switch to unknown BBOption in PrepareBBdata",__FILE__,__LINE__); + + } + +// delete [] temp_parameters; +// delete [] bb_ob_param; +// delete [] bb_sample_parameters; + + + return values.size(); + +} + +int BBLogNorm::GetnProjwithAngle(float angle){ + + // range of projection angles + double nProj=((double)m_Config.ProjectionInfo.nLastIndex-(double)m_Config.ProjectionInfo.nFirstIndex+1)/(double)m_Config.ProjectionInfo.nProjectionStep; + + int index =0; + float curr_angle; + + for (size_t i=0; i=angle-0.5f) { + break; + } + else index++; + + } + + + return index; +} + +float BBLogNorm::GetInterpolationError(kipl::base::TImage &mask){ + +// std::cout << "GetInterpolationError begin.." << std::endl; + if (flatname.empty() && nOBCount!=0) + throw ReconException("The flat field image mask is empty",__FILE__,__LINE__); + if (darkname.empty() && nDCCount!=0) + throw ReconException("The dark current image mask is empty",__FILE__,__LINE__); + + if (blackbodyname.empty() && nBBCount!=0) + throw ReconException("The open beam image with BBs image mask is empty",__FILE__,__LINE__); + + kipl::base::TImage flat, dark, bb; + + std::string flatmask=path+flatname; + std::string darkmask=path+darkname; + + + + float darkdose = 0.0f; + float flatdose = 1.0f; + float blackdose = 1.0f; + +// std::cout << "before BB loader" <(BBroi[0]), + static_cast(BBroi[1]), + static_cast(BBroi[2]), + static_cast(BBroi[3])}; // it is now just the BBroi position, makes more sense + +// std::cout << "before set corrector" < obmask(bb.Dims()); + bb_ob_param = m_corrector.PrepareBlackBodyImage(flat,dark,bb, obmask, error); + mask = obmask; + +// std::cout << "after PrepareBlackBodyImage" < BBLogNorm::GetMaskImage(){ + return mMaskBB; +} + +float BBLogNorm::computedose(kipl::base::TImage&img){ + + float *pImg=img.GetDataPtr(); + float *means=new float[img.Size(1)]; + memset(means,0,img.Size(1)*sizeof(float)); + + for (size_t y=0; y(img.Size(0)); + } + + float dose; + kipl::math::median(means,img.Size(1),&dose); + delete [] means; + return dose; + + +} + +int BBLogNorm::ProcessCore(kipl::base::TImage & img, std::map & coeff) +{ + + return 0; +} + +int BBLogNorm::ProcessCore(kipl::base::TImage & img, std::map & coeff) { + + int nDose=img.Size(2); + float *doselist=nullptr; + + std::stringstream msg; + + if (bUseNormROI==true) { + doselist=new float[nDose]; + GetFloatParameterVector(coeff,"dose",doselist,nDose); + for (int i=0; i dark, kipl::base::TImage flat) +{ + + mdark = dark; + mdark.Clone(); + + mflat = flat; + mflat.Clone(); + + + +// m_corrector.SetReferenceImages(&mflat, &mdark, (bUseBB && nBBCount!=0 && nBBSampleCount!=0), (bUseExternalBB && nBBextCount!=0), fFlatDose, fDarkDose, (bUseNormROIBB && bUseNormROI), m_Config.ProjectionInfo.roi, m_Config.ProjectionInfo.dose_roi); + + if (m_Config.ProjectionInfo.imagetype==ReconConfig::cProjections::ImageType_Proj_RepeatSinogram) { + for (int i=1; i(flat.Size(1)); i++) { + memcpy(flat.GetLinePtr(i),flat.GetLinePtr(0),sizeof(float)*flat.Size(0)); } + } + +} + + +kipl::base::TImage BBLogNorm::ReferenceLoader(std::string fname, + int firstIndex, int N, size_t *roi, + float initialDose, + float doseBias, + ReconConfig &config, + float &dose) +{ + std::ostringstream msg; + + kipl::base::TImage img, refimg; + + float tmpdose = 0.0f; + + if (fname.empty() && N!=0) + throw ReconException("The reference image file name mask is empty",__FILE__,__LINE__); + + std::string fmask=fname; + + std::string filename,ext; + ProjectionReader reader; + size_t found; + + dose = initialDose; // A precaution in case no dose is calculated + + if (N!=0) { + msg.str(""); msg<<"Loading "<(N)}; + + kipl::base::TImage img3D(obdims); + memcpy(img3D.GetLinePtr(0,0),img.GetDataPtr(),img.Size()*sizeof(float)); + + for (int i=1; i(N); + msg.str(""); msg<<"Dose="< BBLogNorm::BBLoader(std::string fname, + int firstIndex, int N, + float initialDose, + float doseBias, + ReconConfig &config, + float &dose) +{ + std::ostringstream msg; + + kipl::base::TImage img, refimg; + + float tmpdose = 0.0f; + + if (fname.empty() && N!=0) + throw ReconException("The reference image file name mask is empty",__FILE__,__LINE__); + + std::string fmask=fname; + + std::string filename,ext; + ProjectionReader reader; + size_t found; + + dose = initialDose; // A precaution in case no dose is calculated + + if (N!=0) { + msg.str(""); msg<<"Loading "<(N)}; + + kipl::base::TImage img3D(obdims); + memcpy(img3D.GetLinePtr(0,0),img.GetDataPtr(),img.Size()*sizeof(float)); + + for (int i=1; i(N); + msg.str(""); msg<<"Dose="< BBLogNorm::BBExternalLoader(std::string fname, ReconConfig &config, size_t *roi, float &dose){ + + + kipl::base::TImage img; + + if (fname.empty()) + throw ReconException("The reference image file name mask is empty",__FILE__,__LINE__); + + ProjectionReader reader; + + img = reader.Read(fname, + config.ProjectionInfo.eFlip, + config.ProjectionInfo.eRotate, + config.ProjectionInfo.fBinning, + roi); + + dose = bUseNormROI ? reader.GetProjectionDose(fname, + config.ProjectionInfo.eFlip, + config.ProjectionInfo.eRotate, + config.ProjectionInfo.fBinning, + nOriginalNormRegion) : 0.0f; + + + return img; + +} + +kipl::base::TImage BBLogNorm::BBExternalLoader(std::string fname, int N, size_t *roi, int firstIndex, ReconConfig &config, float *doselist){ + + + kipl::base::TImage tempimg; + kipl::base::TImage img; + + + + if (fname.empty() && N!=0) + throw ReconException("The reference image file name mask is empty",__FILE__,__LINE__); + + float *mylist = new float[N]; + + std::string fmask=fname; + + std::string filename,ext; + ProjectionReader reader; + + if (N!=0) { + + + for (int i=0; i(N)}; + img.Resize(dims); + } + + + mylist[i] = bUseNormROI ? reader.GetProjectionDose(filename, + config.ProjectionInfo.eFlip, + config.ProjectionInfo.eRotate, + config.ProjectionInfo.fBinning, + nOriginalNormRegion) : 0.0f; + + + memcpy(img.GetLinePtr(0,i),tempimg.GetDataPtr(),tempimg.Size()*sizeof(float)); + + } + memcpy(doselist, mylist, sizeof(float)*N); + + if (m_Config.ProjectionInfo.imagetype==ReconConfig::cProjections::ImageType_Proj_RepeatSinogram) { + float *pFlat=img.GetDataPtr(); + for (size_t i=1; i + +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include + +#include "bblognormdlg.h" +#include "ui_bblognormdlg.h" + +BBLogNormDlg::BBLogNormDlg(QWidget *parent) : + ConfiguratorDialogBase("BBLogNorm",true,false,true,parent), + ui(new Ui::BBLogNormDlg), + nBBCount(0), + nBBFirstIndex(1), + nBBSampleCount(0), + nBBSampleFirstIndex(1), + radius(2), +// bUseNormROI(true), +// bUseNormROIBB(false), + tau(0.99f), + bPBvariante(true), + bSameMask(true), + bUseManualThresh(false), + m_nWindow(5), + m_ReferenceAverageMethod(ImagingAlgorithms::AverageImage::ImageWeightedAverage), + m_ReferenceMethod(ImagingAlgorithms::ReferenceImageCorrection::ReferenceLogNorm), + m_BBOptions(ImagingAlgorithms::ReferenceImageCorrection::Interpolate), + m_xInterpOrder(ImagingAlgorithms::ReferenceImageCorrection::SecondOrder_x), + m_yInterpOrder(ImagingAlgorithms::ReferenceImageCorrection::SecondOrder_y), + m_InterpMethod(ImagingAlgorithms::ReferenceImageCorrection::Polynomial), + ffirstAngle(0.0f), + flastAngle(360.0f), + nBBextCount(0), + nBBextFirstIndex(0), + min_area(20), + thresh(0) +{ + + blackbodyname = "somename"; + blackbodysamplename = "somename"; + doseBBroi[0] = doseBBroi[1] = doseBBroi[2] = doseBBroi[3] = 0; + BBroi[0] = BBroi[1] = BBroi[2] = BBroi[3] = 0; + + blackbodyexternalname = "./"; + blackbodysampleexternalname = "./"; + + try{ + ui->setupUi(this); + } + + catch (ModuleException & e) + { + logger(kipl::logging::Logger::LogWarning,e.what()); + } + + + +} + +BBLogNormDlg::~BBLogNormDlg() +{ + delete ui; +} + + +int BBLogNormDlg::exec(ConfigBase *config, std::map ¶meters, kipl::base::TImage &img) { + + m_Config=dynamic_cast(config); + + + try{ + nBBFirstIndex = GetIntParameter(parameters,"BB_first_index"); + nBBCount = GetIntParameter(parameters,"BB_counts"); + blackbodyname = GetStringParameter(parameters,"BB_OB_name"); + nBBSampleFirstIndex = GetIntParameter(parameters,"BB_sample_firstindex"); + nBBSampleCount = GetIntParameter(parameters,"BB_samplecounts"); + blackbodysamplename = GetStringParameter(parameters, "BB_samplename"); + GetUIntParameterVector(parameters,"BBroi",BBroi,4); + GetUIntParameterVector(parameters,"doseBBroi",doseBBroi,4); + radius = GetIntParameter(parameters,"radius"); +// bUseNormROIBB = kipl::strings::string2bool(GetStringParameter(parameters,"useBBnormregion")); + tau = GetFloatParameter(parameters, "tau"); + bPBvariante = kipl::strings::string2bool(GetStringParameter(parameters,"PBvariante")); + string2enum(GetStringParameter(parameters,"avgmethod"),m_ReferenceAverageMethod); + string2enum(GetStringParameter(parameters,"refmethod"), m_ReferenceMethod); + string2enum(GetStringParameter(parameters,"BBOption"), m_BBOptions); + m_nWindow = GetIntParameter(parameters,"window"); + ffirstAngle = GetFloatParameter(parameters,"firstAngle"); + flastAngle = GetFloatParameter(parameters,"lastAngle"); + string2enum(GetStringParameter(parameters,"X_InterpOrder"), m_xInterpOrder); + string2enum(GetStringParameter(parameters,"Y_InterpOrder"), m_yInterpOrder); + string2enum(GetStringParameter(parameters,"InterpolationMethod"), m_InterpMethod); + + blackbodyexternalname = GetStringParameter(parameters,"BB_OB_ext_name"); + blackbodysampleexternalname = GetStringParameter(parameters,"BB_sample_ext_name"); + nBBextCount = GetIntParameter(parameters,"BB_ext_samplecounts"); + nBBextFirstIndex = GetIntParameter(parameters,"BB_ext_firstindex"); + bSameMask = kipl::strings::string2bool(GetStringParameter(parameters,"SameMask")); + bUseManualThresh = kipl::strings::string2bool(GetStringParameter(parameters,"ManualThreshold")); + thresh = GetFloatParameter(parameters,"thresh"); + min_area = GetIntParameter(parameters, "min_area"); + +// bUseExternalBB = kipl::strings::string2bool(GetStringParameter(parameters,"useExternalBB")); // not sure I need those here +// bUseBB = kipl::strings::string2bool(GetStringParameter(parameters, "useBB")); + + + + + } + catch(ModuleException &e){ + logger(kipl::logging::Logger::LogWarning,e.what()); + return false; + + QMessageBox error_dlg; + error_dlg.setWindowTitle("Error"); + error_dlg.setText("Module exception"); + error_dlg.setDetailedText(QString::fromStdString(e.what())); + + } + + UpdateDialog(); + + try { + ApplyParameters(); + } + catch (kipl::base::KiplException &e) { + logger(kipl::logging::Logger::LogError,e.what()); + return false; + } + + + if (enum2string(m_BBOptions)=="noBB" || enum2string(m_BBOptions)=="ExternalBB") { + ui->tabWidget->setTabEnabled(1, false); + } // not sure this is the right place + + if (enum2string(m_BBOptions)!="ExternalBB"){ + ui->group_externalBB->setEnabled(false); + } + else { + ui->group_externalBB->setEnabled(true); + } + + + + int res=QDialog::exec(); + + + if (res==QDialog::Accepted) { + logger(kipl::logging::Logger::LogMessage,"Use settings"); + UpdateParameters(); + UpdateParameterList(parameters); + return true; + } + else { + logger(kipl::logging::Logger::LogMessage,"Discard settings"); + } + + return res; + + +} + +void BBLogNormDlg::ApplyParameters(){ + + //std::cout << "apply parameters" << std::endl; + + ui->buttonPreviewOBBB->click(); + ui->buttonPreviewsampleBB->click(); + + + UpdateDoseROI(); + UpdateBBROI(); + + + std::map parameters; + UpdateParameterList(parameters); + + + +} + +void BBLogNormDlg::UpdateDialog(){ + + UpdateDoseROI(); + UpdateBBROI(); + + ui->spinFirstOBBB->setValue(nBBFirstIndex); + ui->spinCountsOBBB->setValue(nBBCount); + ui->edit_OB_BB_mask->setText(QString::fromStdString(blackbodyname)); + ui->spinx0BBroi->setValue(BBroi[0]); + ui->spinx1BBroi->setValue(BBroi[2]); + ui->spiny0BBroi->setValue(BBroi[1]); + ui->spiny1BBroi->setValue(BBroi[3]); + + ui->spinFirstsampleBB->setValue(nBBSampleFirstIndex); + ui->spinCountsampleBB->setValue(nBBSampleCount); + ui->edit_sample_BB_mask->setText(QString::fromStdString(blackbodysamplename)); + ui->spinx0BBdose->setValue(doseBBroi[0]); + ui->spinx1BBdose->setValue(doseBBroi[2]); + ui->spiny0BBdose->setValue(doseBBroi[1]); + ui->spiny1BBdose->setValue(doseBBroi[3]); + + ui->spinRadius->setValue(static_cast(radius)); + ui->combo_averagingMethod->setCurrentText(QString::fromStdString(enum2string(m_ReferenceAverageMethod))); + ui->combo_referencingmethod->setCurrentText(QString::fromStdString(enum2string(m_ReferenceMethod))); + ui->combo_BBoptions->setCurrentText(QString::fromStdString(enum2string(m_BBOptions))); + ui->combo_IntMeth_X->setCurrentText(QString::fromStdString(enum2string(m_xInterpOrder))); + ui->combo_IntMeth_Y->setCurrentText(QString::fromStdString(enum2string(m_yInterpOrder))); + + ui->edit_OBBB_ext->setText(QString::fromStdString(blackbodyexternalname)); + ui->edit_BB_external->setText(QString::fromStdString(blackbodysampleexternalname)); + ui->spin_first_extBB->setValue(nBBextFirstIndex); + ui->spin_count_ext_BB->setValue(nBBextCount); + + ui->combo_InterpolationMethod->setCurrentText(QString::fromStdString(enum2string(m_InterpMethod))); + ui->checkBox_thresh->setChecked(bUseManualThresh); + ui->spinThresh->setValue(thresh); + + + +// std::cout << "ui->combo_averagingMethod->currentIndex(): " << ui->combo_averagingMethod->currentText().toStdString()<< std::endl; + ui->spinFirstAngle->setValue(ffirstAngle); + ui->spinLastAngle->setValue(flastAngle); + ui->spin_minarea->setValue(min_area); + + +// std::cout << "update dialog" << std::endl; + +} + +void BBLogNormDlg::UpdateParameters(){ + + + nBBFirstIndex = ui->spinFirstOBBB->value(); + nBBCount = ui->spinCountsOBBB->value(); + blackbodyname = ui->edit_OB_BB_mask->text().toStdString(); + BBroi[0] = ui->spinx0BBroi->value(); + BBroi[1] = ui->spiny0BBroi->value(); + BBroi[2] = ui->spinx1BBroi->value(); + BBroi[3] = ui->spiny1BBroi->value(); + + nBBSampleFirstIndex =ui->spinFirstsampleBB->value(); + nBBSampleCount = ui->spinCountsampleBB->value(); + blackbodysamplename = ui->edit_sample_BB_mask->text().toStdString(); + doseBBroi[0] = ui->spinx0BBdose->value(); + doseBBroi[1] = ui->spiny0BBdose->value(); + doseBBroi[2] = ui->spinx1BBdose->value(); + doseBBroi[3] = ui->spiny1BBdose->value(); + +// if ( (doseBBroi[3]-doseBBroi[1])>0 && (doseBBroi[2]-doseBBroi[0]>0)) { +// bUseNormROIBB = true; +// std::cout << "----------------" << bUseNormROIBB << std::endl; +// } else { +// bUseNormROIBB = false; +// std::cout << "---------------------" << bUseNormROIBB << std::endl; +// } + + radius = static_cast(ui->spinRadius->value()); + string2enum(ui->combo_averagingMethod->currentText().toStdString(), m_ReferenceAverageMethod); + string2enum(ui->combo_referencingmethod->currentText().toStdString(), m_ReferenceMethod); + string2enum(ui->combo_BBoptions->currentText().toStdString(), m_BBOptions); + string2enum(ui->combo_IntMeth_X->currentText().toStdString(), m_xInterpOrder); + string2enum(ui->combo_IntMeth_Y->currentText().toStdString(), m_yInterpOrder); + string2enum(ui->combo_InterpolationMethod->currentText().toStdString(), m_InterpMethod); + + ffirstAngle = ui->spinFirstAngle->value(); + flastAngle = ui->spinLastAngle->value(); + + blackbodyexternalname = ui->edit_OBBB_ext->text().toStdString(); + blackbodysampleexternalname = ui->edit_BB_external->text().toStdString(); + nBBextFirstIndex = ui->spin_first_extBB->value(); + nBBextCount = ui->spin_count_ext_BB->value(); + + min_area = ui->spin_minarea->value(); + + bUseManualThresh = ui->checkBox_thresh->isChecked(); + thresh = ui->spinThresh->value(); + +// std::cout << "update parameters " << std::endl; +// std::cout << ui->edit_OB_BB_mask->text().toStdString() << std::endl; +// std::cout << blackbodyname << std::endl; + +} + +void BBLogNormDlg::UpdateParameterList(std::map ¶meters){ + + parameters["BB_OB_name"] = blackbodyname; + parameters["BB_counts"] = kipl::strings::value2string(nBBCount); + parameters["BB_first_index"] = kipl::strings::value2string(nBBFirstIndex); + parameters["BBroi"] = kipl::strings::value2string(BBroi[0])+" "+kipl::strings::value2string(BBroi[1])+" "+kipl::strings::value2string(BBroi[2])+" "+kipl::strings::value2string(BBroi[3]); + + parameters["BB_samplename"] = blackbodysamplename; + parameters["BB_samplecounts"] = kipl::strings::value2string(nBBSampleCount); + parameters["BB_sample_firstindex"] = kipl::strings::value2string(nBBSampleFirstIndex); + parameters["doseBBroi"] = kipl::strings::value2string(doseBBroi[0])+" "+kipl::strings::value2string(doseBBroi[1])+" "+kipl::strings::value2string(doseBBroi[2])+" "+kipl::strings::value2string(doseBBroi[3]); + + parameters["radius"] = kipl::strings::value2string(radius); + + parameters["avgmethod"] = enum2string(m_ReferenceAverageMethod); + parameters["refmethod"] = enum2string(m_ReferenceMethod); + parameters["BBOption"] = enum2string(m_BBOptions); + parameters["InterpolationMethod"] = enum2string(m_InterpMethod); + parameters["tau"] = kipl::strings::value2string(tau); +// parameters["useBBnormregion"] = kipl::strings::bool2string(bUseNormROIBB); + parameters["PBvariante"] = kipl::strings::bool2string(bPBvariante); +// parameters["usenormregion"] = kipl::strings::bool2string(bUseNormROI); + parameters["window"] = kipl::strings::value2string(m_nWindow); + parameters["firstAngle"] = kipl::strings::value2string(ffirstAngle); + parameters["lastAngle"] = kipl::strings::value2string(flastAngle); + parameters["X_InterpOrder"] = enum2string(m_xInterpOrder); + parameters["Y_InterpOrder"] = enum2string(m_yInterpOrder); + + parameters["BB_OB_ext_name"] = blackbodyexternalname; + parameters["BB_sample_ext_name"] = blackbodysampleexternalname; + parameters["BB_ext_samplecounts"] = kipl::strings::value2string(nBBextCount); + parameters["BB_ext_firstindex"] = kipl::strings::value2string(nBBextFirstIndex); + parameters["SameMask"] = kipl::strings::bool2string(bSameMask); + parameters["ManualThreshold"] = kipl::strings::bool2string(bUseManualThresh); + parameters["min_area"] = kipl::strings::value2string(min_area); + parameters["thresh"]= kipl::strings::value2string(thresh); + +// parameters["useBB"] = kipl::strings::bool2string(bUseBB); +// parameters["useExternalBB"] = kipl::strings::bool2string(bUseExternalBB); + + + +// std::cout << "update parameters list" << std::endl; + +} + +void BBLogNormDlg::on_button_OBBBpath_clicked() +{ + BrowseOBBBPath(); + ui->buttonPreviewOBBB->click(); +} + +void BBLogNormDlg::BrowseOBBBPath(){ + + QString ob_bb_dir=QFileDialog::getOpenFileName(this, + "Select location of the open beam images with BB", + ui->edit_OB_BB_mask->text()); + + if (!ob_bb_dir.isEmpty()) { + std::string pdir=ob_bb_dir.toStdString(); + + #ifdef _MSC_VER + const char slash='\\'; + #else + const char slash='/'; + #endif + ptrdiff_t pos=pdir.find_last_of(slash); + + QString path(QString::fromStdString(pdir.substr(0,pos+1))); + std::string fname=pdir.substr(pos+1); + kipl::io::DirAnalyzer da; + kipl::io::FileItem fi=da.GetFileMask(pdir); + + if (fi.m_sExt=="hdf"){ + ui->edit_OB_BB_mask->setText(QString::fromStdString(pdir)); + + ProjectionReader reader; + size_t Nofimgs[2]; + reader.GetNexusInfo(pdir,Nofimgs,NULL); + ui->spinFirstOBBB->setValue(Nofimgs[0]); + ui->spinCountsOBBB->setValue(Nofimgs[1]); + } + else { + ui->edit_OB_BB_mask->setText(QString::fromStdString(fi.m_sMask)); + int c=0; + int f=0; + int l=0; + da.AnalyzeMatchingNames(fi.m_sMask,c,f,l); + ui->spinFirstOBBB->setValue(f); + ui->spinCountsOBBB->setValue(c); + } + } + + +} + + +void BBLogNormDlg::on_buttonPreviewOBBB_clicked() +{ + + UpdateParameters(); + + + std::string filename, ext; + kipl::strings::filenames::MakeFileName(blackbodyname,nBBFirstIndex,filename,ext,'#','0'); + size_t found=blackbodyname.find("hdf"); + ProjectionReader reader; + if (QFile::exists(QString::fromStdString(filename)) || QFile::exists(QString::fromStdString(blackbodyname)) && blackbodyname!="./") + { + if (found==std::string::npos ) + { + m_Preview_OBBB = reader.Read(filename, + m_Config->ProjectionInfo.eFlip, + m_Config->ProjectionInfo.eRotate, + m_Config->ProjectionInfo.fBinning, + NULL); + } + else { + m_Preview_OBBB = reader.ReadNexus(blackbodyname, 0, + m_Config->ProjectionInfo.eFlip, + m_Config->ProjectionInfo.eRotate, + m_Config->ProjectionInfo.fBinning, + NULL); + } + float lo,hi; + + // if (x < 0) { + const size_t NHist=512; + size_t hist[NHist]; + float axis[NHist]; + size_t nLo=0; + size_t nHi=0; + kipl::base::Histogram(m_Preview_OBBB.GetDataPtr(),m_Preview_OBBB.Size(),hist,NHist,0.0f,0.0f,axis); + kipl::base::FindLimits(hist, NHist, 99.0f, &nLo, &nHi); + lo=axis[nLo]; + hi=axis[nHi]; + + ui->ob_bb_Viewer->set_image(m_Preview_OBBB.GetDataPtr(), m_Preview_OBBB.Dims(), lo,hi); + } + + +} + +void BBLogNormDlg::on_button_BBroi_clicked() +{ + QRect rect=ui->ob_bb_Viewer->get_marked_roi(); + + if (rect.width()*rect.height()!=0) + { +// ui->spinx0BBroi->blockSignals(true); +// ui->spiny0BBroi->blockSignals(true); +// ui->spinx1BBroi->blockSignals(true); +// ui->spiny1BBroi->blockSignals(true); + ui->spinx0BBroi->setValue(rect.x()); + ui->spiny0BBroi->setValue(rect.y()); + ui->spinx1BBroi->setValue(rect.x()+rect.width()); + ui->spiny1BBroi->setValue(rect.y()+rect.height()); +// ui->spinx0BBroi->blockSignals(false); +// ui->spiny0BBroi->blockSignals(false); +// ui->spinx1BBroi->blockSignals(false); +// ui->spiny1BBroi->blockSignals(false); + UpdateBBROI(); + } +} + +void BBLogNormDlg::UpdateBBROI() +{ + QRect rect; + + rect.setCoords(ui->spinx0BBroi->value(), + ui->spiny0BBroi->value(), + ui->spinx1BBroi->value(), + ui->spiny1BBroi->value()); + + ui->ob_bb_Viewer->set_rectangle(rect,QColor("green").light(),0); +} + +void BBLogNormDlg::on_spinx0BBroi_valueChanged(int arg1) +{ + UpdateBBROI(); +} + +void BBLogNormDlg::on_spinx1BBroi_valueChanged(int arg1){ UpdateBBROI(); } +void BBLogNormDlg::on_spiny0BBroi_valueChanged(int arg1){ UpdateBBROI(); } +void BBLogNormDlg::on_spiny1BBroi_valueChanged(int arg1){ UpdateBBROI(); } + + + +void BBLogNormDlg::on_button_sampleBBpath_clicked() +{ + BrowseSampleBBPath(); + ui->buttonPreviewsampleBB->click(); +} + +void BBLogNormDlg::BrowseSampleBBPath(){ + + QString sample_bb_dir=QFileDialog::getOpenFileName(this, + "Select location of the open beam images with BB", + ui->edit_sample_BB_mask->text()); + + if (!sample_bb_dir.isEmpty()) { + std::string pdir=sample_bb_dir.toStdString(); + + #ifdef _MSC_VER + const char slash='\\'; + #else + const char slash='/'; + #endif + ptrdiff_t pos=pdir.find_last_of(slash); + + QString path(QString::fromStdString(pdir.substr(0,pos+1))); + std::string fname=pdir.substr(pos+1); + kipl::io::DirAnalyzer da; + kipl::io::FileItem fi=da.GetFileMask(pdir); + + if (fi.m_sExt=="hdf"){ + ui->edit_sample_BB_mask->setText(QString::fromStdString(pdir)); + ProjectionReader reader; + size_t Nofimgs[2]; + double Angles[2]; + reader.GetNexusInfo(pdir, Nofimgs, Angles); + ui->spinFirstsampleBB->setValue(Nofimgs[0]); + ui->spinCountsampleBB->setValue(Nofimgs[1]); + ui->spinFirstAngle->setValue(Angles[0]); + ui->spinLastAngle->setValue(Angles[1]); + } + else { + ui->edit_sample_BB_mask->setText(QString::fromStdString(fi.m_sMask)); + int c=0; + int f=0; + int l=0; + da.AnalyzeMatchingNames(fi.m_sMask,c,f,l); + ui->spinFirstsampleBB->setValue(f); + ui->spinCountsampleBB->setValue(c); + } + } + +} + +void BBLogNormDlg::on_buttonPreviewsampleBB_clicked() +{ + UpdateParameters(); + + + std::string filename, ext; + kipl::strings::filenames::MakeFileName(blackbodysamplename,nBBSampleFirstIndex,filename,ext,'#','0'); + ProjectionReader reader; + + if (QFile::exists(QString::fromStdString(filename))) + { + m_Preview_sampleBB = reader.Read(filename, + m_Config->ProjectionInfo.eFlip, + m_Config->ProjectionInfo.eRotate, + m_Config->ProjectionInfo.fBinning, + NULL); + + + float lo,hi; + + // if (x < 0) { + const size_t NHist=512; + size_t hist[NHist]; + float axis[NHist]; + size_t nLo=0; + size_t nHi=0; + kipl::base::Histogram(m_Preview_OBBB.GetDataPtr(),m_Preview_OBBB.Size(),hist,NHist,0.0f,0.0f,axis); + kipl::base::FindLimits(hist, NHist, 99.0f, &nLo, &nHi); + lo=axis[nLo]; + hi=axis[nHi]; + + ui->sample_bb_Viewer->set_image(m_Preview_sampleBB.GetDataPtr(), m_Preview_sampleBB.Dims(), lo,hi); + + // } + // else { + + // ui->projectionViewer->get_levels(&lo,&hi); + // ui->projectionViewer->set_image(m_PreviewImage.GetDataPtr(),m_PreviewImage.Dims(),lo,hi); + // } + } + + if (QFile::exists(QString::fromStdString(blackbodysamplename)) && blackbodysamplename!="./") { + m_Preview_sampleBB = reader.ReadNexus(blackbodysamplename, nBBSampleFirstIndex, + m_Config->ProjectionInfo.eFlip, + m_Config->ProjectionInfo.eRotate, + m_Config->ProjectionInfo.fBinning, + NULL); + float lo,hi; + + // if (x < 0) { + const size_t NHist=512; + size_t hist[NHist]; + float axis[NHist]; + size_t nLo=0; + size_t nHi=0; + kipl::base::Histogram(m_Preview_OBBB.GetDataPtr(),m_Preview_OBBB.Size(),hist,NHist,0.0f,0.0f,axis); + kipl::base::FindLimits(hist, NHist, 99.0f, &nLo, &nHi); + lo=axis[nLo]; + hi=axis[nHi]; + + ui->sample_bb_Viewer->set_image(m_Preview_sampleBB.GetDataPtr(), m_Preview_sampleBB.Dims(), lo,hi); + + // } + // else { + + // ui->projectionViewer->get_levels(&lo,&hi); + // ui->projectionViewer->set_image(m_PreviewImage.GetDataPtr(),m_PreviewImage.Dims(),lo,hi); + // } + + } + +} + +void BBLogNormDlg::on_button_BBdose_clicked() +{ + QRect rect=ui->sample_bb_Viewer->get_marked_roi(); + + if (rect.width()*rect.height()!=0) + { + ui->spinx0BBdose->blockSignals(true); + ui->spiny0BBdose->blockSignals(true); + ui->spinx1BBdose->blockSignals(true); + ui->spiny1BBdose->blockSignals(true); + ui->spinx0BBdose->setValue(rect.x()); + ui->spiny0BBdose->setValue(rect.y()); + ui->spinx1BBdose->setValue(rect.x()+rect.width()); + ui->spiny1BBdose->setValue(rect.y()+rect.height()); + ui->spinx0BBdose->blockSignals(false); + ui->spiny0BBdose->blockSignals(false); + ui->spinx1BBdose->blockSignals(false); + ui->spiny1BBdose->blockSignals(false); + UpdateDoseROI(); + } +} + + +void BBLogNormDlg::UpdateDoseROI(){ + QRect rect; + + rect.setCoords(ui->spinx0BBdose->value(), + ui->spiny0BBdose->value(), + ui->spinx1BBdose->value(), + ui->spiny1BBdose->value()); + + ui->sample_bb_Viewer->set_rectangle(rect,QColor("red"),0); + +} + +void BBLogNormDlg::on_spinx0BBdose_valueChanged(int arg1) +{ + UpdateDoseROI(); +} + +void BBLogNormDlg::on_spinx1BBdose_valueChanged(int arg1) +{ + UpdateDoseROI(); +} + +void BBLogNormDlg::on_spiny0BBdose_valueChanged(int arg1) +{ + UpdateDoseROI(); +} + +void BBLogNormDlg::on_spiny1BBdose_valueChanged(int arg1) +{ + UpdateDoseROI(); +} + + +void BBLogNormDlg::on_errorButton_clicked() +{ + + // has to run only if bb ob image and bb roi are loaded + + QRect rect=ui->ob_bb_Viewer->get_marked_roi(); + + + if (rect.width()*rect.height()!=0) { + +// ReconConfig *rc=dynamic_cast(m_Config); + + std::map parameters; + UpdateParameters(); + UpdateParameterList(parameters); +// std::cout << "trying to compute error" << std::endl; +// std::cout << "tau: " << GetFloatParameter(parameters, "tau") << std::endl; + + kipl::base::TImage mymask; + float error; + + try { + module.ConfigureDLG(*(dynamic_cast(m_Config)),parameters); + error = module.GetInterpolationError(mymask); + } + catch(kipl::base::KiplException &e) { + QMessageBox errdlg(this); + errdlg.setText("Failed to compute interpolation error. Hint: try to change the threshold by using the manual threshold option"); + errdlg.setDetailedText(QString::fromStdString(e.what())); + logger(kipl::logging::Logger::LogWarning,e.what()); + errdlg.exec(); + return ; + } + catch(...){ + QMessageBox errdlg(this); + errdlg.setText("Failed to compute interpolation error.. generic exception."); + return ; + } + + +// std::cout << error << std::endl; + + // display interpolation error +// ui->errorBrowser->setText(QString::number(error)); + ui->label_error->setText(QString::number(error)); + + // display computed mask + // kipl::base::TImage mymask = module.GetMaskImage(); + float lo,hi; + const size_t NHist=512; + size_t hist[NHist]; + float axis[NHist]; + size_t nLo=0; + size_t nHi=0; + kipl::base::Histogram(mymask.GetDataPtr(),mymask.Size(),hist,NHist,0.0f,0.0f,axis); + kipl::base::FindLimits(hist, NHist, 99.0f, &nLo, &nHi); + lo=axis[nLo]; + hi=axis[nHi]; + ui->mask_Viewer->set_image(mymask.GetDataPtr(), mymask.Dims(), lo,hi); + } + +} + +void BBLogNormDlg::on_combo_BBoptions_activated(const QString &arg1) +{ + +// std::cout << "arg1: " << arg1.toStdString() << std::endl; + if (arg1.toStdString()=="noBB" || arg1.toStdString()=="ExternalBB"){ + ui->tabWidget->setTabEnabled(1,false); + } + else { + ui->tabWidget->setTabEnabled(1,true); + } + + if(arg1.toStdString()!="ExternalBB"){ + ui->group_externalBB->setEnabled(false); + } + else { + ui->group_externalBB->setEnabled(true); + } +} + +void BBLogNormDlg::on_button_OB_BB_ext_clicked() +{ + QString ob_bb_ext_dir=QFileDialog::getOpenFileName(this, + "Select location of the open beam images with BB", + ui->edit_OBBB_ext->text()); + + if (!ob_bb_ext_dir.isEmpty()) { + std::string pdir=ob_bb_ext_dir.toStdString(); + +// #ifdef _MSC_VER +// const char slash='\\'; +// #else +// const char slash='/'; +// #endif +// ptrdiff_t pos=pdir.find_last_of(slash); + +// QString path(QString::fromStdString(pdir.substr(0,pos+1))); +// std::string fname=pdir.substr(pos+1); +// kipl::io::DirAnalyzer da; +// kipl::io::FileItem fi=da.GetFileMask(pdir); + + ui->edit_OBBB_ext->setText(QString::fromStdString(pdir)); // I want the entire filename + } + +} + +void BBLogNormDlg::on_button_BBexternal_path_clicked() +{ + QString sample_bb_ext_dir=QFileDialog::getOpenFileName(this, + "Select location of the open beam images with BB", + ui->edit_BB_external->text()); + + if (!sample_bb_ext_dir.isEmpty()) { + std::string pdir=sample_bb_ext_dir.toStdString(); + + #ifdef _MSC_VER + const char slash='\\'; + #else + const char slash='/'; + #endif + ptrdiff_t pos=pdir.find_last_of(slash); + + QString path(QString::fromStdString(pdir.substr(0,pos+1))); + std::string fname=pdir.substr(pos+1); + kipl::io::DirAnalyzer da; + kipl::io::FileItem fi=da.GetFileMask(pdir); + + ui->edit_BB_external->setText(QString::fromStdString(fi.m_sMask)); + } + + +} + + +void BBLogNormDlg::on_combo_InterpolationMethod_activated(const QString &arg1) +{ + if (arg1.toStdString()=="Polynomial") { + ui->combo_IntMeth_X->setEnabled(true); + ui->combo_IntMeth_Y->setEnabled(true); + ui->label_23->setEnabled(true); + ui->label_24->setEnabled(true); +// ui->errorBrowser->setEnabled(true); + } + + if (arg1.toStdString()=="ThinPlateSplines"){ + ui->combo_IntMeth_X->setEnabled(false); + ui->combo_IntMeth_Y->setEnabled(false); + ui->label_23->setEnabled(false); + ui->label_24->setEnabled(false); +// ui->errorBrowser->setEnabled(false); + } + +} + +void BBLogNormDlg::on_checkBox_thresh_clicked(bool checked) +{ + bUseManualThresh = checked; + +} + + +void BBLogNormDlg::on_spinThresh_valueChanged(double arg1) +{ + thresh = arg1; +} + +void BBLogNormDlg::on_checkBox_thresh_stateChanged(int arg1) +{ + +} + +void BBLogNormDlg::on_pushButton_filenameOBBB_clicked() +{ + ui->edit_OB_BB_mask->setText(QString::fromStdString(m_Config->ProjectionInfo.sFileMask)); +} + +void BBLogNormDlg::on_pushButton_filenameBB_clicked() +{ + ui->edit_sample_BB_mask->setText(ui->edit_OB_BB_mask->text()); +} diff --git a/frameworks/tomography/Preprocessing/StdPreprocModulesGUI/src/bblognormdlg.h b/frameworks/tomography/Preprocessing/StdPreprocModulesGUI/src/bblognormdlg.h new file mode 100644 index 000000000..2a6e82cba --- /dev/null +++ b/frameworks/tomography/Preprocessing/StdPreprocModulesGUI/src/bblognormdlg.h @@ -0,0 +1,122 @@ +// + +#ifndef BBLOGNORMDLG_H +#define BBLOGNORMDLG_H +#include "StdPreprocModulesGUI_global.h" + +#include + +#include +#include +#include +#include +#include + +#include + + +namespace Ui { +class BBLogNormDlg; +} + +class BBLogNormDlg : public ConfiguratorDialogBase +{ + Q_OBJECT + +public: + explicit BBLogNormDlg(QWidget *parent = 0); + ~BBLogNormDlg(); + virtual int exec(ConfigBase * config, std::map ¶meters, kipl::base::TImage & img); + +private slots: + void on_button_OBBBpath_clicked(); + void on_buttonPreviewOBBB_clicked(); + void on_button_BBroi_clicked(); + void on_spinx0BBroi_valueChanged(int arg1); + void on_spiny0BBroi_valueChanged(int arg1); + void on_spinx1BBroi_valueChanged(int arg1); + void on_spiny1BBroi_valueChanged(int arg1); + void on_button_sampleBBpath_clicked(); + void on_buttonPreviewsampleBB_clicked(); + void on_button_BBdose_clicked(); + void on_spinx0BBdose_valueChanged(int arg1); + void on_spinx1BBdose_valueChanged(int arg1); + void on_spiny0BBdose_valueChanged(int arg1); + void on_spiny1BBdose_valueChanged(int arg1); + void on_errorButton_clicked(); + void on_combo_BBoptions_activated(const QString &arg1); + void on_button_OB_BB_ext_clicked(); + void on_button_BBexternal_path_clicked(); + void on_combo_InterpolationMethod_activated(const QString &arg1); + void on_checkBox_thresh_clicked(bool checked); + void on_spinThresh_valueChanged(double arg1); + void on_checkBox_thresh_stateChanged(int arg1); + void on_pushButton_filenameOBBB_clicked(); + void on_pushButton_filenameBB_clicked(); + +private: + virtual void ApplyParameters(); + virtual void UpdateDialog(); + virtual void UpdateParameters(); + virtual void UpdateParameterList(std::map ¶meters); + + + void BrowseOBBBPath(); + void UpdateBBROI(); + + void BrowseSampleBBPath(); + void UpdateDoseROI(); + + Ui::BBLogNormDlg *ui; + ReconConfig *m_Config; + + size_t nBBCount; /// number of open beam images with BB + size_t nBBFirstIndex; /// first index in filename for OB images with BB + std::string blackbodyname; + + size_t nBBSampleCount; /// number of sample images with BB + size_t nBBSampleFirstIndex; /// first index in filename for sample images with BB + std::string blackbodysamplename; + size_t BBroi[4]; + size_t doseBBroi[4]; + size_t radius; + size_t min_area; + + float ffirstAngle; + float flastAngle; + + std::string blackbodyexternalname; + std::string blackbodysampleexternalname; + + size_t nBBextCount; /// number of preprocessed BB images; + size_t nBBextFirstIndex; /// first index in filneame for preprocessed BB images + + float tau; /// mean pattern transmission, default 0.97 + float thresh; /// manual threshold + bool bPBvariante; /// boolean value on the use of PB formula (default now) + bool bUseNormROI; /// boolean value on the use of the norm roi + bool bUseNormROIBB; /// boolean value on the use of the norm roi on BBs + bool bSameMask; /// boolean value on the use of the same mask for all images with BBs + bool bUseManualThresh; /// boolean value on the use of a manual threshold instead of Otsu +// bool bUseBB; /// boolean value on the use of BBs, to be set when calling PrepareBBData +// bool bUseExternalBB; /// boolean value on the use of externally produced BBs + ImagingAlgorithms::AverageImage::eAverageMethod m_ReferenceAverageMethod; + ImagingAlgorithms::ReferenceImageCorrection::eReferenceMethod m_ReferenceMethod; + ImagingAlgorithms::ReferenceImageCorrection::eBBOptions m_BBOptions; + ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderX m_xInterpOrder; + ImagingAlgorithms::ReferenceImageCorrection::eInterpOrderY m_yInterpOrder; + ImagingAlgorithms::ReferenceImageCorrection::eInterpMethod m_InterpMethod; + int m_nWindow; + + BBLogNorm module; + + + + kipl::base::TImage m_Preview_OBBB; + kipl::base::TImage m_Preview_sampleBB; + + + +}; + +#endif // BBLOGNORMDLG_H diff --git a/frameworks/tomography/Preprocessing/StdPreprocModulesGUI/src/bblognormdlg.ui b/frameworks/tomography/Preprocessing/StdPreprocModulesGUI/src/bblognormdlg.ui new file mode 100644 index 000000000..33df198fb --- /dev/null +++ b/frameworks/tomography/Preprocessing/StdPreprocModulesGUI/src/bblognormdlg.ui @@ -0,0 +1,1221 @@ + + + BBLogNormDlg + + + + 0 + 0 + 1048 + 924 + + + + + 0 + 0 + + + + Configure BB log norm + + + + + + 0 + + + + Module Settings + + + + + 20 + 40 + 971 + 41 + + + + + + + Averaging method + + + + + + + Selects image combination method + + + ImageWeightedAverage + + + 0 + + + + ImageWeightedAverage + + + + + ImageAverage + + + + + ImageMedian + + + + + ImageMax + + + + + ImageMin + + + + + ImageSum + + + + + + + + + + 20 + 90 + 971 + 41 + + + + + + + Referencing method + + + + + + + Selects whether the referencing is computed including the -log operation or not + + + false + + + LogNorm + + + + LogNorm + + + + + Norm + + + + + + + + + + 20 + 140 + 971 + 51 + + + + + + + BB options + + + + + + + Selects the BB options, to be chosen according to the acquired BB images + + + false + + + noBB + + + + noBB + + + + + Interpolate + + + + + Average + + + + + OneToOne + + + + + ExternalBB + + + + + + + + + + 20 + 290 + 991 + 191 + + + + Pre-processed BB images + + + + + 0 + 80 + 971 + 41 + + + + + + + Sample scattering + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 38 + 20 + + + + + + + + + + + <html><head/><body><p>Browse to select the externally computed sample scattering images. They should be as many as the projection images. </p></body></html> + + + Browse + + + + + + + + + 0 + 120 + 971 + 41 + + + + + + + First + + + + + + + <html><head/><body><p>First index of the sample scattering image files. </p></body></html> + + + + + + + Count + + + + + + + <html><head/><body><p>Number of images</p></body></html> + + + 9999 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + 40 + 971 + 41 + + + + + + + Background scattering + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + + <html><head/><body><p>Browse to select the externally computed background scattering image. A single file is expected. </p></body></html> + + + Browse + + + + + + + + + + BB images + + + + + + Open beam images with BB + + + + + + + + <html><head/><body><p>click to copy the filename</p></body></html> + + + filename + + + + + + + + + + false + + + Browse to select the open beam with black body images + + + Browse + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + 0 + + + + + 50 + 100 + + + + First + + + + + + + + 0 + 0 + + + + <html><head/><body><p>First index of the open beam images with BB</p></body></html> + + + 9999 + + + + + + + Count + + + + + + + <html><head/><body><p>Number of open beam images with BB</p></body></html> + + + 9999 + + + + + + + <html><head/><body><p>click to Preview</p></body></html> + + + Preview + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + BB roi + + + + + + + x0 + + + + + + + 99999 + + + + + + + y0 + + + + + + + 9999 + + + + + + + x1 + + + + + + + 9999 + + + + + + + y1 + + + + + + + 9999 + + + + + + + <html><head/><body><p>Select a ROI in the open beam image with BB including all BBs. </p></body></html> + + + GetBBroi + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + Sample images with BB + + + + + + + + <html><head/><body><p>click to copy the filename</p></body></html> + + + filename + + + + + + + + + + false + + + <html><head/><body><p>Browse to select the sample images with BB</p></body></html> + + + Browse + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + 0 + + + + + 50 + 100 + + + + First + + + + + + + + 0 + 0 + + + + false + + + <html><head/><body><p>first index of the sample images with BB</p><p><br/></p></body></html> + + + 9999 + + + + + + + Count + + + + + + + <html><head/><body><p>Number of sample images with BB</p></body></html> + + + 9999 + + + + + + + <html><head/><body><p>Click to Preview</p></body></html> + + + Preview + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + first Scan Angle + + + + + + + <html><head/><body><p>projection angle corresponding to the first sample image with BB</p></body></html> + + + 9999.989999999999782 + + + + + + + last Scan Angle + + + + + + + CrossCursor + + + <html><head/><body><p>projection angle corresponding to the last sample image with BB</p></body></html> + + + 9999.989999999999782 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + dose BB roi + + + + + + + x0 + + + + + + + 99999 + + + + + + + y0 + + + + + + + 9999 + + + + + + + x1 + + + + + + + 9999 + + + + + + + y1 + + + + + + + 9999 + + + + + + + + + <html><head/><body><p>Click to select an open beam area in the sample images with BB</p></body></html> + + + GetBBdose + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + 0 + 0 + + + + Open beam with BBs + + + + + + + 256 + 256 + + + + + + + + + + + + 0 + 0 + + + + Sample image with BBs + + + + + + + 256 + 256 + + + + + + + + + + + BB mask + + + + + + + 0 + 0 + + + + + 256 + 256 + + + + + + + + + + + + + + 0 + 0 + + + + Parameters + + + + + + + + radius + + + + + + + <html><head/><body><p>select the dimensions of the BBs in the mask</p></body></html> + + + + + + + min area + + + + + + + <html><head/><body><p>Min area for a segmented object to be considered a BB. Objects with smaller areas are considered noise and removed from segmentation.</p></body></html> + + + 999 + + + + + + + + + + + + + + <html><head/><body><p>Select manual threshold for BB segmentation. Threshold should be a normalized values between 0.0 and 1.0. Values below the theshold are considerd as BB. If unchecked, Otsu thresholding is applied</p></body></html> + + + Manual Threshold + + + + + + + <html><head/><body><p>Manual thresholding, normalized value between 0 and 1</p></body></html> + + + 1.000000000000000 + + + 0.010000000000000 + + + + + + + <html><head/><body><p>Compute the interpolation error in the case of the polynomial interpolation</p></body></html> + + + Compute error + + + + + + + Error + + + + + + + not available + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Interpolation method: + + + + + + + <html><head/><body><p>Selects the interpolation method. </p></body></html> + + + + Polynomial + + + + + ThinPlateSplines + + + + + + + + Interpolation X: + + + + + + + <html><head/><body><p>Selects the order of the polynomial interpolation along X</p></body></html> + + + + SecondOrder + + + + + FirstOrder + + + + + ZeroOrder + + + + + + + + Interpolation Y: + + + + + + + <html><head/><body><p>Select the order of the polynomial interpolation along Y</p></body></html> + + + + SecondOrder + + + + + FirstOrder + + + + + ZeroOrder + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + QtAddons::ImageViewerWidget + QWidget +
imageviewerwidget.h
+ 1 +
+
+ + + + buttonBox + accepted() + BBLogNormDlg + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + BBLogNormDlg + reject() + + + 316 + 260 + + + 286 + 274 + + + + +
diff --git a/frameworks/tomography/Preprocessing/StdPreprocModulesGUI/src/stdpreprocmodulesgui.cpp b/frameworks/tomography/Preprocessing/StdPreprocModulesGUI/src/stdpreprocmodulesgui.cpp index 32da42f09..b49b19942 100644 --- a/frameworks/tomography/Preprocessing/StdPreprocModulesGUI/src/stdpreprocmodulesgui.cpp +++ b/frameworks/tomography/Preprocessing/StdPreprocModulesGUI/src/stdpreprocmodulesgui.cpp @@ -15,6 +15,7 @@ #include "datascalerdlg.h" #include "adaptivefilterdlg.h" #include "generalfilterdlg.h" +#include "bblognormdlg.h" class ConfiguratorDialogBase; @@ -29,6 +30,10 @@ STDPREPROCMODULESGUISHARED_EXPORT void *GetGUIModule(const char *application, co if (sName=="FullLogNorm") return new FullLogNormDlg; + + if (sName=="BBLogNorm") + return new BBLogNormDlg; + // if (sName=="LogProjection") // return new LogProjection;