X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=vv%2FvvToolBinarize.cxx;h=fa22daad122e54bb2337d1feb1700f40bbd152e0;hb=488f24aa984ae24adc9458bf5fbf3b2351415742;hp=42154e3e27bffce3c9b76d06cb4c9abc4db69ed6;hpb=34490f432219fe05c7ae19c4cf012b5529d784dc;p=clitk.git
diff --git a/vv/vvToolBinarize.cxx b/vv/vvToolBinarize.cxx
index 42154e3..fa22daa 100644
--- a/vv/vvToolBinarize.cxx
+++ b/vv/vvToolBinarize.cxx
@@ -1,40 +1,35 @@
/*=========================================================================
+ Program: vv http://www.creatis.insa-lyon.fr/rio/vv
- Program: vv
- Module: $RCSfile: vvToolBinarize.cxx,v $
- Language: C++
- Date: $Date: 2010/03/24 10:48:18 $
- Version: $Revision: 1.13 $
- 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://www.centreleonberard.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
+ ===========================================================================**/
+// vv
#include "vvToolBinarize.h"
#include "vvSlicerManager.h"
#include "vvSlicer.h"
#include "vvToolInputSelectorWidget.h"
+// clitk
#include "clitkBinarizeImageGenericFilter.h"
+// vtk
#include
#include
#include
+#include
//------------------------------------------------------------------------------
// Create the tool and automagically (I like this word) insert it in
@@ -44,10 +39,11 @@ ADD_TOOL(vvToolBinarize);
//------------------------------------------------------------------------------
-void vvToolBinarize::Initialize() {
+void vvToolBinarize::Initialize()
+{
SetToolName("Binarize");
SetToolMenuName("Binarize");
- SetToolIconFilename(":/new/prefix1/icons/binarize.png");
+ SetToolIconFilename(":/common/icons/binarize.png");
SetToolTip("Image interactive binarization with thresholds.");
}
//------------------------------------------------------------------------------
@@ -55,15 +51,15 @@ void vvToolBinarize::Initialize() {
//------------------------------------------------------------------------------
vvToolBinarize::vvToolBinarize(vvMainWindowBase * parent, Qt::WindowFlags f)
- :vvToolWidgetBase(parent,f),
- vvToolBase(parent),
- Ui::vvToolBinarize()
+ :vvToolWidgetBase(parent,f),
+ vvToolBase(parent),
+ Ui::vvToolBinarize()
{
// GUI Initialization
Ui_vvToolBinarize::setupUi(mToolWidget);
mInteractiveDisplayIsEnabled = mCheckBoxInteractiveDisplay->isChecked();
- // Connect signals & slots
+ // 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)));
@@ -75,8 +71,8 @@ vvToolBinarize::vvToolBinarize(vvMainWindowBase * parent, Qt::WindowFlags f)
mFGSlider->SetText("Foreground value");
mBGSlider->SetText("Background value");
- // Main filter
- mFilter = new clitk::BinarizeImageGenericFilter;
+ // Main filter
+ mFilter = clitk::BinarizeImageGenericFilter::New();
// Set how many inputs are needed for this tool
AddInputSelector("Select one image", mFilter);
@@ -85,22 +81,23 @@ vvToolBinarize::vvToolBinarize(vvMainWindowBase * parent, Qt::WindowFlags f)
//------------------------------------------------------------------------------
-vvToolBinarize::~vvToolBinarize() {
+vvToolBinarize::~vvToolBinarize()
+{
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvToolBinarize::InteractiveDisplayToggled(bool b) {
+void vvToolBinarize::InteractiveDisplayToggled(bool b)
+{
mInteractiveDisplayIsEnabled = b;
if (!mInteractiveDisplayIsEnabled) {
RemoveVTKObjects();
- }
- else {
+ } else {
for(unsigned int i=0; ishowActors();
+ mImageContour[i]->ShowActors();
if (mRadioButtonLowerThan->isChecked())
- mImageContourLower[i]->showActors();
+ mImageContourLower[i]->ShowActors();
}
if (mCurrentSlicerManager)
mCurrentSlicerManager->Render();
@@ -110,10 +107,11 @@ void vvToolBinarize::InteractiveDisplayToggled(bool b) {
//------------------------------------------------------------------------------
-void vvToolBinarize::RemoveVTKObjects() {
+void vvToolBinarize::RemoveVTKObjects()
+{
for(unsigned int i=0; ihideActors();
- mImageContourLower[i]->hideActors();
+ mImageContour[i]->HideActors();
+ mImageContourLower[i]->HideActors();
}
if (mCurrentSlicerManager)
mCurrentSlicerManager->Render();
@@ -122,36 +120,46 @@ void vvToolBinarize::RemoveVTKObjects() {
//------------------------------------------------------------------------------
-bool vvToolBinarize::close() {
+bool vvToolBinarize::close()
+{
+ // RemoveVTKObjects();
+ return vvToolWidgetBase::close();
+}
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolBinarize::closeEvent(QCloseEvent *event) {
RemoveVTKObjects();
- return vvToolWidgetBase::close();
+ event->accept();
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvToolBinarize::reject() {
+void vvToolBinarize::reject()
+{
// DD("vvToolBinarize::reject");
RemoveVTKObjects();
- return vvToolWidgetBase::reject();
+ return vvToolWidgetBase::reject();
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvToolBinarize::enableLowerThan(bool b) {
+void vvToolBinarize::enableLowerThan(bool b)
+{
if (!b) {
mThresholdSlider1->resetMaximum();
for(unsigned int i=0; ihideActors();
+ mImageContourLower[i]->HideActors();
}
mCurrentSlicerManager->Render();
- }
- else {
+ } else {
valueChangedT1(mThresholdSlider1->GetValue());
valueChangedT2(mThresholdSlider2->GetValue());
for(unsigned int i=0; ishowActors();
+ mImageContourLower[i]->ShowActors();
}
mCurrentSlicerManager->Render();
}
@@ -160,8 +168,9 @@ void vvToolBinarize::enableLowerThan(bool b) {
//------------------------------------------------------------------------------
-void vvToolBinarize::useFGBGtoggled(bool) {
- if (!mCheckBoxUseBG->isChecked() && !mCheckBoxUseFG->isChecked())
+void vvToolBinarize::useFGBGtoggled(bool)
+{
+ if (!mCheckBoxUseBG->isChecked() && !mCheckBoxUseFG->isChecked())
mCheckBoxUseBG->toggle();
}
//------------------------------------------------------------------------------
@@ -172,7 +181,8 @@ void vvToolBinarize::useFGBGtoggled(bool) {
// DD("vvToolBinarize::InputIsSelected vector in binarize");
// DD(m.size());
// }
-void vvToolBinarize::InputIsSelected(vvSlicerManager * m) {
+void vvToolBinarize::InputIsSelected(vvSlicerManager * m)
+{
mCurrentSlicerManager = m;
// Specific for this gui
@@ -183,23 +193,30 @@ void vvToolBinarize::InputIsSelected(vvSlicerManager * m) {
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());
+ // 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;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);
+ 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);
+ mImageContourLower.push_back(vvImageContour::New());
+ mImageContourLower[i]->SetSlicer(mCurrentSlicerManager->GetSlicer(i));
+ mImageContourLower[i]->SetColor(0.0, 0.0, 1.0);
}
valueChangedT1(mThresholdSlider1->GetValue());
@@ -208,47 +225,71 @@ void vvToolBinarize::InputIsSelected(vvSlicerManager * m) {
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 vvToolBinarize::UpdateSlice(int slicer,int slices) {
+// void vvToolBinarize::LeftButtonReleaseEvent(int slicer) {
+// DD("LeftButtonReleaseEvent");
+// for(int i=0; iGetNumberOfSlicers(); i++) {
+// if (i == slicer);
+// mCurrentSlicerManager->GetSlicer(i)->GetRenderWindow()->Render();
+// }
+// }
+//------------------------------------------------------------------------------
+
+
+//------------------------------------------------------------------------------
+void vvToolBinarize::UpdateOrientation(int slicer,int orientation)
+{
+ Update(slicer);
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void vvToolBinarize::UpdateSlice(int slicer,int slices)
+{
+ Update(slicer);
+}
+//------------------------------------------------------------------------------
+
+//------------------------------------------------------------------------------
+void vvToolBinarize::Update(int slicer)
+{
if (!mInteractiveDisplayIsEnabled) return;
if (!mCurrentSlicerManager) close();
- for(int i=0;iNumberOfSlicers(); i++) {
- mImageContour[i]->update(mThresholdSlider1->GetValue());
- if (mRadioButtonLowerThan->isChecked())
- mImageContourLower[i]->update(mThresholdSlider2->GetValue());
-
- }
- mCurrentSlicerManager->Render();
+ mImageContour[slicer]->Update(mThresholdSlider1->GetValue());
+ if (mRadioButtonLowerThan->isChecked())
+ mImageContourLower[slicer]->Update(mThresholdSlider2->GetValue());
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvToolBinarize::GetArgsInfoFromGUI() {
+void vvToolBinarize::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);
+ 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);
*/
-
- mArgsInfo.imagetypes_flag = 0;
- mArgsInfo.upper_given = 0;
- mArgsInfo.lower_given = 0;
+ cmdline_parser_clitkBinarizeImage_init(&mArgsInfo); // Initialisation to default
bool inverseBGandFG = false;
mArgsInfo.lower_given = 1;
mArgsInfo.lower_arg = mThresholdSlider1->GetValue();
- // DD(mArgsInfo.lower_arg);
if (mRadioButtonLowerThan->isChecked()) {
mArgsInfo.upper_given = 1;
mArgsInfo.upper_arg = mThresholdSlider2->GetValue();
@@ -271,40 +312,39 @@ void vvToolBinarize::GetArgsInfoFromGUI() {
if (mCheckBoxUseBG->isChecked()) {
if (mCheckBoxUseFG->isChecked()) mArgsInfo.mode_arg = (char*)"both";
else mArgsInfo.mode_arg = (char*)"BG";
- }
- else mArgsInfo.mode_arg = (char*)"FG";
+ } 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;
+ // // Required (even if not used)
+ // mArgsInfo.input_given = 0;
+ // mArgsInfo.output_given = 0;
+
+ // mArgsInfo.input_arg = new char;
+ // mArgsInfo.output_arg = new char;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
-void vvToolBinarize::apply() {
+void vvToolBinarize::apply()
+{
if (!mCurrentSlicerManager) close();
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
GetArgsInfoFromGUI();
// Main filter
- clitk::BinarizeImageGenericFilter::Pointer filter =
- clitk::BinarizeImageGenericFilter::New();
+ clitk::BinarizeImageGenericFilter::Pointer filter =
+ clitk::BinarizeImageGenericFilter::New();
filter->SetInputVVImage(mCurrentImage);
filter->SetArgsInfo(mArgsInfo);
- filter->EnableReadOnDisk(false);
filter->Update();
// Output
vvImage::Pointer output = filter->GetOutputVVImage();
std::ostringstream osstream;
osstream << "Binarized_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd";
- AddImage(output,osstream.str());
+ AddImage(output,osstream.str());
QApplication::restoreOverrideCursor();
close();
}
@@ -312,13 +352,14 @@ void vvToolBinarize::apply() {
//------------------------------------------------------------------------------
-void vvToolBinarize::valueChangedT2(double v) {
+void vvToolBinarize::valueChangedT2(double v)
+{
// DD("valueChangedT2");
if (mRadioButtonLowerThan->isChecked()) {
mThresholdSlider1->SetMaximum(v);
if (!mInteractiveDisplayIsEnabled) return;
- for(int i=0;iNumberOfSlicers(); i++) {
- mImageContourLower[i]->update(v);
+ for(int i=0;iGetNumberOfSlicers(); i++) {
+ mImageContourLower[i]->Update(v);
}
mCurrentSlicerManager->Render();
}
@@ -327,14 +368,15 @@ void vvToolBinarize::valueChangedT2(double v) {
//------------------------------------------------------------------------------
-void vvToolBinarize::valueChangedT1(double v) {
+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(v);
+ for(int i=0;iGetNumberOfSlicers(); i++) {
+ mImageContour[i]->Update(v);
}
mCurrentSlicerManager->Render();
}