1 // =========================================================================
2 // @author Leonardo Florez Valencia (florez-l@javeriana.edu.co)
3 // =========================================================================
4 #ifndef __CTBronchi__Image__hxx__
5 #define __CTBronchi__Image__hxx__
8 #include <itkImageFileReader.h>
9 #include <itkImageFileWriter.h>
11 // -------------------------------------------------------------------------
12 template< class _TPixel, unsigned int _VDim >
13 CTBronchi::Image< _TPixel, _VDim >::
18 // -------------------------------------------------------------------------
19 template< class _TPixel, unsigned int _VDim >
20 CTBronchi::Image< _TPixel, _VDim >::
25 // -------------------------------------------------------------------------
26 template< class _TPixel, unsigned int _VDim >
27 bool CTBronchi::Image< _TPixel, _VDim >::
30 return( this->m_Image.IsNotNull( ) );
33 // -------------------------------------------------------------------------
34 template< class _TPixel, unsigned int _VDim >
35 bool CTBronchi::Image< _TPixel, _VDim >::
38 return( this->m_Image.IsNull( ) );
41 // -------------------------------------------------------------------------
42 template< class _TPixel, unsigned int _VDim >
43 typename CTBronchi::Image< _TPixel, _VDim >::
44 TImage* CTBronchi::Image< _TPixel, _VDim >::
47 return( this->m_Image.GetPointer( ) );
50 // -------------------------------------------------------------------------
51 template< class _TPixel, unsigned int _VDim >
52 const typename CTBronchi::Image< _TPixel, _VDim >::
53 TImage* CTBronchi::Image< _TPixel, _VDim >::
56 return( this->m_Image.GetPointer( ) );
59 // -------------------------------------------------------------------------
60 template< class _TPixel, unsigned int _VDim >
61 void CTBronchi::Image< _TPixel, _VDim >::
64 this->m_Image = image;
65 if( this->m_Image.IsNotNull( ) )
66 this->m_Image->DisconnectPipeline( );
69 // -------------------------------------------------------------------------
70 template< class _TPixel, unsigned int _VDim >
71 void CTBronchi::Image< _TPixel, _VDim >::
72 Set( const typename TImage::Pointer& image )
74 this->m_Image = image.GetPointer( );
75 if( this->m_Image.IsNotNull( ) )
76 this->m_Image->DisconnectPipeline( );
79 // -------------------------------------------------------------------------
80 template< class _TPixel, unsigned int _VDim >
81 double CTBronchi::Image< _TPixel, _VDim >::
82 Load( const std::string& fname )
84 typedef CTBronchi::Filter< itk::ImageFileReader< TImage > > _TReader;
86 r.Get( )->SetFileName( fname );
89 double t = r.Update( );
90 this->Set( r.Get( )->GetOutput( ) );
101 // -------------------------------------------------------------------------
102 template< class _TPixel, unsigned int _VDim >
103 double CTBronchi::Image< _TPixel, _VDim >::
104 Save( const std::string& fname )
106 typedef CTBronchi::Filter< itk::ImageFileWriter< TImage > > _TWriter;
109 if( this->IsNotNull( ) )
112 w.Get( )->SetFileName( fname );
113 w.Get( )->UseCompressionOn( );
114 w.Get( )->SetInput( this->m_Image );
125 #endif // __CTBronchi__Image__hxx__