]> Creatis software - clitk.git/commitdiff
*** empty log message ***
authorbharath <bharath>
Fri, 9 Apr 2010 09:47:58 +0000 (09:47 +0000)
committerbharath <bharath>
Fri, 9 Apr 2010 09:47:58 +0000 (09:47 +0000)
filters/clitkMedianImageGenericFilter.cxx [new file with mode: 0644]
filters/clitkMedianImageGenericFilter.h [new file with mode: 0644]
filters/clitkMedianImageGenericFilter.txx [new file with mode: 0644]
tools/clitkMedianImageFilter.cxx [new file with mode: 0644]
tools/clitkMedianImageFilter.ggo [new file with mode: 0644]
vv/qt_ui/vvToolMedianFilter.ui [new file with mode: 0644]
vv/vvToolMedianFilter.cxx [new file with mode: 0644]
vv/vvToolMedianFilter.h [new file with mode: 0644]

diff --git a/filters/clitkMedianImageGenericFilter.cxx b/filters/clitkMedianImageGenericFilter.cxx
new file mode 100644 (file)
index 0000000..1a766a0
--- /dev/null
@@ -0,0 +1,15 @@
+#ifndef clitkMedianImageGenericFilter_cxx
+#define clitkMedianImageGenericFilter_cxx
+
+/* =================================================
+ * @file   clitkMedianImageGenericFilter.cxx
+ * @author Bharath Navalpakkam <Bharath.Navalpakkam@creatis.insa-lyon.fr>
+ * @date  20.03.2010  
+ * 
+ * @brief 
+ * 
+ ===================================================*/
+
+#include "clitkMedianImageGenericFilter.h"
+
+#endif  //#define clitkMedianImageGenericFilter_cxx
diff --git a/filters/clitkMedianImageGenericFilter.h b/filters/clitkMedianImageGenericFilter.h
new file mode 100644 (file)
index 0000000..8dee470
--- /dev/null
@@ -0,0 +1,85 @@
+/*=========================================================================
+
+  Program:   clitk
+  Module:    $RCSfile: clitkMedianImageGenericFilter.h,v $
+  Language:  C++
+  Date:      $Date: 2010/04/09 09:50:04 $
+  Version:   $Revision: 1.1 $
+  Author :  Bharath Navalpakkam <Bharath.Navalpakkam@creatis.insa-lyon.fr>
+  Copyright (C) 2010
+  Léon Bérard cancer center    http://oncora1.lyon.fnclcc.fr
+  CREATIS                      http://www.creatis.insa-lyon.fr
+
+  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.
+
+  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 <http://www.gnu.org/licenses/>.
+
+  =========================================================================*/
+
+#ifndef CLITKMEDIANIMAGEGENERICFILTER_H
+#define CLITKMEDIANIMAGEGENERICFILTER_H
+
+// clitk include
+#include "clitkIO.h"
+#include "clitkCommon.h"
+#include "clitkImageToImageGenericFilter.h"
+
+//--------------------------------------------------------------------
+namespace clitk 
+{
+  
+  template<class args_info_type>
+  class ITK_EXPORT MedianImageGenericFilter: 
+    public ImageToImageGenericFilter<MedianImageGenericFilter<args_info_type> >
+  {
+    
+  public:
+
+    //--------------------------------------------------------------------
+   MedianImageGenericFilter();
+
+    //--------------------------------------------------------------------
+    typedef MedianImageGenericFilter         Self;
+    typedef itk::SmartPointer<Self>            Pointer;
+    typedef itk::SmartPointer<const Self>      ConstPointer;
+   
+    //--------------------------------------------------------------------
+    // Method for creation through the object factory
+    // and Run-time type information (and related methods)
+    itkNewMacro(Self);  
+    itkTypeMacro(MedianImageGenericFilter, LightObject);
+  
+    //--------------------------------------------------------------------
+    void SetArgsInfo(const args_info_type & a);
+
+    //--------------------------------------------------------------------
+    // Main function called each time the filter is updated
+    template<class InputImageType>  
+    void UpdateWithInputImageType();
+    
+
+
+  protected:
+    template<unsigned int Dim> void InitializeImageType();
+    
+    args_info_type mArgsInfo;
+    
+  }; // end class
+  //--------------------------------------------------------------------
+    
+} // end namespace clitk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "clitkMedianImageGenericFilter.txx"
+#endif
+
+#endif // #define clitkMedianImageGenericFilter_h
diff --git a/filters/clitkMedianImageGenericFilter.txx b/filters/clitkMedianImageGenericFilter.txx
new file mode 100644 (file)
index 0000000..29a316c
--- /dev/null
@@ -0,0 +1,126 @@
+#ifndef clitkMedianImageGenericFilter_txx
+#define clitkMedianImageGenericFilter_txx
+
+/* =================================================
+ * @file   clitkMedianImageGenericFilter.txx
+ * @author Bharath Navalapakkam <Bharath.Navalpakkam@creatis.insa-lyon.fr>
+ * @date   20 March 2010
+ * 
+ * @brief 
+ * 
+ ===================================================*/
+
+// itk include
+#include "itkMedianImageFilter.h"
+#include "itkImage.h"
+
+namespace clitk
+{
+  
+  //--------------------------------------------------------------------
+  template<class args_info_type>
+  MedianImageGenericFilter<args_info_type>::MedianImageGenericFilter():
+    ImageToImageGenericFilter<Self>("MedianImage") {
+    InitializeImageType<2>();
+    InitializeImageType<3>();
+    InitializeImageType<4>();
+  }
+  //--------------------------------------------------------------------
+
+
+  //--------------------------------------------------------------------
+  template<class args_info_type>
+  template<unsigned int Dim>
+  void MedianImageGenericFilter<args_info_type>::InitializeImageType() {      
+    ADD_IMAGE_TYPE(Dim, char);
+    ADD_IMAGE_TYPE(Dim, uchar);
+    ADD_IMAGE_TYPE(Dim, short);
+    ADD_IMAGE_TYPE(Dim, int);
+    ADD_IMAGE_TYPE(Dim, float);
+    ADD_IMAGE_TYPE(Dim, double);
+    ADD_IMAGE_TYPE(Dim, unsigned short); 
+
+
+  }
+  //--------------------------------------------------------------------
+  
+
+  //--------------------------------------------------------------------
+  template<class args_info_type>
+  void MedianImageGenericFilter<args_info_type>::SetArgsInfo(const args_info_type & a) {
+    mArgsInfo=a;
+    SetIOVerbose(mArgsInfo.verbose_flag);
+  
+
+    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<class args_info_type>
+  template<class InputImageType>
+  void 
+  MedianImageGenericFilter<args_info_type>::UpdateWithInputImageType()
+  {
+     // Reading input
+    typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
+// Typedef
+  typedef typename InputImageType::PixelType PixelType;
+
+
+
+ // typedef itk::Image<PixelType,InputImageType::ImageDimension> OutputImageType;
+
+ // Main filter
+   
+     typedef itk::Image<uchar, InputImageType::ImageDimension> OutputImageType;
+     class  InputImageType::SizeType indexRadius;
+
+    // Filter
+    typedef itk::MedianImageFilter<InputImageType, OutputImageType> MedianImageFilterType;
+
+    typename MedianImageFilterType::Pointer thresholdFilter=MedianImageFilterType::New();
+    thresholdFilter->SetInput(input);
+
+
+indexRadius[0]=mArgsInfo.radius_arg[0];
+indexRadius[1]=mArgsInfo.radius_arg[1];
+indexRadius[2]=mArgsInfo.radius_arg[2];
+
+
+
+  
+// indexRadius[0] = 1; 
+ // indexRadius[1] = 1;
+
+thresholdFilter->SetRadius( indexRadius );
+  
+
+    typename OutputImageType::Pointer outputImage = thresholdFilter->GetOutput();
+ thresholdFilter->Update();
+     
+     // Write/Save results
+    this->template SetNextOutput<OutputImageType>(outputImage);
+
+   
+    }
+  
+  //--------------------------------------------------------------------
+
+}//end clitk
+
+
+#endif //#define clitkMedianImageGenericFilter_txx
+
diff --git a/tools/clitkMedianImageFilter.cxx b/tools/clitkMedianImageFilter.cxx
new file mode 100644 (file)
index 0000000..7c8dcc8
--- /dev/null
@@ -0,0 +1,47 @@
+/*------------------------------------------------------------------------
+                                                                                 
+  Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+  l'Image). All rights reserved. See Doc/License.txt or
+  http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
+                                                                                
+  This software is distributed WITHOUT ANY WARRANTY; without even
+  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+  PURPOSE.  See the above copyright notices for more information.
+                                                                             
+  ------------------------------------------------------------------------*/
+
+/* =================================================
+ * @file   clitkMedianImageGenericFilter.txx
+ * @author Bharath Navalpakkam <Bharath.Navalpakkam@creatis.insa-lyon.fr>
+ * @date   18 March 2010
+ * 
+ * @brief Apply Median Filter to an Image
+ * 
+ ===================================================*/
+
+// clitk
+#include "clitkMedianImageFilter_ggo.h"
+#include "clitkMedianImageGenericFilter.h"
+
+//--------------------------------------------------------------------
+int main(int argc, char * argv[]) {
+
+  // Init command line
+  GGO(clitkMedianImageFilter, args_info);
+  CLITK_INIT;
+
+  // Filter
+  clitk::MedianImageGenericFilter<args_info_clitkMedianImageFilter>::Pointer filter = 
+    clitk::MedianImageGenericFilter<args_info_clitkMedianImageFilter>::New();
+  
+    
+      filter->SetOutputFilename(args_info.output_arg);
+  filter->SetArgsInfo(args_info);
+  
+  filter->Update();
+
+  return EXIT_SUCCESS;
+}// end main
+
+//--------------------------------------------------------------------
diff --git a/tools/clitkMedianImageFilter.ggo b/tools/clitkMedianImageFilter.ggo
new file mode 100644 (file)
index 0000000..ffa8228
--- /dev/null
@@ -0,0 +1,12 @@
+#File clitkMedianImageFilter.ggo
+package "clitkMedianImageFilter"
+version "1.0"
+purpose ""
+
+option "config"                -       "Config file"                     string        no
+option "verbose"       v       "Verbose"                         flag          off
+option "input"         i       "Input image filename"            string        yes 
+option "output"        o       "Output image filename"           string        yes
+option "radius"        r       "Radius in each Direction"        int   multiple no default="1"
+
+
diff --git a/vv/qt_ui/vvToolMedianFilter.ui b/vv/qt_ui/vvToolMedianFilter.ui
new file mode 100644 (file)
index 0000000..fe31b04
--- /dev/null
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>vvToolMedianFilter</class>
+ <widget class="QWidget" name="vvToolMedianFilter">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>735</width>
+    <height>290</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Mean Filter</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout_3">
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_9">
+     <item>
+      <widget class="QLabel" name="label">
+       <property name="text">
+        <string>X Radius</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QSlider" name="horizontalSlider">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="lineEdit"/>
+     </item>
+     <item>
+      <layout class="QGridLayout" name="gridLayout_12"/>
+     </item>
+     <item>
+      <widget class="QLabel" name="label_2">
+       <property name="text">
+        <string>Y Radius</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QSlider" name="horizontalSlider_2">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="lineEdit_2"/>
+     </item>
+     <item>
+      <layout class="QVBoxLayout" name="verticalLayout_7"/>
+     </item>
+     <item>
+      <widget class="QLabel" name="label_3">
+       <property name="text">
+        <string>Z Radius</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QSlider" name="horizontalSlider_3">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="lineEdit_3"/>
+     </item>
+    </layout>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/vv/vvToolMedianFilter.cxx b/vv/vvToolMedianFilter.cxx
new file mode 100644 (file)
index 0000000..0d69855
--- /dev/null
@@ -0,0 +1,174 @@
+    /*=========================================================================
+
+      Program:   vv
+      Module:    $RCSfile: vvToolMedianFilter.cxx,v $
+      Language:  C++
+      Date:      $Date: 2010/04/09 09:53:27 $
+      Version:   $Revision: 1.1 $
+      Author :   Bharath Navalpakkam (Bharath.Navalpakkam@creatis.insa-lyon.fr)
+
+      Copyright (C) 2010
+      Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+      CREATIS                   http://www.creatis.insa-lyon.fr
+
+      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.
+
+      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 <http://www.gnu.org/licenses/>.
+
+      =========================================================================*/
+
+    #include "vvToolMedianFilter.h"
+    #include "vvSlicerManager.h"
+    #include "vvSlicer.h"
+    #include "vvToolInputSelectorWidget.h"
+    #include <clitkMedianImageGenericFilter.h>
+
+
+    //------------------------------------------------------------------------------
+    // Create the tool and automagically 
+    ADD_TOOL(vvToolMedianFilter);
+    //------------------------------------------------------------------------------
+
+    //------------------------------------------------------------------------------
+    vvToolMedianFilter::vvToolMedianFilter(vvMainWindowBase * parent, Qt::WindowFlags f) 
+      :vvToolWidgetBase(parent,f), 
+      vvToolBase<vvToolMedianFilter>(parent), 
+      Ui::vvToolMedianFilter()
+      {
+       
+      // Setup the UI
+    
+    Ui_vvToolMedianFilter::setupUi(mToolWidget);
+    
+    mFilter = new clitk::MedianImageGenericFilter<args_info_clitkMedianImageFilter>;
+    
+
+
+      // Main filter 
+
+      // Set how many inputs are needed for this tool
+  AddInputSelector("Select one image", mFilter);
+    }
+
+    //------------------------------------------------------------------------------
+    vvToolMedianFilter::~vvToolMedianFilter() {
+    }
+    //------------------------------------------------------------------------------
+
+
+    void vvToolMedianFilter::Initialize() {
+      SetToolName("MedianFilter");
+      SetToolMenuName("MedianFilter");
+      SetToolIconFilename(":/new/prefix1/icons/ducky.png");
+      SetToolTip("Make 'MedianFilter' on an image.");
+    }
+    //------------------------------------------------------------------------------
+
+  void vvToolMedianFilter::apply() {
+
+     GetArgsInfoFromGUI();
+
+    if (!mCurrentSlicerManager) close();
+  QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+  // Main filter
+  clitk::MedianImageGenericFilter<args_info_clitkMedianImageFilter>::Pointer filter = 
+     clitk::MedianImageGenericFilter<args_info_clitkMedianImageFilter>::New();
+    
+   filter->SetInputVVImage(mCurrentImage);
+  filter->SetArgsInfo(mArgsInfo);
+  filter->EnableReadOnDisk(false);
+  filter->Update();
+  
+
+  // Output
+  vvImage::Pointer output = filter->GetOutputVVImage();
+  std::ostringstream osstream;
+  osstream << "MedianFiltered_" << mCurrentSlicerManager->GetSlicer(0)->GetFileName() << ".mhd";
+  AddImage(output,osstream.str()); 
+  QApplication::restoreOverrideCursor();
+  close();
+     
+
+  }
+
+    //------------------------------------------------------------------------------
+
+  void vvToolMedianFilter::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);
+    */
+     mArgsInfo.radius_given=0;
+      mArgsInfo.verbose_flag = false;
+   // mArgsInfo.radius_arg = new int[3];
+
+  // Required (even if not used)
+    mArgsInfo.input_given = 0;
+    mArgsInfo.output_given = 0;
+    
+    mArgsInfo.input_arg=new char;
+    mArgsInfo.output_arg = new char;
+    
+  mArgsInfo.config_given=0;
+  mArgsInfo.verbose_given=0;
+  
+    
+ //  mArgsInfo.radius_arg[0]=1;
+   // mArgsInfo.radius_arg[1]=1;
+  //  mArgsInfo.radius_arg[2]=1;
+
+  }
+  //------------------------------------------------------------------------------
+void vvToolMedianFilter::InputIsSelected(vvSlicerManager *m){
+  mCurrentSlicerManager =m;
+  // Specific for this gui
+                    
+  mArgsInfo.radius_arg = new int[3];
+  connect(horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(UpdatevalueH1()));
+  connect(horizontalSlider_2, SIGNAL(valueChanged(int)), this, SLOT(UpdatevalueH2())); 
+  connect(horizontalSlider_3, SIGNAL(valueChanged(int)), this, SLOT(UpdatevalueH3()));
+  
+  
+  
+}
+
+  //-----------------------------------------------------------------------------
+
+void vvToolMedianFilter::UpdatevalueH1()
+{
+  mArgsInfo.radius_arg[0]=horizontalSlider->value();
+  QString string1 = QString::number(mArgsInfo.radius_arg[0]);
+  lineEdit->setText(string1);
+}
+void vvToolMedianFilter::UpdatevalueH2()
+{
+    mArgsInfo.radius_arg[1]=horizontalSlider_2->value(); 
+   QString string2 = QString::number(mArgsInfo.radius_arg[1]);
+  lineEdit_2->setText(string2);
+}
+void vvToolMedianFilter::UpdatevalueH3()
+{
+  mArgsInfo.radius_arg[2]=horizontalSlider_3->value(); 
+  QString string3 = QString::number(mArgsInfo.radius_arg[2]);
+  lineEdit_3->setText(string3);
+
+}
diff --git a/vv/vvToolMedianFilter.h b/vv/vvToolMedianFilter.h
new file mode 100644 (file)
index 0000000..c569a19
--- /dev/null
@@ -0,0 +1,77 @@
+      /*=========================================================================
+
+    Program:   vv
+    Module:    $RCSfile: vvToolMedianFilter.h,v $
+    Language:  C++
+    Date:      $Date: 2010/04/09 09:53:50 $
+    Version:   $Revision: 1.1 $
+    Author :   Bharath Navalpakkam (Bharath.Navalpakkam@creatis.insa-lyon.fr)
+
+    Copyright (C) 2010
+    Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
+    CREATIS                   http://www.creatis.insa-lyon.fr
+
+    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.
+
+    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 <http://www.gnu.org/licenses/>.
+
+    =========================================================================*/
+
+  #ifndef VVTOOLMedianFilter_H
+  #define VVTOOLMedianFilter_H
+
+  #include <QtDesigner/QDesignerExportWidget>
+  #include "vvToolBase.h"
+  #include "QDialog"
+  #include "vvToolWidgetBase.h"
+  #include "ui_vvToolMedianFilter.h"
+  #include "clitkMedianImageFilter_ggo.h"
+   #include <clitkMedianImageGenericFilter.h>
+
+
+  //------------------------------------------------------------------------------
+  class vvToolMedianFilter:
+    public vvToolWidgetBase,
+    public vvToolBase<vvToolMedianFilter>, 
+    private Ui::vvToolMedianFilter
+  {
+      Q_OBJECT 
+  public:
+      vvToolMedianFilter(vvMainWindowBase* parent=0, Qt::WindowFlags f=0);
+      ~vvToolMedianFilter();
+
+      static void Initialize();
+      virtual void GetArgsInfoFromGUI();
+      virtual void InputIsSelected(vvSlicerManager * m);
+      virtual void apply();
+
+    public slots:    
+          void UpdatevalueH1();
+         void UpdatevalueH2();
+          void UpdatevalueH3();
+         
+         
+   
+    
+      
+  protected:
+
+      Ui::vvToolMedianFilter ui;
+     args_info_clitkMedianImageFilter mArgsInfo;
+
+
+  }; // end class vvToolMedianFilter
+  //------------------------------------------------------------------------------
+
+  #endif
+