X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=appli%2FCTBronchi%2FFunctions.h;fp=appli%2FCTBronchi%2FFunctions.h;h=272c974f81162e429a8fba9e6ac3ac3b226fbabf;hb=b69a5d04d117c1fdd297999c4fb034db54911aca;hp=0000000000000000000000000000000000000000;hpb=594f8102342948c80175e6829e0134df63245106;p=FrontAlgorithms.git diff --git a/appli/CTBronchi/Functions.h b/appli/CTBronchi/Functions.h new file mode 100644 index 0000000..272c974 --- /dev/null +++ b/appli/CTBronchi/Functions.h @@ -0,0 +1,57 @@ +// ========================================================================= +// @author Leonardo Florez Valencia +// @email florez-l@javeriana.edu.co +// ========================================================================= +#ifndef __CTBronchi__Functions__h__ +#define __CTBronchi__Functions__h__ + +#include +#include +#include + +namespace CTBronchi +{ + // ----------------------------------------------------------------------- + double MeasureTime( itk::ProcessObject* f ) + { + std::chrono::time_point< std::chrono::high_resolution_clock > s, e; + std::chrono::duration< double > t; + s = std::chrono::high_resolution_clock::now( ); + f->Update( ); + e = std::chrono::high_resolution_clock::now( ); + t = e - s; + return( t.count( ) ); + } + + // ----------------------------------------------------------------------- + template< class _TImagePtr > + void ReadImage( _TImagePtr& image, const std::string& fname ) + { + typedef typename _TImagePtr::ObjectType _TImage; + typedef itk::ImageFileReader< _TImage > _TReader; + typename _TReader::Pointer reader = _TReader::New( ); + reader->SetFileName( fname ); + double t = MeasureTime( reader ); + std::cout << "Read " << fname << " in " << t << " s" << std::endl; + image = reader->GetOutput( ); + image->DisconnectPipeline( ); + } + + // ----------------------------------------------------------------------- + template< class _TImagePtr > + void WriteImage( const _TImagePtr& image, const std::string& fname ) + { + typedef typename _TImagePtr::ObjectType _TImage; + typedef itk::ImageFileWriter< _TImage > _TWriter; + typename _TWriter::Pointer writer = _TWriter::New( ); + writer->SetFileName( fname ); + writer->SetInput( image ); + double t = MeasureTime( writer ); + std::cout << "Wrote " << fname << " in " << t << " s" << std::endl; + } + +} // ecapseman + +#endif // __CTBronchi__Functions__h__ + +// eof - $RCSfile$