1 // =========================================================================
2 // @author Leonardo Florez Valencia (florez-l@javeriana.edu.co)
3 // =========================================================================
4 #ifndef __CTBronchi__Image__hxx__
5 #define __CTBronchi__Image__hxx__
7 #include <itkImageFileReader.h>
8 #include <itkImageFileWriter.h>
10 // -------------------------------------------------------------------------
11 template< class _TPixel, unsigned int _VDim >
12 CTBronchi::Image< _TPixel, _VDim >::
17 // -------------------------------------------------------------------------
18 template< class _TPixel, unsigned int _VDim >
19 CTBronchi::Image< _TPixel, _VDim >::
24 // -------------------------------------------------------------------------
25 template< class _TPixel, unsigned int _VDim >
26 bool CTBronchi::Image< _TPixel, _VDim >::
29 return( this->m_Image.IsNotNull( ) );
32 // -------------------------------------------------------------------------
33 template< class _TPixel, unsigned int _VDim >
34 bool CTBronchi::Image< _TPixel, _VDim >::
37 return( this->m_Image.IsNull( ) );
40 // -------------------------------------------------------------------------
41 template< class _TPixel, unsigned int _VDim >
42 typename CTBronchi::Image< _TPixel, _VDim >::
43 TImage* CTBronchi::Image< _TPixel, _VDim >::
46 return( this->m_Image.GetPointer( ) );
49 // -------------------------------------------------------------------------
50 template< class _TPixel, unsigned int _VDim >
51 const typename CTBronchi::Image< _TPixel, _VDim >::
52 TImage* CTBronchi::Image< _TPixel, _VDim >::
55 return( this->m_Image.GetPointer( ) );
58 // -------------------------------------------------------------------------
59 template< class _TPixel, unsigned int _VDim >
60 void CTBronchi::Image< _TPixel, _VDim >::
63 this->m_Image = image;
64 this->m_Image->DisconnectPipeline( );
67 // -------------------------------------------------------------------------
68 template< class _TPixel, unsigned int _VDim >
69 void CTBronchi::Image< _TPixel, _VDim >::
70 Set( const TImage::Pointer& image )
72 this->m_Image = image.GetPointer( );
73 this->m_Image->DisconnectPipeline( );
76 // -------------------------------------------------------------------------
77 template< class _TPixel, unsigned int _VDim >
78 void CTBronchi::Image< _TPixel, _VDim >::
79 Load( const std::string& fname )
81 typedef itk::ImageFileReader< TImage > _TReader;
82 typename _TReader::Pointer r = _TReader::New( );
83 r->SetFileName( fname );
87 this->Set( r->GetOutput( ) );
96 // -------------------------------------------------------------------------
97 template< class _TPixel, unsigned int _VDim >
98 void CTBronchi::Image< _TPixel, _VDim >::
99 Save( const std::string& fname )
101 typedef itk::ImageFileWriter< TImage > _TWriter;
103 if( this->IsNotNull( ) )
105 typename _TWriter::Pointer w = _TWriter::New( );
106 w->SetFileName( fname );
107 w->SetInput( this->m_Image );
117 #endif // __CTBronchi__Image__hxx__