From 0a19d346a86d286a63b37146e1c985f552243a5e Mon Sep 17 00:00:00 2001 From: David Sarrut Date: Thu, 14 Jun 2012 15:35:53 +0200 Subject: [PATCH] Add CheckImage --- .../clitkAnatomicalFeatureDatabase.txx | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) 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:: -- 2.47.1