本文整理汇总了C++中writertype::Pointer::UseCompressionOn方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::UseCompressionOn方法的具体用法?C++ Pointer::UseCompressionOn怎么用?C++ Pointer::UseCompressionOn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类writertype::Pointer
的用法示例。
在下文中一共展示了Pointer::UseCompressionOn方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
string outFileName;
seriesItr = seriesUID.begin();
while (seriesItr != seriesUID.end())
{
string seriesIdentifier;
if (writeAllSeries) //without -k option
{
seriesIdentifier = seriesItr->c_str();
}
else //with -k option
{
//get sereisDescription according to seriesUID
string seriesDescription = seriesUidToOtherStuff[*seriesItr][5];
transform(seriesDescription.begin(), seriesDescription.end(), seriesDescription.begin(), tolower);//to lower case
//check if series Description contains the specified keyword (by -k)
for( int i = 0; i < seriesKeywords.size(); i++)
{
if (seriesDescription.find(seriesKeywords[i]) != string::npos)
{
seriesIdentifier = seriesItr->c_str();
}
}
}//end if (writeAllSeries)
if ( !seriesIdentifier.empty() )
{
//get file names belong to specific series
fileNames = nameGenerator->GetFileNames(seriesIdentifier);
reader->SetImageIO(dicomIO);
reader->SetFileNames(fileNames);
//get output file name:PatientID_StudyID_StudyDate_Access#_Series#_SeriesDescription
vector<string> vs = seriesUidToOtherStuff[seriesIdentifier];
string temp = vs[0]+"_"+vs[1]+"_"+vs[2]+"_"+vs[3]+"_"+vs[4]+"_"+vs[5];
string tempNew;
//remove illegal characters
for (string::iterator it = temp.begin(); it < temp.end(); ++it)
{
bool found = illegalChars.find(*it) != string::npos;
if(!found){
tempNew=tempNew+(*it);
}
}
//repace space with . . Many series descriptions come with spaces. But, filenames with spaces is not good.
replace( tempNew.begin(), tempNew.end(), ' ', '.');
//get full path file name
outFileName = outputDirectory + string(PATH_SEP) + tempNew + "."+outputFormat;
//write
writer->SetFileName(outFileName);
writer->UseCompressionOn();
writer->SetInput(reader->GetOutput());
cout << "Writing: " << outFileName << endl;
try
{
writer->Update();
}
catch (itk::ExceptionObject &ex)
{
cout << ex << std::endl;
continue;
}
//writing converted files full path to convertedList
if ( writeConvertedList )
{
try
{
convertedListFile << outFileName <<endl;
}
catch (std::ofstream::failure e)
{
cerr << "Exception writing file"<<endl;
}
}
}
seriesItr++;
}//end while
}//end if write3D
//close convertedList file
if (convertedListFile.is_open())
{
try
{
convertedListFile.close();
}
catch (std::ofstream::failure e)
{
cerr << "Exception closing file"<<endl;
}
}
//print elasped time
cout << "Elapsed time: "<<float( clock () - begin_time )/CLOCKS_PER_SEC<<" Seconds";
return 0;
}
示例2: 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;
}
}
}