void ReadImage(medAbstractData* medData,itk::DCMTKImageIO::Pointer io,const QStringList& paths) { typename itk::ImageFileReader<itk::Image<TYPE,DIM> >::Pointer Reader = itk::ImageFileReader<itk::Image<TYPE,DIM> >::New(); Reader->SetImageIO(io); Reader->SetFileName(paths[0].toAscii().constData()); medData->setData(Reader->GetOutput()); Reader->Update(); }
bool itkDataImageReaderBase::read_image(const QString& path,const char* type) { medAbstractData* medData = dynamic_cast<medAbstractData*>(this->data()); if (medData && medData->identifier()!=type) return false; typedef itk::Image<T,DIM> Image; typename itk::ImageFileReader<Image>::Pointer TReader = itk::ImageFileReader<Image>::New(); TReader->SetImageIO(this->io); TReader->SetFileName(path.toAscii().constData()); TReader->SetUseStreaming(true); typename Image::Pointer im = TReader->GetOutput(); medData->setData(im); // Recover the pixel meaning from the intent_name. const itk::MetaDataDictionary dict = im->GetMetaDataDictionary(); std::string PixMeaning; if (itk::ExposeMetaData(dict,"intent_name",PixMeaning)) medData->addMetaData(medAbstractImageData::PixelMeaningMetaData,QString(PixMeaning.c_str())); TReader->Update(); return true; }
// a helper function for minc reading template <class T> typename T::Pointer load_minc(const char *file) { typedef itk::MincImageIO ImageIOType; ImageIOType::Pointer minc2ImageIO = ImageIOType::New(); typename itk::ImageFileReader<T>::Pointer reader = itk::ImageFileReader<T>::New(); reader->SetFileName(file); reader->SetImageIO( minc2ImageIO ); reader->Update(); return reader->GetOutput(); }