Exemple #1
0
// a helper function for minc writing
template <class T> void save_minc(const char *file,typename T::ConstPointer img)
{
  typedef itk::MincImageIO ImageIOType;
  ImageIOType::Pointer minc2ImageIO = ImageIOType::New();
     
  typename itk::ImageFileWriter< T >::Pointer writer = itk::ImageFileWriter<T>::New();
  writer->SetFileName(file);
  writer->SetImageIO( minc2ImageIO );
  writer->SetInput( img );
  writer->Update();
}
Exemple #2
0
bool itkDataImageWriterBase::write_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 Image::Pointer image = dynamic_cast<Image*>((itk::Object*)(this->data()->output()));
    if (image.IsNull())
        return false;
    if (medData->hasMetaData(medAbstractImageData::PixelMeaningMetaData)) {
        itk::MetaDataDictionary& dict = image->GetMetaDataDictionary();
        itk::EncapsulateMetaData(dict,"intent_name",medData->metadata(medAbstractImageData::PixelMeaningMetaData));
    }
    typename itk::ImageFileWriter<Image>::Pointer writer = itk::ImageFileWriter <Image>::New();
    writer->SetImageIO (this->io);
    writer->UseCompressionOn();
    writer->SetFileName(path.toLatin1().constData());
    writer->SetInput(image);
    writer->Update();

    return true;
}