From 11f0ba44e7cc6df01882a3ac12d5cd4e429616b7 Mon Sep 17 00:00:00 2001 From: dsarrut Date: Fri, 18 Mar 2011 12:49:25 +0000 Subject: [PATCH] Resample tool now use new resampleImage class (use the right number of thread) --- vv/vvToolResample.cxx | 94 ++++++++++++++++++++++++++++++++----------- vv/vvToolResample.h | 8 ++-- 2 files changed, 75 insertions(+), 27 deletions(-) diff --git a/vv/vvToolResample.cxx b/vv/vvToolResample.cxx index 03ed9cb..54f407b 100644 --- a/vv/vvToolResample.cxx +++ b/vv/vvToolResample.cxx @@ -24,11 +24,20 @@ // qt #include #include +#include #define COLUMN_IMAGE_NAME 7 ADD_TOOL(vvToolResample); + +#define SetArgOptionString(OPTION, VALUE) \ + { \ + OPTION##_given = VALUE.size(); \ + OPTION##_arg = new char[VALUE.size()]; \ + strcpy(OPTION##_arg, VALUE.c_str()); \ + } + //------------------------------------------------------------------------------ vvToolResample::vvToolResample(vvMainWindowBase * parent, Qt::WindowFlags f): vvToolWidgetBase(parent,f), @@ -37,8 +46,8 @@ vvToolResample::vvToolResample(vvMainWindowBase * parent, Qt::WindowFlags f): { Ui_vvToolResample::setupUi(mToolWidget); - // mFilter = clitk::ResampleImageGenericFilter::New(); - mFilter = clitk::ImageResampleGenericFilter::New(); + mFilter = clitk::ResampleImageGenericFilter::New(); + //mFilter = clitk::ImageResampleGenericFilter::New(); mLastError =""; mInputFileFormat = ""; @@ -461,30 +470,69 @@ void vvToolResample::apply() if (mDimension > 2) sigma.push_back(zGaussianLineEdit->text().toDouble()); if (mDimension == 4) sigma.push_back(0.01); //FIXME Don't filter along the temporal direction - /* - // Build ArgsInfo - typename clitk::ResampleImageGenericFilter::ArgsInfoType mArgsInfo; + // Build ArgsInfo + clitk::ResampleImageGenericFilter::ArgsInfoType mArgsInfo; + + // Initialisation to default + cmdline_parser_clitkResampleImage_init(&mArgsInfo); + mArgsInfo.input_given = 0; + mArgsInfo.output_given = 0; + + // Size and spacing options mArgsInfo.size_given = mDimension; - mArgsInfo.size_arg = mDimension; + mArgsInfo.spacing_given = mDimension; + mArgsInfo.size_arg = new int[mDimension]; + mArgsInfo.spacing_arg = new float[mDimension]; for(int i=0; iSetOutputSize(mOutputSize); - mFilter->SetOutputSpacing(mOutputSpacing); - mFilter->SetInterpolationName(interpolationComboBox->currentText().toLower().toStdString()); - - if (interpolationComboBox->currentText() == "BSpline") - mFilter->SetBSplineOrder(bSplineOrderSpinBox->value()); - else if (interpolationComboBox->currentText() == "Blut (faster BSpline)") { - mFilter->SetInterpolationName("blut"); - mFilter->SetBSplineOrder(bSplineOrderSpinBox->value()); - mFilter->SetBLUTSampling(bLUTSpinBox->value()); + mArgsInfo.size_arg[i] = mOutputSize[i]; + mArgsInfo.spacing_arg[i] = mOutputSpacing[i]; + } + + if (sizeRadioButton->isChecked() || + scaleSizeRadioButton->isChecked() || + isoSizeRadioButton->isChecked()) { + mArgsInfo.spacing_given=0; + } + if (spacingRadioButton->isChecked() || + scaleSpacingRadioButton->isChecked() || + isoSpacingRadioButton->isChecked()) { + mArgsInfo.size_given=0; } - if (gaussianFilterCheckBox->isChecked()) - mFilter->SetGaussianSigma(sigma); - // mFilter->SetOutputFileName(OutputFileName.toStdString()); - mFilter->SetDefaultPixelValue(defaultPixelValueLineEdit->text().toDouble()); + + // Interpolation options + std::string interp = interpolationComboBox->currentText().toLower().toStdString(); + if (interp == "nn") SetArgOptionString(mArgsInfo.interp, std::string("nn")); + if (interp == "linear") SetArgOptionString(mArgsInfo.interp, std::string("linear")); + if (interp == "bspline") SetArgOptionString(mArgsInfo.interp, std::string("bspline")); + if (interp == "blut (faster bspline)") SetArgOptionString(mArgsInfo.interp, std::string("blut")); + if (interp == "windowed sinc") SetArgOptionString(mArgsInfo.interp, std::string("windowed sinc")); + + if (interp == "bspline") { + mArgsInfo.order_arg = bSplineOrderSpinBox->value(); + } + else { + if (interp == "blut (faster bspline)") { + mArgsInfo.order_arg = bSplineOrderSpinBox->value(); + mArgsInfo.sampling_arg = bLUTSpinBox->value(); + } + } + + // Gauss + if (gaussianFilterCheckBox->isChecked()) { + mArgsInfo.gauss_given = mDimension; + mArgsInfo.gauss_arg = new float[mDimension]; + for(int i=0; itext().toDouble(); + + // Thread + mArgsInfo.thread_arg = QThread::idealThreadCount(); + mArgsInfo.thread_given = 1; + + // Set options to filter + mFilter->SetArgsInfo(mArgsInfo); mFilter->SetInputVVImage(mCurrentImage); // Go ! diff --git a/vv/vvToolResample.h b/vv/vvToolResample.h index c93f0cc..c13e5eb 100644 --- a/vv/vvToolResample.h +++ b/vv/vvToolResample.h @@ -20,8 +20,8 @@ #define _VVTOOLRESAMPLE_H // clitk -#include "clitkImageResampleGenericFilter.h" -//#include "clitkResampleImageGenericFilter.h" +//#include "clitkImageResampleGenericFilter.h" +#include "clitkResampleImageGenericFilter.h" // vv #include "ui_vvToolResample.h" @@ -70,8 +70,8 @@ public slots: protected: Ui::vvToolResample ui; vvImage::Pointer mOutput; - clitk::ImageResampleGenericFilter::Pointer mFilter; - //clitk::ResampleImageGenericFilter::Pointer mFilter; + //clitk::ImageResampleGenericFilter::Pointer mFilter; + clitk::ResampleImageGenericFilter::Pointer mFilter; vvSlicerManager* mCurrentSlicerManager; vvImage::Pointer mCurrentImage; -- 2.47.1