From cf5d06f41440fd7f41748aea480b2b18deaa1bc6 Mon Sep 17 00:00:00 2001 From: dsarrut Date: Sun, 7 Feb 2010 08:49:38 +0000 Subject: [PATCH] binarize --- filters/clitkBinarizeImage.ggo | 1 + filters/clitkBinarizeImageGenericFilter.txx | 22 ++++ vv/vvMainWindow.cxx | 8 +- vv/vvToolBinarize.cxx | 132 +++++++++++--------- vv/vvToolBinarize.h | 12 +- 5 files changed, 107 insertions(+), 68 deletions(-) diff --git a/filters/clitkBinarizeImage.ggo b/filters/clitkBinarizeImage.ggo index c4620da..9f655b6 100644 --- a/filters/clitkBinarizeImage.ggo +++ b/filters/clitkBinarizeImage.ggo @@ -16,3 +16,4 @@ option "upper" u "Upper intensity (default=max), fg is lower than this va 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" default="both" no + diff --git a/filters/clitkBinarizeImageGenericFilter.txx b/filters/clitkBinarizeImageGenericFilter.txx index 80837bd..56d85e9 100644 --- a/filters/clitkBinarizeImageGenericFilter.txx +++ b/filters/clitkBinarizeImageGenericFilter.txx @@ -93,6 +93,27 @@ namespace clitk DD(mArgsInfo.bg_given); DD(mArgsInfo.mode_arg); +// <<<<<<< clitkBinarizeImageGenericFilter.txx +// DD(mArgsInfo.useFG_flag); +// DD(mArgsInfo.useBG_flag); + +// thresholdFilter->SetInsideValue(mArgsInfo.fg_arg); + +// // Keep BG value to 0 if maskFilterType is used after +// if (mArgsInfo.useBG_flag && mArgsInfo.useFG_flag) { +// thresholdFilter->SetOutsideValue(mArgsInfo.bg_arg); +// } +// else { +// DD("0"); +// thresholdFilter->SetOutsideValue(0); +// } + +// // thresholdFilter->Update(); + +// // If no BG or no FG : new image, copy input with MaskImageFilter +// // If setFG -> FG BG have been changed +// if (mArgsInfo.useBG_flag && mArgsInfo.useFG_flag) { +// ======= /* 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 @@ -101,6 +122,7 @@ namespace clitk if (mArgsInfo.mode_arg == std::string("both")) { thresholdFilter->SetOutsideValue(mArgsInfo.bg_arg); thresholdFilter->Update(); + //>>>>>>> 1.5 typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput(); this->template SetNextOutput(outputImage); } diff --git a/vv/vvMainWindow.cxx b/vv/vvMainWindow.cxx index 2cb2870..7e955c0 100644 --- a/vv/vvMainWindow.cxx +++ b/vv/vvMainWindow.cxx @@ -3,8 +3,8 @@ Program: vv Module: $RCSfile: vvMainWindow.cxx,v $ Language: C++ - Date: $Date: 2010/02/06 15:38:13 $ - Version: $Revision: 1.7 $ + Date: $Date: 2010/02/07 08:49:41 $ + Version: $Revision: 1.8 $ Author : Pierre Seroul (pierre.seroul@gmail.com) Copyright (C) 200COLUMN_IMAGE_NAME @@ -115,10 +115,10 @@ vvMainWindow::vvMainWindow() { this->setContextMenuPolicy(Qt::CustomContextMenu); contextActions.resize(0); QAction* actionOpen_new_image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/fileopen.png")), - tr("Open new Image")); + tr("O&pen new Image")); + actionOpen_new_image->setShortcut(QKeySequence(tr("Ctrl+O"))); connect(actionOpen_new_image,SIGNAL(triggered()),this,SLOT(OpenImages())); contextActions.push_back(actionOpen_new_image); - actionOpen_new_image->setShortcut("Ctrl+O");//Qt::CTRL & Qt::Key_O); contextMenu.addSeparator(); QAction* actionClose_Image = contextMenu.addAction(QIcon(QString::fromUtf8(":/new/prefix1/icons/exit.png")), diff --git a/vv/vvToolBinarize.cxx b/vv/vvToolBinarize.cxx index c5f209d..9a45d1c 100644 --- a/vv/vvToolBinarize.cxx +++ b/vv/vvToolBinarize.cxx @@ -3,8 +3,8 @@ Program: vv Module: $RCSfile: vvToolBinarize.cxx,v $ Language: C++ - Date: $Date: 2010/02/06 15:38:14 $ - Version: $Revision: 1.5 $ + Date: $Date: 2010/02/07 08:49:42 $ + Version: $Revision: 1.6 $ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) Copyright (C) 2008 @@ -66,10 +66,15 @@ vvToolBinarize::vvToolBinarize(QWidget * parent, Qt::WindowFlags f) connect(mCheckBoxUseBG, SIGNAL(toggled(bool)), this, SLOT(useFGBGtoggled(bool))); // VTK objects + /* mClipper = vtkImageClip::New(); mSquares1 = vtkMarchingSquares::New(); mSquaresMapper1 = vtkPolyDataMapper::New(); mSquaresActor1 = vtkActor::New(); + */ + mImageContour = new vvImageContour; + + //new vector of contours // Initialize some widget mThresholdSlider1->SetText(""); @@ -77,7 +82,6 @@ vvToolBinarize::vvToolBinarize(QWidget * parent, Qt::WindowFlags f) mFGSlider->SetText("Foreground value"); mBGSlider->SetText("Background value"); - // Disable main widget while input image is not selected toolMainWidget->setEnabled(false); @@ -143,18 +147,21 @@ void vvToolBinarize::InputIsSelected() { DD(mCurrentSliceManager->NumberOfSlicers()); // mClipper->SetInput(mCurrentSliceManager->GetSlicer(0)->GetInput()); DD(mCurrentImage->GetFirstVTKImageData()); - DD(mClipper); + // DD(mClipper); DD(mCurrentSliceManager->GetSlicer(0)); + mImageContour->setSlicer(mCurrentSliceManager->GetSlicer(0)); + + /* mClipper->SetInput(mCurrentImage->GetFirstVTKImageData()); - mSquares1->SetInput(mClipper->GetOutput()); mSquaresMapper1->SetInput(mSquares1->GetOutput()); + mSquaresMapper1->ScalarVisibilityOff(); mSquaresActor1->SetMapper(mSquaresMapper1); mSquaresActor1->GetProperty()->SetColor(1.0,0,0); mSquaresActor1->SetPickable(0); mCurrentSliceManager->GetSlicer(0)->GetRenderer()->AddActor(mSquaresActor1); mSquares1->Update(); - + */ DD("VTK end"); @@ -174,62 +181,63 @@ void vvToolBinarize::UpdateSlice(int slicer,int slices) { // !! signal update slice pas tjs quand move slicer ??? - - int slice = mCurrentSliceManager->GetSlicer(0)->GetSlice(); - //int tslice = mCurrentSliceManager->GetSlicer(0)->GetTSlice(); - mClipper->SetInput(mCurrentSliceManager->GetSlicer(0)->GetInput()); - int* extent = mCurrentSliceManager->GetSlicer(0)->GetImageActor()->GetDisplayExtent(); - mClipper->SetOutputWholeExtent(extent[0],extent[1],extent[2],extent[3],extent[4],extent[5]); - int i; - for (i = 0; i < 6;i = i+2) - { - if (extent[i] == extent[i+1]) - { - break; - } - } - - switch (i) - { - case 0: - if (mCurrentSliceManager->GetSlicer(0)->GetRenderer()->GetActiveCamera()->GetPosition()[0] > slice) - { - mSquaresActor1->SetPosition(1,0,0); - // mSquaresActor2->SetPosition(1,0,0); - } - else - { - mSquaresActor1->SetPosition(-1,0,0); - // mSquaresActor2->SetPosition(-1,0,0); - } - break; - case 2: - if (mCurrentSliceManager->GetSlicer(0)->GetRenderer()->GetActiveCamera()->GetPosition()[1] > slice) - { - mSquaresActor1->SetPosition(0,1,0); - // mSquaresActor2->SetPosition(0,1,0); - } - else - { - mSquaresActor1->SetPosition(0,-1,0); - // mSquaresActor2->SetPosition(0,-1,0); - } - break; - case 4: - if (mCurrentSliceManager->GetSlicer(0)->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice) - { - mSquaresActor1->SetPosition(0,0,1); - // mSquaresActor2->SetPosition(0,0,1); - } - else - { - mSquaresActor1->SetPosition(0,0,-1); - // mSquaresActor2->SetPosition(0,0,-1); - } - break; - } - mSquares1->Update(); - // mSquares2->Update(); + mImageContour->update(); + + // int slice = mCurrentSliceManager->GetSlicer(0)->GetSlice(); + // //int tslice = mCurrentSliceManager->GetSlicer(0)->GetTSlice(); + // mClipper->SetInput(mCurrentSliceManager->GetSlicer(0)->GetInput()); + // int* extent = mCurrentSliceManager->GetSlicer(0)->GetImageActor()->GetDisplayExtent(); + // mClipper->SetOutputWholeExtent(extent[0],extent[1],extent[2],extent[3],extent[4],extent[5]); + // int i; + // for (i = 0; i < 6;i = i+2) + // { + // if (extent[i] == extent[i+1]) + // { + // break; + // } + // } + + // switch (i) + // { + // case 0: + // if (mCurrentSliceManager->GetSlicer(0)->GetRenderer()->GetActiveCamera()->GetPosition()[0] > slice) + // { + // mSquaresActor1->SetPosition(1,0,0); + // // mSquaresActor2->SetPosition(1,0,0); + // } + // else + // { + // mSquaresActor1->SetPosition(-1,0,0); + // // mSquaresActor2->SetPosition(-1,0,0); + // } + // break; + // case 2: + // if (mCurrentSliceManager->GetSlicer(0)->GetRenderer()->GetActiveCamera()->GetPosition()[1] > slice) + // { + // mSquaresActor1->SetPosition(0,1,0); + // // mSquaresActor2->SetPosition(0,1,0); + // } + // else + // { + // mSquaresActor1->SetPosition(0,-1,0); + // // mSquaresActor2->SetPosition(0,-1,0); + // } + // break; + // case 4: + // if (mCurrentSliceManager->GetSlicer(0)->GetRenderer()->GetActiveCamera()->GetPosition()[2] > slice) + // { + // mSquaresActor1->SetPosition(0,0,1); + // // mSquaresActor2->SetPosition(0,0,1); + // } + // else + // { + // mSquaresActor1->SetPosition(0,0,-1); + // // mSquaresActor2->SetPosition(0,0,-1); + // } + // break; + // } + // mSquares1->Update(); + // // mSquares2->Update(); mCurrentSliceManager->Render(); } diff --git a/vv/vvToolBinarize.h b/vv/vvToolBinarize.h index b40b267..50ca44b 100644 --- a/vv/vvToolBinarize.h +++ b/vv/vvToolBinarize.h @@ -3,8 +3,8 @@ Program: vv Module: $RCSfile: vvToolBinarize.h,v $ Language: C++ - Date: $Date: 2010/02/06 15:38:14 $ - Version: $Revision: 1.3 $ + Date: $Date: 2010/02/07 08:49:42 $ + Version: $Revision: 1.4 $ Author : David Sarrut (david.sarrut@creatis.insa-lyon.fr) Copyright (C) 2010 @@ -32,6 +32,7 @@ #include #include "vvToolBase.h" +#include "vvImageContour.h" #include "ui_vvToolBinarize.h" #include "clitkBinarizeImage_ggo.h" @@ -94,6 +95,13 @@ class vvToolBinarize: vtkPolyDataMapper* mSquaresMapper1; vtkActor* mSquaresActor1; + vvImageContour * mImageContour; + + /* vtkImageClip* mClipper; */ + /* vtkMarchingSquares* mSquares1; */ + /* vtkPolyDataMapper* mSquaresMapper1; */ + /* vtkActor* mSquaresActor1; */ + }; // end class vvToolBinarize //------------------------------------------------------------------------------ -- 2.49.0