]> Creatis software - clitk.git/commitdiff
Add CheckImage
authorDavid Sarrut <david.sarrut@gmail.com>
Thu, 14 Jun 2012 13:35:53 +0000 (15:35 +0200)
committerDavid Sarrut <david.sarrut@gmail.com>
Thu, 14 Jun 2012 13:35:53 +0000 (15:35 +0200)
segmentation/clitkAnatomicalFeatureDatabase.txx

index c155d44084c2581a6940e03069fee49f7bc9de03..72e9dcdd06b9293742aa70dac935eb9d58ff4421 100644 (file)
@@ -47,6 +47,39 @@ GetImage(std::string tag, bool reload)
 //--------------------------------------------------------------------
 
 
+//--------------------------------------------------------------------
+template<class ImageType>
+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<ImageType *>(m_MapOfImage[tag]);
+    }
+    else {
+      std::string s = m_MapOfTag[tag];
+      // Read the file
+      std::string n = GetPath()+"/"+s;
+      //      image = readImage<ImageType>();
+      typedef itk::ImageFileReader<ImageType> ReaderType;
+      typename ReaderType::Pointer reader = ReaderType::New();
+      reader->SetFileName(n.c_str());
+      try {
+        reader->Update();
+      } catch(itk::ExceptionObject & err) {
+        return false;
+      }
+    }
+  }
+  return true;
+}
+//--------------------------------------------------------------------
+
+
 //--------------------------------------------------------------------
 template<class ImageType>
 void AnatomicalFeatureDatabase::