本文整理汇总了C++中writertype::Pointer::UseInputMetaDataDictionaryOn方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::UseInputMetaDataDictionaryOn方法的具体用法?C++ Pointer::UseInputMetaDataDictionaryOn怎么用?C++ Pointer::UseInputMetaDataDictionaryOn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类writertype::Pointer
的用法示例。
在下文中一共展示了Pointer::UseInputMetaDataDictionaryOn方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: localeSwitch
void mitk::DiffusionImageNrrdWriterService::Write()
{
mitk::Image::ConstPointer input = dynamic_cast<const mitk::Image *>(this->GetInput());
VectorImageType::Pointer itkImg;
mitk::CastToItkImage(input,itkImg);
if (input.IsNull())
{
MITK_ERROR <<"Sorry, input to DiffusionImageNrrdWriterService is NULL!";
return;
}
if ( this->GetOutputLocation().empty() )
{
MITK_ERROR << "Sorry, filename has not been set!";
return ;
}
mitk::LocaleSwitch localeSwitch("C");
char keybuffer[512];
char valbuffer[512];
//itk::MetaDataDictionary dic = input->GetImage()->GetMetaDataDictionary();
vnl_matrix_fixed<double,3,3> measurementFrame = mitk::DiffusionPropertyHelper::GetMeasurementFrame(input);
if (measurementFrame(0,0) || measurementFrame(0,1) || measurementFrame(0,2) ||
measurementFrame(1,0) || measurementFrame(1,1) || measurementFrame(1,2) ||
measurementFrame(2,0) || measurementFrame(2,1) || measurementFrame(2,2))
{
sprintf( valbuffer, " (%lf,%lf,%lf) (%lf,%lf,%lf) (%lf,%lf,%lf)", measurementFrame(0,0), measurementFrame(0,1), measurementFrame(0,2), measurementFrame(1,0), measurementFrame(1,1), measurementFrame(1,2), measurementFrame(2,0), measurementFrame(2,1), measurementFrame(2,2));
itk::EncapsulateMetaData<std::string>(itkImg->GetMetaDataDictionary(),std::string("measurement frame"),std::string(valbuffer));
}
sprintf( valbuffer, "DWMRI");
itk::EncapsulateMetaData<std::string>(itkImg->GetMetaDataDictionary(),std::string("modality"),std::string(valbuffer));
if(mitk::DiffusionPropertyHelper::GetGradientContainer(input)->Size())
{
sprintf( valbuffer, "%1f", mitk::DiffusionPropertyHelper::GetReferenceBValue(input) );
itk::EncapsulateMetaData<std::string>(itkImg->GetMetaDataDictionary(),std::string("DWMRI_b-value"),std::string(valbuffer));
}
for(unsigned int i=0; i<mitk::DiffusionPropertyHelper::GetGradientContainer(input)->Size(); i++)
{
sprintf( keybuffer, "DWMRI_gradient_%04d", i );
/*if(itk::ExposeMetaData<std::string>(input->GetMetaDataDictionary(),
std::string(keybuffer),tmp))
continue;*/
sprintf( valbuffer, "%1f %1f %1f", mitk::DiffusionPropertyHelper::GetGradientContainer(input)->ElementAt(i).get(0),
mitk::DiffusionPropertyHelper::GetGradientContainer(input)->ElementAt(i).get(1), mitk::DiffusionPropertyHelper::GetGradientContainer(input)->ElementAt(i).get(2));
itk::EncapsulateMetaData<std::string>(itkImg->GetMetaDataDictionary(),std::string(keybuffer),std::string(valbuffer));
}
typedef itk::VectorImage<short,3> ImageType;
std::string ext = this->GetMimeType()->GetExtension(this->GetOutputLocation());
ext = itksys::SystemTools::LowerCase(ext);
// default extension is .dwi
if( ext == "")
{
ext = ".nrrd";
this->SetOutputLocation(this->GetOutputLocation() + ext);
}
if (ext == ".hdwi" || ext == ".nrrd" || ext == ".dwi")
{
MITK_INFO << "Extension " << ext;
itk::NrrdImageIO::Pointer io = itk::NrrdImageIO::New();
//io->SetNrrdVectorType( nrrdKindList );
io->SetFileType( itk::ImageIOBase::Binary );
io->UseCompressionOn();
typedef itk::ImageFileWriter<ImageType> WriterType;
WriterType::Pointer nrrdWriter = WriterType::New();
nrrdWriter->UseInputMetaDataDictionaryOn();
nrrdWriter->SetInput( itkImg );
nrrdWriter->SetImageIO(io);
nrrdWriter->SetFileName(this->GetOutputLocation());
nrrdWriter->UseCompressionOn();
nrrdWriter->SetImageIO(io);
try
{
nrrdWriter->Update();
}
catch (itk::ExceptionObject e)
{
std::cout << e << std::endl;
throw;
}
}
}