]> Creatis software - creaImageIO.git/commitdiff
convert Analyze files to vtkImageData
authorFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Wed, 27 Apr 2011 19:12:20 +0000 (19:12 +0000)
committerFrederic Cervenansky <Frederic.Cervenansky@creatis.insa-lyon.fr>
Wed, 27 Apr 2011 19:12:20 +0000 (19:12 +0000)
src/CMakeLists.txt
src/creaImageIOWxISimpleDlg.hpp [new file with mode: 0644]
src/creaImageIOWxIsimpleDlg.h [new file with mode: 0644]
src/creaImageIOWxSimpleDlg.cpp
src/itkImageToVTKImageFilter.h [new file with mode: 0644]
src/itkImageToVTKImageFilter.txx [new file with mode: 0644]

index bce3f2be3170872481828e3711bff374bb2c243d..ea8d3328a7afd2d896a1286efcf57caaa7b1b95e 100644 (file)
@@ -74,7 +74,7 @@ FILE(GLOB SOURCES_CREAIMAGEIO_IMG_READER
 IF(USE_ITK)
 FILE(GLOB SOURCES_CREAIMAGEIO_ITK_DLG
        creaImageIOWxIsimpleDlg.h
-       creaImageIOWxIsimpleDlg.txx
+       creaImageIOWxIsimpleDlg.hpp
        )
 ENDIF(USE_ITK)
          
diff --git a/src/creaImageIOWxISimpleDlg.hpp b/src/creaImageIOWxISimpleDlg.hpp
new file mode 100644 (file)
index 0000000..e310a07
--- /dev/null
@@ -0,0 +1,339 @@
+//#include "creaImageIOWxISimpleDlg.h"
+
+#include "creaImageIOWxGimmickReaderDialog.h"
+#include <itkAnalyzeImageIO.h>
+#include <itkImageFileReader.h>
+#include <itkImage.h>
+#include <itkImageSeriesWriter.h>
+#include <itkNumericSeriesFileNames.h>
+#include "itkImageToVTKImageFilter.h"
+#include <vtkImageReader2.h>
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem.hpp>
+#include <boost/utility.hpp>
+
+namespace creaImageIO
+{
+               template <typename TImage2> 
+  typename TImage2::Pointer ReadImage( const std::string &fileName) 
+  { 
+
+
+
+    typename TImage2::Pointer image; 
+
+    typedef itk::ImageFileReader<TImage2> ReaderType; 
+    typename ReaderType::Pointer reader = ReaderType::New(); 
+    reader->SetFileName( fileName.c_str() ); 
+    try 
+      { 
+      reader->Update(); 
+      } 
+    catch( itk::ExceptionObject & err ) 
+      { 
+      std::cout << "Caught an exception reading" << fileName << ": " << std::endl; 
+      std::cout << err << " " << __FILE__ << " " << __LINE__ << std::endl; 
+      throw err; 
+      } 
+    catch(...) 
+      { 
+      std::cout << "Error while reading image " << fileName << std::endl; 
+      throw; 
+      } 
+     image = reader->GetOutput(); 
+    
+    return image; 
+  } 
+
+
+       ///Ctor
+  template <typename TImage> 
+   WxISimpleDlg<TImage>::WxISimpleDlg(wxWindow *parent, 
+                                                       wxString i_title,  
+                                                       const std::string i_namedescp , 
+                                                       const std::string i_namedb)
+    : wxDialog(parent, -1,_T("DISPLAY IMAGES"), wxDefaultPosition, wxSize(230,150))
+   {
+               namedescp       = i_namedescp; 
+               namedb          = i_namedb;
+
+          if(!i_title.empty())
+          {
+                       this->SetTitle(i_title);  
+          }
+          // Button to select file(s)
+          wxButton *fileBut = new wxButton(this, -1,_T("Select a file to display"), wxPoint(10,7) );
+          Connect( fileBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxISimpleDlg::OnReadFile ); 
+
+          // Button to select directory
+          wxButton *directoryBut = new wxButton(this, -1,_T("Select a directory to display"), wxPoint(10,40) );
+          Connect( directoryBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxISimpleDlg::OnReadDirectory ); 
+
+          // button to select creaImageIO
+          wxButton *gimmickBut = new wxButton(this, -1,_T("Select Gimmick"), wxPoint(10,70) );
+          Connect( gimmickBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxISimpleDlg::OnReadGimmick ); 
+
+          /// \TODO  Button to select Bruker directory
+       
+       Layout(); 
+       
+       }
+//////////////////////////////////////////////////////////////////////
+//                                                                  //
+//////////////////////////////////////////////////////////////////////
+     template <typename TImage> 
+         void WxISimpleDlg<TImage>::OnReadFile(wxCommandEvent& event)
+         {
+                 int resultShowModal;
+                 wxFileDialog* fileDlg = new wxFileDialog( 0,  _T("Select file"), _T(""), _T(""), crea::std2wx("*"), wxOPEN |wxFD_MULTIPLE, wxDefaultPosition);
+    
+                   resultShowModal = fileDlg->ShowModal();
+                       if ( resultShowModal==wxID_OK )
+                       {
+                               wxArrayString wxArray;
+                               fileDlg->GetPaths(wxArray);
+                               if(wxArray.size() >0)
+                               {
+                                       for( int i = 0; i < wxArray.GetCount(); i++)
+                                       {
+                                               readImg( crea::wx2std(wxArray[i]));
+                                       }
+                               } 
+                               else {
+                                       // TO DO WARNING MESSAGES
+                               }
+                       }
+                 SetReturnCode( resultShowModal );
+//              Close();
+                EndModal( resultShowModal );
+         }
+
+
+           template <typename TImage> 
+               void WxISimpleDlg<TImage>::setExts(std::vector<std::string> i_exts)
+               {
+                       m_exts = i_exts;
+               }
+ //////////////////////////////////////////////////////////////////////
+//                                                                                                                                     //
+//////////////////////////////////////////////////////////////////////
+           template <typename TImage> 
+         void WxISimpleDlg<TImage>::OnReadDirectory(wxCommandEvent &event)
+         {
+                 int resultShowModal;
+                 bool bvalid = false;
+            long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
+                wxDirDialog* dirDlg = new wxDirDialog( 0, _T("Select the directory to display"), _T(""), style);
+                
+                resultShowModal = dirDlg->ShowModal();
+                if ( resultShowModal==wxID_OK )
+                {  
+                       std::string path = crea::wx2std(dirDlg->GetPath());
+                       typedef boost::filesystem::directory_iterator dir_it;
+                       dir_it itr(path);
+                       dir_it end_itr;
+                       /*if (boost::filesystem::exists(path))
+                       {*/
+                               for(;itr != end_itr; ++itr)
+                               {
+                                          bvalid = m_exts.size() == 0? true : false;
+                                          std::vector<std::string>::iterator it = m_exts.begin();
+                                          std::string ext = itr->filename().substr(itr->filename().find_last_of("."));
+                                          for(; it != m_exts.end(); it++)
+                                          {
+                                                  if(ext == (*it) )
+                                                  {
+                                                          bvalid = true;
+                                                          break;
+                                                  }
+                                          }
+                                       if (!boost::filesystem::is_directory(itr->status()) && bvalid)
+                                       {
+                                               readImg(itr->string().c_str());
+                                       }
+                               }
+                }
+                SetReturnCode( resultShowModal );
+//              Close();
+                EndModal( resultShowModal );
+         }
+
+         //////////////////////////////////////////////////////////////////////
+//                                                                                                                                     //
+//////////////////////////////////////////////////////////////////////
+                   template <typename TImage> 
+         void WxISimpleDlg<TImage>::OnReadGimmick(wxCommandEvent &event)
+         {
+                 // Run Gimmick
+                  WxGimmickReaderDialog dlg(0,-1, 
+                                  namedescp,
+                                  namedb, 
+                                  _T("Select image(s)        - Gimmick! (c) CREATIS-LRMN 2008"),
+                   wxDefaultPosition,
+                   wxSize(810,750),
+                   GIMMICK_2D_IMAGE_SELECTION,
+                   GIMMICK_3D_IMAGE_SELECTION,
+                   _3D,
+                                  1);
+                dlg.ShowModal();
+                if (dlg.GetReturnCode() == wxID_OK)
+            {
+       //              infoimage=_T("DICOM: ???_EED_???");
+//EED 07JUIN2010                       dlg.GetSelectedImages(m_results,3);
+                       std::vector<creaImageIO::OutStrGimmick> out;
+                       std::vector<std::string> attr;
+//                             attr.push_back("D0028_0010");
+//                             attr.push_back("D0008_0023");
+//                             attr.push_back("D0008_1070");
+                               dlg.stopReading();
+                               dlg.getSelected(out, attr,true,"");
+//                             crea::VtkBasicSlicer(out.front().img);
+                       //m_results.clear();
+                       int size=out.size();
+                       int ii;
+                       //for (ii=0;ii<size;ii++)
+                       //{
+                               //m_results.push_back(out[ii].img);
+                       //}
+
+                       dlg.OnExit();
+                }
+                SetReturnCode( dlg.GetReturnCode() );
+//              Close();
+                EndModal( dlg.GetReturnCode() );
+          }
+
+
+     template <typename TImage> 
+        wxString WxISimpleDlg<TImage>::getInfoImage()
+       {
+               return infoimage;
+       }
+
+
+    //////////////////////////////////////////////////////////////////////
+    // Return the results vector                                                                               //
+    //////////////////////////////////////////////////////////////////////
+        template <typename TImage>  
+        std::vector<typename TImage::Pointer> WxISimpleDlg<TImage>::getImagesSelected()
+         {
+                 return m_Iresults;
+         }
+
+         template <typename TImage> 
+         void WxISimpleDlg<TImage>::readImg(const std::string &i_name)
+         {
+                   // FCY : just to check but not needed, we hardly suppose that we load only same type and dim of images
+                   // uncomment to test
+                       /*typedef itk::ImageIOBase::IOComponentType ScalarPixelType;
+                       itk::ImageIOBase::Pointer imageIO =  itk::ImageIOFactory::CreateImageIO(i_name.c_str(), itk::ImageIOFactory::ReadMode);
+                   imageIO->SetFileName(i_name.c_str());
+                       imageIO->ReadImageInformation();
+                       ScalarPixelType pixelType = imageIO->GetComponentType();
+                       const size_t dims =  imageIO->GetNumberOfDimensions();*/
+
+                       typedef itk::ImageFileReader<TImage> ReaderType; 
+                   typename ReaderType::Pointer reader = ReaderType::New(); 
+                       reader->SetFileName( i_name ); 
+                       try 
+                       { 
+                               reader->Update(); 
+                       } 
+                       catch( itk::ExceptionObject & err ) 
+                       { 
+                               std::cout << "Caught an exception reading" << i_name << ": " << std::endl; 
+                               std::cout << err << " " << __FILE__ << " " << __LINE__ << std::endl; 
+                               throw err; 
+                       } 
+                       catch(...) 
+                       { 
+                               std::cout << "Error while reading image " << i_name << std::endl; 
+                               throw; 
+                       } 
+                       m_Iresults.push_back(reader->GetOutput()); 
+    
+         }
+
+
+
+         template <typename TImage> 
+         void WxISimpleDlg<TImage>::split3Din3Dvtk()
+         {
+                
+                int ii;
+                 if ((m_Iresults).size() != 0)
+                 {
+
+                         typename TImage::Pointer image = m_Iresults[0];
+                         image->GetImageDimension();
+                         typedef itk::ImageToVTKImageFilter< TImage > ConnectorType;
+                         ConnectorType::Pointer connector = ConnectorType::New();
+                         for(unsigned int i = 0 ;i < m_Iresults.size(); i++)
+                                  {
+                                               connector->SetInput(m_Iresults[i]);
+                                               connector->Update();
+                                               vtkImageData *im = vtkImageData::New();
+                                               im->ShallowCopy(connector->GetOutput());
+                                               m_Vresults.push_back(im);
+                                  }
+                 }
+         }
+
+
+
+         template <typename TImage> 
+         void WxISimpleDlg<TImage>::split4Din3Dvtk(const std::string &i_dir)
+         {
+                       if ((m_Iresults).size() != 0)
+                       {
+                           typename TImage::Pointer image = m_Iresults[0];
+                       
+                                // Size and dims for Input Image
+                               typedef itk::Size<4> iSize;
+                               typedef const itk::Size<4>::SizeValueType iSizeVal;
+                               iSize size = image->GetLargestPossibleRegion().GetSize();
+                               iSizeVal *dims_size  = size.GetSize();
+
+                                // Output Type
+                                typedef itk::Image<short,3> ImageOutputType;  
+                            typedef itk::ImageSeriesWriter<TImage, ImageOutputType >  SeriesWriterType;
+                 
+                                SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();
+                                seriesWriter->SetInput( image);
+                       
+                                // from JPR file to generate output files
+                                typedef itk::NumericSeriesFileNames NamesGeneratorType;
+                                NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();
+                                namesGenerator->SetStartIndex(0);
+                                namesGenerator->SetEndIndex(dims_size[3]-1);
+                                namesGenerator->SetIncrementIndex(1);
+                                std::string format = i_dir;
+                            format += "/image%03d.vtk";
+                                namesGenerator->SetSeriesFormat( format.c_str() );
+      
+                                seriesWriter->SetFileNames( namesGenerator->GetFileNames() );
+                       
+                                try
+                               {
+                                       seriesWriter->Update();
+                                       vtkImageReader2 *vReader =vtkImageReader2::New();
+                                       for(unsigned int i = 0 ;i < dims_size[3]; i++)
+                                       {
+                                               vReader->SetFileName(namesGenerator->GetFileNames()[i].c_str());
+                                               vReader->Update();
+                                               m_Vresults.push_back(vReader->GetOutput());
+                                       }
+                               }
+                               catch( itk::ExceptionObject & excp )
+                               {
+                                       std::cerr << "Exception thrown while writing the series " << std::endl;
+                                       std::cerr << excp << std::endl;
+                                       //return EXIT_FAILURE;
+                               }
+                               
+                 }
+
+         }
+
+ }// namespace end
+
diff --git a/src/creaImageIOWxIsimpleDlg.h b/src/creaImageIOWxIsimpleDlg.h
new file mode 100644 (file)
index 0000000..6527b01
--- /dev/null
@@ -0,0 +1,64 @@
+#include "creaImageIOSimpleView.h"
+#include <creaWx.h>
+#include <itkImageFileReader.h>
+
+namespace creaImageIO
+{
+ /**
+   * \ingroup View
+   */
+
+       /// Simple Wxwidgets interface to select file(s) or directory or from creaImageIO database to display
+       template <typename TImage> 
+       class  __declspec(dllexport) WxISimpleDlg : public wxDialog
+       {
+       public:
+                /// Ctor
+                 WxISimpleDlg( wxWindow *parent,  
+                         wxString i_title =_T(""),
+                         const std::string i_namedescp = "localdatabase_Descriptor.dscp",   
+                         const std::string i_namedb   = "Local Database"     
+                         );
+
+                 ~WxISimpleDlg(){};
+
+                 void setExts(std::vector<std::string>);
+                 /// Callback to read file(s)
+                 void OnReadFile(wxCommandEvent& event);
+
+                 /// Callback to read directory, no recursive
+                  void OnReadDirectory(wxCommandEvent &event);
+             
+                 /// Callback to select from creaImageIO database
+                  void OnReadGimmick(wxCommandEvent &event);
+
+                  /// return a vtkImageData vector of selected images, if available
+                  std::vector<vtkImageData*> getVtkImagesSelected() {return m_Vresults;}
+
+                       /// return a itkImage vector of selected images, if available
+                       std::vector<typename TImage::Pointer> getImagesSelected();
+               
+
+                  wxString getInfoImage();
+
+                  void split4Din3Dvtk(const std::string &i_dir);
+                  void split3Din3Dvtk();
+       private:
+
+               std::vector<std::string> m_exts;
+               std::string namedescp; 
+               std::string namedb;
+               wxString infoimage;
+
+               /// interface to read data
+               SimpleView m_view;
+                void readImg(const std::string &i_name);
+
+                std::vector <typename TImage::Pointer> m_Iresults;
+
+                std::vector <vtkImageData*> m_Vresults;
+
+       };
+
+
+}
index 43e2ac115639bd342fa4e15cadf30edea3fe5feb..afe11168d2d7b915a1d0375df93983512a83a75b 100644 (file)
@@ -1,9 +1,13 @@
 #include "creaImageIOWxSimpleDlg.h"
 #include "creaImageIOWxGimmickReaderDialog.h"
+//#include <itkAnalyzeImageIO.h>
+//#include <itkImageFileReader.h>
+//#include <itkImage.h>
 
 namespace creaImageIO
 {
 
+
        ///Ctor
    WxSimpleDlg::WxSimpleDlg(wxWindow *parent, 
                                                        wxString i_title,  
@@ -50,6 +54,9 @@ namespace creaImageIO
                                fileDlg->GetPaths(wxArray);
                                if(wxArray.size() >0)
                                {
+                               /*      typedef itk::Image< float, 4 >         ImageType;
+                                       ReadImage<ImageType>(crea::wx2std(wxArray[0]).c_str());*/
+
                                        infoimage=_T("FILE(s):")+wxArray[0];
                                        std::vector<std::string> files;
                                        for( int i = 0; i < wxArray.GetCount(); i++)
diff --git a/src/itkImageToVTKImageFilter.h b/src/itkImageToVTKImageFilter.h
new file mode 100644 (file)
index 0000000..145c840
--- /dev/null
@@ -0,0 +1,134 @@
+/*=========================================================================
+
+  Program:   Insight Segmentation & Registration Toolkit
+  Module:    $RCSfile: itkImageToVTKImageFilter.h,v $
+  Language:  C++
+  Date:      $Date: 2011/04/27 19:12:20 $
+  Version:   $Revision: 1.1 $
+
+  Copyright (c) 2002 Insight Consortium. All rights reserved.
+  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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.
+
+=========================================================================*/
+#ifndef __itkImageToVTKImageFilter_h
+#define __itkImageToVTKImageFilter_h
+
+#include "itkVTKImageExport.h"
+#include "vtkImageImport.h"
+#include "vtkImageData.h"
+#include <vector>
+
+namespace itk
+{
+  
+/** \class ImageToVTKImageFilter
+ * \brief Converts an ITK image into a VTK image and plugs a 
+ *  itk data pipeline to a VTK datapipeline.   
+ *
+ *  This class puts together an itkVTKImageExporter and a vtkImageImporter.
+ *  It takes care of the details related to the connection of ITK and VTK
+ *  pipelines. The User will perceive this filter as an adaptor to which
+ *  an itk::Image can be plugged as input and a vtkImage is produced as 
+ *  output.
+ * 
+ * \ingroup   ImageFilters     
+ */
+template <class TInputImage >
+class ITK_EXPORT ImageToVTKImageFilter : public ProcessObject
+{
+public:
+  /** Standard class typedefs. */
+  typedef ImageToVTKImageFilter       Self;
+  typedef ProcessObject             Superclass;
+  typedef SmartPointer<Self>        Pointer;
+  typedef SmartPointer<const Self>  ConstPointer;
+
+  /** Method for creation through the object factory. */
+  itkNewMacro(Self);
+  
+  /** Run-time type information (and related methods). */
+  itkTypeMacro(ImageToVTKImageFilter, ProcessObject);
+
+  /** Some typedefs. */
+  typedef TInputImage InputImageType;
+  typedef typename    InputImageType::ConstPointer    InputImagePointer;
+  typedef VTKImageExport< InputImageType>            ExporterFilterType; 
+  typedef typename ExporterFilterType::Pointer        ExporterFilterPointer;
+  /** Get the output in the form of a vtkImage. 
+      This call is delegated to the internal vtkImageImporter filter  */
+  vtkImageData *  GetOutput() const;
+
+  /** Set the input in the form of an itk::Image */
+  void SetInput( const InputImageType * );
+
+  /** Return the internal VTK image importer filter.
+      This is intended to facilitate users the access 
+      to methods in the importer */
+  vtkImageImport * GetImporter() const;
+
+  /** Return the internal ITK image exporter filter.
+      This is intended to facilitate users the access 
+      to methods in the exporter */
+  ExporterFilterType * GetExporter() const;
+  
+  /** This call delegate the update to the importer */
+  void Update();
+  
+   const std::vector<double>& getvtest() const
+     {
+  return m_vtest;
+     }
+
+   int testsize() 
+     {
+  return m_vtest.size();
+     }
+  
+   std::vector<double> addvector(const std::vector<double>& v) {
+          for (unsigned int i=0; i<v.size(); i++)
+          m_vtest.push_back(v[i]);
+          return m_vtest;
+      }
+   
+   const std::vector<double>& addtest(double toto)
+          {
+       m_vtest.push_back(toto);
+               return m_vtest;
+            }
+   std::vector<double> tralala()
+     {
+  std::vector<double> w;
+      for (double i=0; i<10; i++)
+            w.push_back(i);
+      return w;
+  
+     }
+   
+protected:
+  ImageToVTKImageFilter(); 
+  virtual ~ImageToVTKImageFilter(); 
+
+private:
+  ImageToVTKImageFilter(const Self&); //purposely not implemented
+  void operator=(const Self&); //purposely not implemented
+
+  ExporterFilterPointer       m_Exporter;
+  vtkImageImport            * m_Importer;
+   std::vector<double> m_vtest;
+};
+
+} // end namespace itk
+
+#ifndef ITK_MANUAL_INSTANTIATION
+#include "itkImageToVTKImageFilter.txx"
+#endif
+
+#endif
+
+
+
diff --git a/src/itkImageToVTKImageFilter.txx b/src/itkImageToVTKImageFilter.txx
new file mode 100644 (file)
index 0000000..c74c9cf
--- /dev/null
@@ -0,0 +1,144 @@
+/*=========================================================================
+
+  Program:   Insight Segmentation & Registration Toolkit
+  Module:    $RCSfile: itkImageToVTKImageFilter.txx,v $
+  Language:  C++
+  Date:      $Date: 2011/04/27 19:12:20 $
+  Version:   $Revision: 1.1 $
+
+  Copyright (c) 2002 Insight Consortium. All rights reserved.
+  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm 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.
+
+=========================================================================*/
+#ifndef _itkImageToVTKImageFilter_txx
+#define _itkImageToVTKImageFilter_txx
+
+#include "itkImageToVTKImageFilter.h"
+
+namespace itk
+{
+
+
+
+/**
+ * Constructor
+ */
+template <class TInputImage>
+ImageToVTKImageFilter<TInputImage>
+::ImageToVTKImageFilter()
+{
+
+  m_Importer = vtkImageImport::New();
+
+  m_Exporter = ExporterFilterType::New();
+
+  m_Importer->SetUpdateInformationCallback(m_Exporter->GetUpdateInformationCallback());
+  m_Importer->SetPipelineModifiedCallback(m_Exporter->GetPipelineModifiedCallback());
+  m_Importer->SetWholeExtentCallback(m_Exporter->GetWholeExtentCallback());
+  m_Importer->SetSpacingCallback(m_Exporter->GetSpacingCallback());
+  m_Importer->SetOriginCallback(m_Exporter->GetOriginCallback());
+  m_Importer->SetScalarTypeCallback(m_Exporter->GetScalarTypeCallback());
+  m_Importer->SetNumberOfComponentsCallback(m_Exporter->GetNumberOfComponentsCallback());
+  m_Importer->SetPropagateUpdateExtentCallback(m_Exporter->GetPropagateUpdateExtentCallback());
+  m_Importer->SetUpdateDataCallback(m_Exporter->GetUpdateDataCallback());
+  m_Importer->SetDataExtentCallback(m_Exporter->GetDataExtentCallback());
+  m_Importer->SetBufferPointerCallback(m_Exporter->GetBufferPointerCallback());
+  m_Importer->SetCallbackUserData(m_Exporter->GetCallbackUserData());
+
+}
+
+
+
+
+/**
+ * Destructor
+ */
+template <class TInputImage>
+ImageToVTKImageFilter<TInputImage>
+::~ImageToVTKImageFilter()
+{
+  if( m_Importer )
+    {
+    m_Importer->Delete();
+    m_Importer = 0;
+    }
+}
+
+
+
+/**
+ * Set an itk::Image as input 
+ */
+template <class TInputImage>
+void
+ImageToVTKImageFilter<TInputImage>
+::SetInput( const InputImageType * inputImage )
+{
+  m_Exporter->SetInput( inputImage );
+}
+
+
+
+/**
+ * Get a vtkImage as output
+ */
+template <class TInputImage>
+vtkImageData *
+ImageToVTKImageFilter<TInputImage>
+::GetOutput() const
+{
+  return m_Importer->GetOutput();
+}
+
+
+
+
+/**
+ * Get the importer filter
+ */
+template <class TInputImage>
+vtkImageImport *
+ImageToVTKImageFilter<TInputImage>
+::GetImporter() const
+{
+  return m_Importer;
+}
+
+
+
+/**
+ * Get the exporter filter
+ */
+template <class TInputImage>
+typename ImageToVTKImageFilter<TInputImage>::ExporterFilterType *
+ImageToVTKImageFilter<TInputImage>
+::GetExporter() const
+{
+  return m_Exporter.GetPointer();
+}
+
+
+
+/**
+ * Delegate the Update to the importer
+ */
+template <class TInputImage>
+void
+ImageToVTKImageFilter<TInputImage>
+::Update()
+{
+  m_Importer->Update();
+}
+
+
+
+
+
+} // end namespace itk
+
+#endif
+