Hi guys,<br><br>I am just wondering if is there any disadvantage in using the following function to encapsulate the image file reading.<br><br>Thank you,<br>Ricardo<br><br><br>/// ************************************************************************************************************<br>
///<br>/// ************************************************************************************************************<br>template< typename TImageType ><br>typename TImageType::Pointer ReadImage( const std::string fileName )<br>
{<br> typedef itk::ImageFileReader< TImageType > ImageFileReader;<br> typename ImageFileReader::Pointer reader = ImageFileReader::New();<br> reader->SetFileName( fileName );<br><br> try<br> {<br>
reader->Update();<br> }<br> catch (... )<br> {<br> std::cout << "Error while reading in image" << fileName << std::endl;<br> throw;<br> }<br><br> return reader->GetOutput();<br>
}<br><br><br>The function is used as follows:<br><br>InputImageType::Pointer img = ReadImage< InputImageType >( inputFileName );<br>