From: David Sarrut Date: Thu, 14 Jun 2012 13:35:53 +0000 (+0200) Subject: Add CheckImage X-Git-Tag: v1.3.0~27^2~7 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=0a19d346a86d286a63b37146e1c985f552243a5e;p=clitk.git Add CheckImage --- diff --git a/segmentation/clitkAnatomicalFeatureDatabase.txx b/segmentation/clitkAnatomicalFeatureDatabase.txx index c155d44..72e9dcd 100644 --- a/segmentation/clitkAnatomicalFeatureDatabase.txx +++ b/segmentation/clitkAnatomicalFeatureDatabase.txx @@ -47,6 +47,39 @@ GetImage(std::string tag, bool reload) //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +template +bool AnatomicalFeatureDatabase:: +CheckImage(std::string tag) +{ + if (m_MapOfTag.find(tag) == m_MapOfTag.end()) { + return false; + } + else { + typename ImageType::Pointer image; + if (m_MapOfImage[tag]) { + image = static_cast(m_MapOfImage[tag]); + } + else { + std::string s = m_MapOfTag[tag]; + // Read the file + std::string n = GetPath()+"/"+s; + // image = readImage(); + typedef itk::ImageFileReader ReaderType; + typename ReaderType::Pointer reader = ReaderType::New(); + reader->SetFileName(n.c_str()); + try { + reader->Update(); + } catch(itk::ExceptionObject & err) { + return false; + } + } + } + return true; +} +//-------------------------------------------------------------------- + + //-------------------------------------------------------------------- template void AnatomicalFeatureDatabase::