Search code examples
c++vtkdicom

How to read ImageType (0008,0008) in VTK DICOM Reader?


I have an application on hands sitting on top of VTK 5.3. Using vtkDICOMImageReader I'm getting image position, width, height, ..., so far so good.

But is there a good way to read ImageType string with tag (0008,0008)?

More general, could I read any tag back using vtkDICOMImageReader? Pass tag value, get back what's in the DICOM file?


Solution

  • #include "gdcmReader.h"
    #include "gdcmMediaStorage.h"
    
    int main(int argc, char *argv [])
    {
      if( argc < 2 ) return 1;
      const char *filename = argv[1];
    
      gdcm::Reader reader;
      reader.SetFileName( filename);
      if( !reader.Read() )
        {
        std::cerr << "Could not read: " << filename << std::endl;
        return 1;
        }
      std::stringstream strm;
    
      gdcm::File &file = reader.GetFile();
      gdcm::DataSet &ds = file.GetDataSet();
      gdcm::FileMetaInformation &fmi = file.GetHeader();
    
      ConstIterator it = ds.GetDES().begin();
    
      for( ; it != ds.GetDES().end(); ++it){
          if (it->GetTag()==gdcm::Tag (0x0008, 0x0008)){
          std:cout << it;
      }