本文整理汇总了C++中readertype::Pointer::GetMetaDataDictionary方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::GetMetaDataDictionary方法的具体用法?C++ Pointer::GetMetaDataDictionary怎么用?C++ Pointer::GetMetaDataDictionary使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类readertype::Pointer
的用法示例。
在下文中一共展示了Pointer::GetMetaDataDictionary方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main( int argc, char *argv[] )
{
string input_name;
string output_dir;
if (argc == 3) {
input_name = argv[1];
output_dir = argv[2];
}
const unsigned int Dimension = 3;
const unsigned int OutDimension = 2;
typedef short InputPixelType;
typedef int FilterPixelType;
typedef itk::Image< InputPixelType, Dimension > InputImageType;
typedef itk::Image< FilterPixelType, Dimension > FilterImageType;
typedef itk::Image< FilterPixelType, OutDimension > OutFilterImageType;
InputImageType::Pointer image;
itk::MetaDataDictionary dict;
if (input_name.size() && output_dir.size())
{
if (boost::filesystem::is_regular_file( input_name )) {
typedef itk::ImageFileReader< InputImageType > ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( input_name );
try
{
reader->Update();
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ERROR: ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
image = reader->GetOutput();
dict = reader->GetMetaDataDictionary();
} else if (boost::filesystem::is_directory( input_name )) {
itkBasic::SeriesReader sreader( input_name );
sreader.readSeriesData( 2 );
try
{
itkBasic::ReaderType::Pointer imageReader = itkBasic::ReaderType::New();
itkBasic::FileNamesContainer fc;
sreader.getSeriesFileNames(0, fc);
image = itkBasic::getDicomSerie( fc, imageReader, 1 );
dict = *((*imageReader->GetMetaDataDictionaryArray())[0]);
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ERROR: ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
}
}
if (!image) {
std::cerr << argv[0] << ": input output" << std::endl;
exit(1);
}
typedef itk::SigmoidImageFilter< InputImageType, FilterImageType > SigmoidCasterType;
SigmoidCasterType::Pointer sigmoidcaster = SigmoidCasterType::New();
sigmoidcaster->SetInput( image );
sigmoidcaster->SetOutputMaximum( 4000 );
sigmoidcaster->SetOutputMinimum( 1000 );
typedef itk::AccumulateImageFilter< FilterImageType, FilterImageType > AccumulateFilter;
AccumulateFilter::Pointer accumulator = AccumulateFilter::New();
accumulator->SetAccumulateDimension(1);
accumulator->SetInput( sigmoidcaster->GetOutput() );
typedef itk::ExtractImageFilter< FilterImageType, OutFilterImageType > ExtractFilter;
ExtractFilter::Pointer extractor = ExtractFilter::New();
extractor->SetInput( accumulator->GetOutput() );
FilterImageType::Pointer accuOut = accumulator->GetOutput();
accuOut->UpdateOutputInformation();
FilterImageType::RegionType extractRegion = accuOut->GetLargestPossibleRegion();
extractRegion.SetSize(1,0);
extractor->SetExtractionRegion( extractRegion );
typedef itk::ResampleImageFilter<OutFilterImageType, OutFilterImageType > ResampleFilter;
ResampleFilter::Pointer resampler = ResampleFilter::New();
resampler->SetInput( extractor->GetOutput() );
typedef itk::BSplineInterpolateImageFunction< OutFilterImageType > InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
interpolator->SetSplineOrder(3);
resampler->SetInterpolator( interpolator );
OutFilterImageType::Pointer exOut = extractor->GetOutput();
exOut->UpdateOutputInformation();
//.........这里部分代码省略.........
示例2: exec
void DicomSelectorDialog::exec() {
typedef itk::ImageFileReader< CTImageType > ReaderType;
int index = 0; bool canceled = false;
QProgressDialog indexProgress(tr("Indexing Files..."), tr("Abort"), 0, m_fileNames.size(), this);
indexProgress.setMinimumDuration(1000);
indexProgress.setWindowModality(Qt::ApplicationModal);
while( index < m_fileNames.size() ) {
indexProgress.setValue(index + 1);
if (indexProgress.wasCanceled()) break;
if ( boost::filesystem::is_directory( m_fileNames[index].toAscii().data() ) )
{
boost::filesystem::path fpath( m_fileNames.takeAt(index).toAscii().data() );
QList< boost::filesystem::path > pathList;
boost::filesystem::directory_iterator end_itr; // default construction yields past-the-end
pathList.push_back( fpath );
indexProgress.setMaximum(m_fileNames.size() + pathList.size());
while( !pathList.isEmpty() ) {
if (indexProgress.wasCanceled()) break;
boost::filesystem::path currentPath = pathList.takeFirst();
for ( boost::filesystem::directory_iterator itr( currentPath ); itr != end_itr; ++itr )
{
if (indexProgress.wasCanceled()) break;
if ( boost::filesystem::is_directory(itr->status()) )
{
pathList.push_back( itr->path() );
indexProgress.setMaximum(m_fileNames.size() + pathList.size());
indexProgress.setValue(index);
}
else if ( boost::filesystem::is_regular_file( itr->status() ))
{
m_fileNames.push_back( itr->path().directory_string().c_str() );
}
}
}
} else {
index++;
}
}
canceled = indexProgress.wasCanceled();
m_fileNames.removeDuplicates();
if (!canceled ) {
QProgressDialog metaReadProgress(tr("Reading MetaData..."), tr("Abort"), 0, m_fileNames.size(), this);
metaReadProgress.setMinimumDuration(1000);
metaReadProgress.setWindowModality(Qt::ApplicationModal);
for(int i = 0; i < m_fileNames.size(); i++) {
metaReadProgress.setValue(i);
if (metaReadProgress.wasCanceled())
break;
boost::filesystem::path fpath( m_fileNames[i].toAscii().data() );
if ( boost::filesystem::is_regular_file( fpath ) ) {
try {
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( fpath.string() );
reader->GenerateOutputInformation();
m_ctImageModel.appendFilename( reader->GetMetaDataDictionary(), fpath.string() );
} catch (itk::ImageFileReaderException &ifrExep) {
std::cerr << "Exception caught !" << std::endl;
std::cerr << ifrExep << std::endl;
} catch (itk::ExceptionObject & excep) {
std::cerr << "Exception caught !" << std::endl;
std::cerr << excep << std::endl;
}
}
}
}
if (m_ctImageModel.rowCount(QModelIndex())==0) return;
treeView->setModel( &m_ctImageModel );
treeView->selectAll();
for(unsigned int t=0; t < m_HeaderFields.size(); t++) treeView->resizeColumnToContents(t);
treeView->setSortingEnabled(true);
treeView->sortByColumn(2,Qt::AscendingOrder);
QDialog::exec();
}