From ebc1acee802a4dd54c3ff05662d3c7087c7aa882 Mon Sep 17 00:00:00 2001 From: tbaudier Date: Tue, 22 Dec 2015 15:07:01 +0100 Subject: [PATCH] Creation of the Profile Tool --- tools/CMakeLists.txt | 7 + tools/clitkProfileImage.cxx | 41 +++ tools/clitkProfileImage.ggo | 19 ++ tools/clitkProfileImageGenericFilter.cxx | 144 +++++++++ tools/clitkProfileImageGenericFilter.h | 66 ++++ vv/CMakeLists.txt | 2 + vv/icons/profile.png | Bin 0 -> 1054 bytes vv/qt_ui/vvToolProfile.ui | 189 +++++++++++ vv/vvIcons.qrc | 1 + vv/vvToolProfile.cxx | 388 +++++++++++++++++++++++ vv/vvToolProfile.h | 75 +++++ 11 files changed, 932 insertions(+) create mode 100644 tools/clitkProfileImage.cxx create mode 100644 tools/clitkProfileImage.ggo create mode 100644 tools/clitkProfileImageGenericFilter.cxx create mode 100644 tools/clitkProfileImageGenericFilter.h create mode 100644 vv/icons/profile.png create mode 100644 vv/qt_ui/vvToolProfile.ui create mode 100644 vv/vvToolProfile.cxx create mode 100644 vv/vvToolProfile.h diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 3bf8948..fbab5f5 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -9,6 +9,9 @@ add_library(clitkImageConvertLib clitkImageConvertGenericFilter.cxx ${clitkImage WRAP_GGO(clitkBinarizeImage_GGO_C clitkBinarizeImage.ggo) add_library(clitkBinarizeImageLib clitkBinarizeImageGenericFilter.cxx ${clitkBinarizeImage_GGO_C}) +WRAP_GGO(clitkProfileImage_GGO_C clitkProfileImage.ggo) +add_library(clitkProfileImageLib clitkProfileImageGenericFilter.cxx ${clitkProfileImage_GGO_C}) + WRAP_GGO(clitkImageArithm_GGO_C clitkImageArithm.ggo) add_library(clitkImageArithmImageLib clitkImageArithmGenericFilter.cxx ${clitkImageArithm_GGO_C}) @@ -58,6 +61,10 @@ if(CLITK_BUILD_TOOLS) add_executable(clitkBinarizeImage clitkBinarizeImage.cxx) target_link_libraries(clitkBinarizeImage clitkBinarizeImageLib clitkCommon) set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkBinarizeImage) + + add_executable(clitkProfileImage clitkProfileImage.cxx) + target_link_libraries(clitkProfileImage clitkProfileImageLib clitkCommon) + set(TOOLS_INSTALL ${TOOLS_INSTALL} clitkProfileImage) WRAP_GGO(clitkVFResample_GGO_C clitkVFResample.ggo) add_executable(clitkVFResample clitkVFResample.cxx clitkVFResampleGenericFilter.cxx ${clitkVFResample_GGO_C}) diff --git a/tools/clitkProfileImage.cxx b/tools/clitkProfileImage.cxx new file mode 100644 index 0000000..c8332c9 --- /dev/null +++ b/tools/clitkProfileImage.cxx @@ -0,0 +1,41 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================**/ + +// clitk +#include "clitkProfileImage_ggo.h" +#include "clitkProfileImageGenericFilter.h" + +//-------------------------------------------------------------------- +int main(int argc, char * argv[]) +{ + + // Init command line + GGO(clitkProfileImage, args_info); + CLITK_INIT; + + // Filter + typedef clitk::ProfileImageGenericFilter FilterType; + FilterType::Pointer filter = FilterType::New(); + + filter->SetArgsInfo(args_info); + + CLITK_TRY_CATCH_EXIT(filter->Update()); + + return EXIT_SUCCESS; +} // This is the end, my friend +//-------------------------------------------------------------------- diff --git a/tools/clitkProfileImage.ggo b/tools/clitkProfileImage.ggo new file mode 100644 index 0000000..1894af6 --- /dev/null +++ b/tools/clitkProfileImage.ggo @@ -0,0 +1,19 @@ +#File clitkProfileImage.ggo +package "clitkProfileImage" +version "1.0" +purpose "" + +option "config" - "Config file" string no +option "verbose" v "Verbose" flag off +option "imagetypes" - "Display allowed image types" flag off + +option "input" i "Input image filename" string yes +option "output" o "Output image filename" string yes +option "lower" l "Lower intensity (default=min), fg is greater than this value" double no +option "upper" u "Upper intensity (default=max), fg is lower than this value" double no + +option "fg" - "Foreground (FG) or 'inside' value" double no default="1" +option "bg" - "Background (BG) or 'ouside' value" double no default="0" +option "mode" - "Use FG and/or BG values (if FG, the BG is replaced by the input image values)" values="FG","BG","both" no default="both" + + diff --git a/tools/clitkProfileImageGenericFilter.cxx b/tools/clitkProfileImageGenericFilter.cxx new file mode 100644 index 0000000..8229815 --- /dev/null +++ b/tools/clitkProfileImageGenericFilter.cxx @@ -0,0 +1,144 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================**/ +#ifndef clitkProfileImageGenericFilter_cxx +#define clitkProfileImageGenericFilter_cxx + +/* ================================================= + * @file clitkProfileImageGenericFilter.cxx + * @author Thomas Baudier + * @date 22 dec 2015 + * + * @brief + * + ===================================================*/ + +#include "clitkProfileImageGenericFilter.h" + +// itk include +#include "itkBinaryThresholdImageFilter.h" +#include "itkMaskImageFilter.h" +#include "itkMaskNegatedImageFilter.h" + +#include + +namespace clitk +{ + +//-------------------------------------------------------------------- +ProfileImageGenericFilter::ProfileImageGenericFilter(): + ImageToImageGenericFilter("ProfileImage") +{ + InitializeImageType<2>(); + InitializeImageType<3>(); + InitializeImageType<4>(); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +template +void ProfileImageGenericFilter::InitializeImageType() +{ + ADD_DEFAULT_IMAGE_TYPES(Dim); +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +void ProfileImageGenericFilter::SetArgsInfo(const args_info_type & a) +{ + mArgsInfo=a; + if (mArgsInfo.verbose_given) + SetIOVerbose(mArgsInfo.verbose_flag); + if (mArgsInfo.imagetypes_given && mArgsInfo.imagetypes_flag) + this->PrintAvailableImageTypes(); + + if (mArgsInfo.input_given) { + SetInputFilename(mArgsInfo.input_arg); + } + if (mArgsInfo.output_given) { + SetOutputFilename(mArgsInfo.output_arg); + } +} +//-------------------------------------------------------------------- + + +//-------------------------------------------------------------------- +// Update with the number of dimensions and the pixeltype +//-------------------------------------------------------------------- +template +void +ProfileImageGenericFilter::UpdateWithInputImageType() +{ + + // Reading input + typename InputImageType::Pointer input = this->template GetInput(0); + + // Main filter + typedef typename InputImageType::PixelType PixelType; + typedef itk::Image OutputImageType; + + // Filter + typedef itk::BinaryThresholdImageFilter BinaryThresholdImageFilterType; + typename BinaryThresholdImageFilterType::Pointer thresholdFilter=BinaryThresholdImageFilterType::New(); + thresholdFilter->SetInput(input); + thresholdFilter->SetInsideValue(mArgsInfo.fg_arg); + + if (mArgsInfo.lower_given) thresholdFilter->SetLowerThreshold(static_cast(mArgsInfo.lower_arg)); + if (mArgsInfo.upper_given) thresholdFilter->SetUpperThreshold(static_cast(mArgsInfo.upper_arg)); + + /* Three modes : + - FG -> only use FG value for pixel in the Foreground (or Inside), keep input values for outside + - BG -> only use BG value for pixel in the Background (or Outside), keep input values for inside + - both -> use FG and BG (real binary image) + */ + if (mArgsInfo.mode_arg == std::string("both")) { + thresholdFilter->SetOutsideValue(mArgsInfo.bg_arg); + thresholdFilter->Update(); + typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput(); + this->template SetNextOutput(outputImage); + } else { + typename InputImageType::Pointer outputImage; + thresholdFilter->SetOutsideValue(0); + if (mArgsInfo.mode_arg == std::string("BG")) { + typedef itk::MaskImageFilter maskFilterType; + typename maskFilterType::Pointer maskFilter = maskFilterType::New(); + maskFilter->SetInput1(input); + maskFilter->SetInput2(thresholdFilter->GetOutput()); + maskFilter->SetOutsideValue(mArgsInfo.bg_arg); + maskFilter->Update(); + outputImage = maskFilter->GetOutput(); + } else { + typedef itk::MaskNegatedImageFilter maskFilterType; + typename maskFilterType::Pointer maskFilter = maskFilterType::New(); + maskFilter->SetInput1(input); + maskFilter->SetInput2(thresholdFilter->GetOutput()); + maskFilter->SetOutsideValue(mArgsInfo.fg_arg); + maskFilter->Update(); + outputImage = maskFilter->GetOutput(); + } + // Write/Save results + this->template SetNextOutput(outputImage); + } +} +//-------------------------------------------------------------------- + + +}//end clitk + +#endif //#define clitkProfileImageGenericFilter_cxx diff --git a/tools/clitkProfileImageGenericFilter.h b/tools/clitkProfileImageGenericFilter.h new file mode 100644 index 0000000..e251ff5 --- /dev/null +++ b/tools/clitkProfileImageGenericFilter.h @@ -0,0 +1,66 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================**/ + +#ifndef clitkProfileImageGenericFilter_h +#define clitkProfileImageGenericFilter_h + +#include "clitkIO.h" +#include "clitkImageToImageGenericFilter.h" +#include "clitkProfileImage_ggo.h" + +//-------------------------------------------------------------------- +namespace clitk +{ + + class ITK_EXPORT ProfileImageGenericFilter: + public ImageToImageGenericFilter + { + + public: + //-------------------------------------------------------------------- + typedef ProfileImageGenericFilter Self; + typedef itk::SmartPointer Pointer; + typedef itk::SmartPointer ConstPointer; + typedef args_info_clitkProfileImage args_info_type; + + //-------------------------------------------------------------------- + // Method for creation through the object factory + // and Run-time type information (and related methods) + itkNewMacro(Self); + itkTypeMacro(ProfileImageGenericFilter, LightObject); + + //-------------------------------------------------------------------- + void SetArgsInfo(const args_info_type & a); + + //-------------------------------------------------------------------- + // Main function called each time the filter is updated + template + void UpdateWithInputImageType(); + + protected: + ProfileImageGenericFilter(); + template void InitializeImageType(); + args_info_type mArgsInfo; + + }; // end class + //-------------------------------------------------------------------- + +} // end namespace clitk +//-------------------------------------------------------------------- + +#endif // #define clitkProfileImageGenericFilter_h diff --git a/vv/CMakeLists.txt b/vv/CMakeLists.txt index 5b84991..4b0932d 100644 --- a/vv/CMakeLists.txt +++ b/vv/CMakeLists.txt @@ -21,6 +21,7 @@ set(vv_TOOLS vvToolConvert ## with dummy vvToolConvert.ui vvToolROIManager vvToolSegmentation + vvToolProfile ## these ones are for tests (not working) # vvToolTest # vvToolFoo @@ -36,6 +37,7 @@ set(vv_TOOLS # Future issues : when tool depend on other tools ... how to manage that ? # >> add the relevant $_LIBS variable to the tool that has dependencies? set(vvToolBinarize_LIBS clitkBinarizeImageLib) +set(vvToolProfile_LIBS clitkProfileImageLib) set(vvToolResample_LIBS clitkResampleImageLib) set(vvToolConvert_LIBS clitkImageConvertLib) set(vvToolExtractPatient_LIBS clitkSegmentationGgoLib) diff --git a/vv/icons/profile.png b/vv/icons/profile.png new file mode 100644 index 0000000000000000000000000000000000000000..656113acf547736db10de305296dd5659fe714cb GIT binary patch literal 1054 zcmV+(1mXLMP)DJ|RP~`vWAWqv1SDFJS{llU;zUAy ziONeN0fGcnHN*;3q(1M?@Zh_%?{fC-8C6Y0$GTs0yR+YZGrKcB5)qsQQ8**=8tDHP zsOQ>ndwU!Ge!uix7=~C{S~?v-`~5!Jop$NF&EDp#XSB%V<;x#{h>`=?+8Tk3qNw)Z zbv)tKWl}32jW^B%PG{X#l6$a|ZhG;e7;tAXVUslMoSX^&Uy9)giGwidNwhAggRDmn~$ow^5S*8Y~C?WupM{cljg2*3b%uV#m z*;94gm)lowe?%*tD-;joGFoUBlQS61fvXdvGR>%`HPmc}RDvyGaIVE9(_-!Vjho~J z0kl`SX;9IvGh96XsxJe1snsT}H3H9v*42>{MG?irn3mpOrmNR((A8_#X?eLt@i3+& zw*ONKE%jGCj7gO&1gGjr1dJrLD8YK@z1ZE3>$BY8#c0U0C+`02vZP(9Y zGE*u=P)dQck9XdE4+Mhmds#DMO;T+!L;z-s!C-(te&5f^E)l_-3m5R$(cye$-jqy{ zQ>HQ6KRhTbJe9i^3z}lk+hjs@fr@KtWD)G||5lg@mEMobI(tI5_vu<-!if`uVG&N@Vdy}dmc zWAOO#583ny1Zyphj*if5HsSj|c6N5qY&K`6IB{`#QFeECaeRCXYi*ViGgd_~7z{u} zIQa7b&;Nc7t#!t*Rtj2cEG#TwadB}bz!O00fP7`&o=!VR08nQEWV)D6HNe;3M_-ow Y3wzx8{;h9VivR!s07*qoM6N<$f;mXxSO5S3 literal 0 HcmV?d00001 diff --git a/vv/qt_ui/vvToolProfile.ui b/vv/qt_ui/vvToolProfile.ui new file mode 100644 index 0000000..b4cdb44 --- /dev/null +++ b/vv/qt_ui/vvToolProfile.ui @@ -0,0 +1,189 @@ + + + vvToolProfile + + + + 0 + 0 + 433 + 222 + + + + Profile image + + + + + + + + + + false + + + + + + + Foreground (FG) is greater than : + + + + + + + + + + and lower than + + + false + + + + + + + + + + + + + Qt::Horizontal + + + + + + + Resulting binary image: + + + + + + + + + Use FG + + + false + + + + + + + false + + + + + + + + + + + Use BG + + + true + + + + + + + + + + + + + + Qt::Horizontal + + + + + + + true + + + Interactive (unchek to disable on the fly contours drawing) + + + true + + + + + + + + vvIntensityValueSlider + QWidget +
vvIntensityValueSlider.h
+ 1 +
+
+ + + + mRadioButtonLowerThan + toggled(bool) + mThresholdSlider2 + setEnabled(bool) + + + 85 + 129 + + + 305 + 129 + + + + + mCheckBoxUseBG + toggled(bool) + mBGSlider + setEnabled(bool) + + + 79 + 203 + + + 395 + 225 + + + + + mCheckBoxUseFG + toggled(bool) + mFGSlider + setEnabled(bool) + + + 63 + 177 + + + 242 + 177 + + + + +
diff --git a/vv/vvIcons.qrc b/vv/vvIcons.qrc index 15a8648..e160460 100644 --- a/vv/vvIcons.qrc +++ b/vv/vvIcons.qrc @@ -12,6 +12,7 @@ icons/8b.png icons/1b.png icons/binarize.png + icons/profile.png icons/resample.png icons/crop.png icons/splashscreen2.png diff --git a/vv/vvToolProfile.cxx b/vv/vvToolProfile.cxx new file mode 100644 index 0000000..164b992 --- /dev/null +++ b/vv/vvToolProfile.cxx @@ -0,0 +1,388 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + ===========================================================================**/ + +// vv +#include "vvToolProfile.h" +#include "vvSlicerManager.h" +#include "vvSlicer.h" +#include "vvToolInputSelectorWidget.h" + +// clitk +#include "clitkProfileImageGenericFilter.h" + +// vtk +#include +#include +#include +#include + + +//------------------------------------------------------------------------------ +// Create the tool and automagically (I like this word) insert it in +// the main window menu. +ADD_TOOL(vvToolProfile); +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolProfile::Initialize() +{ + SetToolName("Profile"); + SetToolMenuName("Intensity Profile"); + SetToolIconFilename(":/common/icons/profile.png"); + SetToolTip("Display the intensity profile between 2 points of the image."); + SetToolExperimental(false); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +vvToolProfile::vvToolProfile(vvMainWindowBase * parent, Qt::WindowFlags f) + :vvToolWidgetBase(parent,f), + vvToolBase(parent), + Ui::vvToolProfile() +{ + // GUI Initialization + Ui_vvToolProfile::setupUi(mToolWidget); + mInteractiveDisplayIsEnabled = mCheckBoxInteractiveDisplay->isChecked(); + + // Connect signals & slots + connect(mRadioButtonLowerThan, SIGNAL(toggled(bool)), this, SLOT(enableLowerThan(bool))); + connect(mCheckBoxUseFG, SIGNAL(toggled(bool)), this, SLOT(useFGBGtoggled(bool))); + connect(mCheckBoxUseBG, SIGNAL(toggled(bool)), this, SLOT(useFGBGtoggled(bool))); + connect(mCheckBoxInteractiveDisplay, SIGNAL(toggled(bool)), this, SLOT(InteractiveDisplayToggled(bool))); + + // Initialize some widget + mThresholdSlider1->SetText(""); + mThresholdSlider2->SetText(""); + mFGSlider->SetText("Foreground value"); + mBGSlider->SetText("Background value"); + + // Main filter + mFilter = clitk::ProfileImageGenericFilter::New(); + + // Set how many inputs are needed for this tool + AddInputSelector("Select one image", mFilter); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +vvToolProfile::~vvToolProfile() +{ +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolProfile::InteractiveDisplayToggled(bool b) +{ + mInteractiveDisplayIsEnabled = b; + if (!mInteractiveDisplayIsEnabled) { + RemoveVTKObjects(); + } else { + for(unsigned int i=0; iShowActors(); + if (mRadioButtonLowerThan->isChecked()) + mImageContourLower[i]->ShowActors(); + } + if (mCurrentSlicerManager) + mCurrentSlicerManager->Render(); + } +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolProfile::RemoveVTKObjects() +{ + for(unsigned int i=0; iHideActors(); + mImageContourLower[i]->HideActors(); + } + if (mCurrentSlicerManager) + mCurrentSlicerManager->Render(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +bool vvToolProfile::close() +{ + // RemoveVTKObjects(); + return vvToolWidgetBase::close(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolProfile::closeEvent(QCloseEvent *event) +{ + RemoveVTKObjects(); + event->accept(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolProfile::reject() +{ + // DD("vvToolProfile::reject"); + RemoveVTKObjects(); + return vvToolWidgetBase::reject(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolProfile::enableLowerThan(bool b) +{ + if (!b) { + mThresholdSlider1->resetMaximum(); + for(unsigned int i=0; iHideActors(); + } + mCurrentSlicerManager->Render(); + } else { + valueChangedT1(mThresholdSlider1->GetValue()); + valueChangedT2(mThresholdSlider2->GetValue()); + for(unsigned int i=0; iShowActors(); + } + mCurrentSlicerManager->Render(); + } +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolProfile::useFGBGtoggled(bool) +{ + if (!mCheckBoxUseBG->isChecked() && !mCheckBoxUseFG->isChecked()) + mCheckBoxUseBG->toggle(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +// void vvToolProfile::InputIsSelected(std::vector & m) { +// DD("vvToolProfile::InputIsSelected vector in Profile"); +// DD(m.size()); +// } +void vvToolProfile::InputIsSelected(vvSlicerManager * m) +{ + mCurrentSlicerManager = m; + + // Specific for this gui + mThresholdSlider1->SetValue(0); + mThresholdSlider2->SetValue(0); + mThresholdSlider1->SetImage(mCurrentImage); + mThresholdSlider2->SetImage(mCurrentImage); + mFGSlider->SetImage(mCurrentImage); + mBGSlider->SetImage(mCurrentImage); + // DD(mCurrentSlicerManager->GetFileName().c_str()); + // mFGSlider->SetMaximum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMax()); + // mFGSlider->SetMinimum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMin()); + // mBGSlider->SetMaximum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMax()); + // mBGSlider->SetMinimum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMin()); + + // Output is uchar ... + mFGSlider->SetMaximum(255); + mFGSlider->SetMinimum(0); + mBGSlider->SetMaximum(255); + mBGSlider->SetMinimum(0); + + mFGSlider->SetValue(1); + mBGSlider->SetValue(0); + mFGSlider->SetSingleStep(1); + mBGSlider->SetSingleStep(1); + + // VTK objects for interactive display + for(int i=0; iGetNumberOfSlicers(); i++) { + mImageContour.push_back(vvImageContour::New()); + mImageContour[i]->SetSlicer(mCurrentSlicerManager->GetSlicer(i)); + mImageContour[i]->SetColor(1.0, 0.0, 0.0); + mImageContour[i]->SetDepth(0); // to be in front of (whe used with ROI tool) + mImageContourLower.push_back(vvImageContour::New()); + mImageContourLower[i]->SetSlicer(mCurrentSlicerManager->GetSlicer(i)); + mImageContourLower[i]->SetColor(0.0, 0.0, 1.0); + mImageContourLower[i]->SetDepth(100); // to be in front of (whe used with ROI tool) + } + valueChangedT1(mThresholdSlider1->GetValue()); + + connect(mThresholdSlider1, SIGNAL(valueChanged(double)), this, SLOT(valueChangedT1(double))); + connect(mThresholdSlider2, SIGNAL(valueChanged(double)), this, SLOT(valueChangedT2(double))); + + connect(mCurrentSlicerManager,SIGNAL(UpdateSlice(int,int)),this,SLOT(UpdateSlice(int, int))); + connect(mCurrentSlicerManager,SIGNAL(UpdateTSlice(int,int)),this,SLOT(UpdateSlice(int, int))); + + connect(mCurrentSlicerManager,SIGNAL(UpdateOrientation(int,int)),this,SLOT(UpdateOrientation(int, int))); + + // connect(mCurrentSlicerManager, SIGNAL(LeftButtonReleaseSignal(int)), SLOT(LeftButtonReleaseEvent(int))); + InteractiveDisplayToggled(mInteractiveDisplayIsEnabled); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +// void vvToolProfile::LeftButtonReleaseEvent(int slicer) { +// DD("LeftButtonReleaseEvent"); +// for(int i=0; iGetNumberOfSlicers(); i++) { +// if (i == slicer); +// mCurrentSlicerManager->GetSlicer(i)->GetRenderWindow()->Render(); +// } +// } +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolProfile::UpdateOrientation(int slicer,int orientation) +{ + Update(slicer); +} +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +void vvToolProfile::UpdateSlice(int slicer,int slices) +{ + Update(slicer); +} +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +void vvToolProfile::Update(int slicer) +{ + if (!mInteractiveDisplayIsEnabled) return; + if (!mCurrentSlicerManager) close(); + mImageContour[slicer]->Update(mThresholdSlider1->GetValue()); + if (mRadioButtonLowerThan->isChecked()) + mImageContourLower[slicer]->Update(mThresholdSlider2->GetValue()); +} +//------------------------------------------------------------------------------ + +//------------------------------------------------------------------------------ +void vvToolProfile::GetArgsInfoFromGUI() +{ + + /* //KEEP THIS FOR READING GGO FROM FILE + int argc=1; + std::string a = "toto"; + char * const* argv = new char*; + //a.c_str(); + struct cmdline_parser_params p; + p.check_required = 0; + int good = cmdline_parser_ext(argc, argv, &args_info, &p); + DD(good); + */ + cmdline_parser_clitkProfileImage_init(&mArgsInfo); // Initialisation to default + bool inverseBGandFG = false; + + mArgsInfo.lower_given = 1; + mArgsInfo.lower_arg = mThresholdSlider1->GetValue(); + if (mRadioButtonLowerThan->isChecked()) { + mArgsInfo.upper_given = 1; + mArgsInfo.upper_arg = mThresholdSlider2->GetValue(); + if (mArgsInfo.upper_argGetValue(); + mArgsInfo.bg_arg = mBGSlider->GetValue(); + + if (inverseBGandFG) { + mArgsInfo.fg_arg = mFGSlider->GetValue(); + mArgsInfo.bg_arg = mBGSlider->GetValue(); + } + mArgsInfo.fg_given = 1; + mArgsInfo.bg_given = 1; + + if (mCheckBoxUseBG->isChecked()) { + if (mCheckBoxUseFG->isChecked()) mArgsInfo.mode_arg = (char*)"both"; + else mArgsInfo.mode_arg = (char*)"BG"; + } else mArgsInfo.mode_arg = (char*)"FG"; + + mArgsInfo.verbose_flag = false; + + // // Required (even if not used) + // mArgsInfo.input_given = 0; + // mArgsInfo.output_given = 0; + + // mArgsInfo.input_arg = new char; + // mArgsInfo.output_arg = new char; +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolProfile::apply() +{ + if (!mCurrentSlicerManager) close(); + QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); + GetArgsInfoFromGUI(); + + // Main filter + clitk::ProfileImageGenericFilter::Pointer filter = + clitk::ProfileImageGenericFilter::New(); + filter->SetInputVVImage(mCurrentImage); + filter->SetArgsInfo(mArgsInfo); + filter->Update(); + + + // Output + vvImage::Pointer output = filter->GetOutputVVImage(); + std::ostringstream osstream; + osstream << "Profiled_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd"; + AddImage(output,osstream.str()); + QApplication::restoreOverrideCursor(); + close(); +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolProfile::valueChangedT2(double v) +{ + // DD("valueChangedT2"); + if (mRadioButtonLowerThan->isChecked()) { + mThresholdSlider1->SetMaximum(v); + if (!mInteractiveDisplayIsEnabled) return; + for(int i=0;iGetNumberOfSlicers(); i++) { + mImageContourLower[i]->Update(v); + } + mCurrentSlicerManager->Render(); + } +} +//------------------------------------------------------------------------------ + + +//------------------------------------------------------------------------------ +void vvToolProfile::valueChangedT1(double v) +{ + // DD("valueChangedT1"); + if (!mCurrentSlicerManager) close(); + mThresholdSlider2->SetMinimum(v); + // int m1 = (int)lrint(v); + if (!mInteractiveDisplayIsEnabled) return; + for(int i=0;iGetNumberOfSlicers(); i++) { + mImageContour[i]->Update(v); + } + mCurrentSlicerManager->Render(); +} +//------------------------------------------------------------------------------ diff --git a/vv/vvToolProfile.h b/vv/vvToolProfile.h new file mode 100644 index 0000000..baaf4a9 --- /dev/null +++ b/vv/vvToolProfile.h @@ -0,0 +1,75 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================**/ +#ifndef VVTOOLPROFILE_H +#define VVTOOLPROFILE_H + +#include + +#include "vvToolBase.h" +#include "vvToolWidgetBase.h" +#include "vvImageContour.h" +#include "ui_vvToolProfile.h" + +#include "clitkProfileImage_ggo.h" + +//------------------------------------------------------------------------------ +class vvToolProfile: + public vvToolWidgetBase, + public vvToolBase, + private Ui::vvToolProfile +{ + Q_OBJECT + public: + vvToolProfile(vvMainWindowBase * parent=0, Qt::WindowFlags f=0); + ~vvToolProfile(); + + //----------------------------------------------------- + static void Initialize(); + void GetArgsInfoFromGUI(); + virtual void InputIsSelected(vvSlicerManager * m); + + //----------------------------------------------------- + public slots: + virtual void apply(); + virtual bool close(); + virtual void reject(); + void valueChangedT1(double v); + void valueChangedT2(double v); + void UpdateOrientation(int slicer, int orientation); + void UpdateSlice(int slicer,int slices); + void enableLowerThan(bool b); + void useFGBGtoggled(bool); + void InteractiveDisplayToggled(bool b); + // void LeftButtonReleaseEvent(int slicer); + + protected: + void RemoveVTKObjects(); + virtual void closeEvent(QCloseEvent *event); + Ui::vvToolProfile ui; + args_info_clitkProfileImage mArgsInfo; + std::vector mImageContour; + std::vector mImageContourLower; + bool mInteractiveDisplayIsEnabled; + + void Update(int slicer); + +}; // end class vvToolProfile +//------------------------------------------------------------------------------ + +#endif + -- 2.45.1