X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvToolBinarize.cxx;h=283428532cb666567c1c7ed11f3859108826e55c;hb=db3faf3195c84f987dea55d8116565a732d1b668;hp=4f91d19d2c20165c87bd0e1c7acfa23ac26f33de;hpb=98bdb72d057c122863776f8c3fb74659e8c87beb;p=clitk.git diff --git a/vv/vvToolBinarize.cxx b/vv/vvToolBinarize.cxx index 4f91d19..2834285 100644 --- a/vv/vvToolBinarize.cxx +++ b/vv/vvToolBinarize.cxx @@ -1,29 +1,20 @@ /*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv - Program: vv - Module: $RCSfile: vvToolBinarize.cxx,v $ - Language: C++ - Date: $Date: 2010/03/01 15:38:09 $ - Version: $Revision: 1.10 $ - Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr - Copyright (C) 2008 - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr - CREATIS-LRMN 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. - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, version 3 of the License. + It is distributed under dual licence - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - - =========================================================================*/ + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +======================================================================-====*/ #include "vvToolBinarize.h" #include "vvSlicerManager.h" @@ -47,7 +38,7 @@ ADD_TOOL(vvToolBinarize); void vvToolBinarize::Initialize() { SetToolName("Binarize"); SetToolMenuName("Binarize"); - SetToolIconFilename(":/new/prefix1/icons/binarize.png"); + SetToolIconFilename(":/common/icons/binarize.png"); SetToolTip("Image interactive binarization with thresholds."); } //------------------------------------------------------------------------------ @@ -64,8 +55,6 @@ vvToolBinarize::vvToolBinarize(vvMainWindowBase * parent, Qt::WindowFlags f) mInteractiveDisplayIsEnabled = mCheckBoxInteractiveDisplay->isChecked(); // Connect signals & slots - connect(mThresholdSlider1, SIGNAL(valueChanged(double)), this, SLOT(valueChangedT1(double))); - connect(mThresholdSlider2, SIGNAL(valueChanged(double)), this, SLOT(valueChangedT2(double))); 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))); @@ -78,7 +67,10 @@ vvToolBinarize::vvToolBinarize(vvMainWindowBase * parent, Qt::WindowFlags f) mBGSlider->SetText("Background value"); // Main filter - mFilter = new clitk::BinarizeImageGenericFilter; //DS PUT IN BASECLASS ? + mFilter = new clitk::BinarizeImageGenericFilter; + + // Set how many inputs are needed for this tool + AddInputSelector("Select one image", mFilter); } //------------------------------------------------------------------------------ @@ -96,8 +88,11 @@ void vvToolBinarize::InteractiveDisplayToggled(bool b) { RemoveVTKObjects(); } else { - for(unsigned int i=0; ishowActors(); + if (mRadioButtonLowerThan->isChecked()) + mImageContourLower[i]->showActors(); + } if (mCurrentSlicerManager) mCurrentSlicerManager->Render(); } @@ -107,8 +102,10 @@ void vvToolBinarize::InteractiveDisplayToggled(bool b) { //------------------------------------------------------------------------------ void vvToolBinarize::RemoveVTKObjects() { - for(unsigned int i=0; ihideActors(); + mImageContourLower[i]->hideActors(); + } if (mCurrentSlicerManager) mCurrentSlicerManager->Render(); } @@ -125,6 +122,7 @@ bool vvToolBinarize::close() { //------------------------------------------------------------------------------ void vvToolBinarize::reject() { + // DD("vvToolBinarize::reject"); RemoveVTKObjects(); return vvToolWidgetBase::reject(); } @@ -135,9 +133,18 @@ void vvToolBinarize::reject() { void vvToolBinarize::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(); } } //------------------------------------------------------------------------------ @@ -152,6 +159,10 @@ void vvToolBinarize::useFGBGtoggled(bool) { //------------------------------------------------------------------------------ +// void vvToolBinarize::InputIsSelected(std::vector & m) { +// DD("vvToolBinarize::InputIsSelected vector in binarize"); +// DD(m.size()); +// } void vvToolBinarize::InputIsSelected(vvSlicerManager * m) { mCurrentSlicerManager = m; @@ -169,13 +180,23 @@ void vvToolBinarize::InputIsSelected(vvSlicerManager * m) { mBGSlider->SetMinimum(mCurrentImage->GetFirstVTKImageData()->GetScalarTypeMin()); mFGSlider->SetValue(1); mBGSlider->SetValue(0); + mFGSlider->SetSingleStep(1); + mBGSlider->SetSingleStep(1); // VTK objects for interactive display for(int i=0;iNumberOfSlicers(); i++) { mImageContour.push_back(new vvImageContour); mImageContour[i]->setSlicer(mCurrentSlicerManager->GetSlicer(i)); + mImageContour[i]->setColor(1.0, 0.0, 0.0); + mImageContourLower.push_back(new vvImageContour); + mImageContourLower[i]->setSlicer(mCurrentSlicerManager->GetSlicer(i)); + mImageContourLower[i]->setColor(0.0, 0.0, 1.0); } 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))); @@ -188,12 +209,17 @@ void vvToolBinarize::UpdateSlice(int slicer,int slices) { if (!mInteractiveDisplayIsEnabled) return; if (!mCurrentSlicerManager) close(); for(int i=0;iNumberOfSlicers(); i++) { + // DD(i); mImageContour[i]->update(mThresholdSlider1->GetValue()); + if (mRadioButtonLowerThan->isChecked()) + mImageContourLower[i]->update(mThresholdSlider2->GetValue()); + } mCurrentSlicerManager->Render(); } //------------------------------------------------------------------------------ + //------------------------------------------------------------------------------ void vvToolBinarize::GetArgsInfoFromGUI() { @@ -262,8 +288,9 @@ void vvToolBinarize::apply() { // Main filter clitk::BinarizeImageGenericFilter::Pointer filter = clitk::BinarizeImageGenericFilter::New(); - filter->SetArgsInfo(mArgsInfo); filter->SetInputVVImage(mCurrentImage); + filter->SetArgsInfo(mArgsInfo); + filter->EnableReadOnDisk(false); filter->Update(); // Output @@ -279,20 +306,29 @@ void vvToolBinarize::apply() { //------------------------------------------------------------------------------ void vvToolBinarize::valueChangedT2(double v) { - if (mRadioButtonLowerThan->isChecked()) mThresholdSlider1->SetMaximum(v); + // DD("valueChangedT2"); + if (mRadioButtonLowerThan->isChecked()) { + mThresholdSlider1->SetMaximum(v); + if (!mInteractiveDisplayIsEnabled) return; + for(int i=0;iNumberOfSlicers(); i++) { + mImageContourLower[i]->update(v); + } + // mCurrentSlicerManager->Render(); + } } //------------------------------------------------------------------------------ //------------------------------------------------------------------------------ void vvToolBinarize::valueChangedT1(double v) { + // DD("valueChangedT1"); if (!mCurrentSlicerManager) close(); mThresholdSlider2->SetMinimum(v); - int m1 = (int)lrint(v); + // int m1 = (int)lrint(v); if (!mInteractiveDisplayIsEnabled) return; for(int i=0;iNumberOfSlicers(); i++) { - mImageContour[i]->update(m1); + mImageContour[i]->update(v); } - mCurrentSlicerManager->Render(); + // mCurrentSlicerManager->Render(); } //------------------------------------------------------------------------------