当前位置: 首页>>代码示例>>C++>>正文


C++ Pointer::SetFileNames方法代码示例

本文整理汇总了C++中readertype::Pointer::SetFileNames方法的典型用法代码示例。如果您正苦于以下问题:C++ Pointer::SetFileNames方法的具体用法?C++ Pointer::SetFileNames怎么用?C++ Pointer::SetFileNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在readertype::Pointer的用法示例。


在下文中一共展示了Pointer::SetFileNames方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: retrieveITKImage

//read CT image
void CTImageTreeItem::retrieveITKImage(QProgressDialog *progress, int progressScale, int progressBase) {
	//define and create file reader
	typedef ReaderProgress::ReaderType ReaderType;
	ReaderType::Pointer imageReader = ReaderType::New();
	ReaderType::FileNamesContainer fc;
	//assign filenames
	fc.assign(m_fnList.begin(), m_fnList.end());
	//set ImageIO and filenames
	itk::GDCMImageIO::Pointer gdcmImageIO = itk::GDCMImageIO::New();
	imageReader->SetImageIO( gdcmImageIO );
	imageReader->SetFileNames(fc);
	//create reader progress
	ReaderProgress::Pointer progressor = ReaderProgress::New();
	if (progress) 
	{
		progressor->setDialog( progress, progressScale, progressBase );
		imageReader->AddObserver(itk::AnyEvent(), progressor);
	}
	//try to read the images
	try {
		imageReader->Update();
	}catch( itk::ExceptionObject & excep ) {
		std::cerr << "Exception caught !" << std::endl;
		std::cerr << excep << std::endl;
	}
	//assign the reader output to an image pointer
	ImageType::Pointer imagePtr =  imageReader->GetOutput();
	setITKImage(imagePtr, 1);
	//emit signal, that data has changed
	m_model->dataChanged(m_model->createIndex(childNumber(),0,parent()),m_model->createIndex(childNumber(),columnCount()-1,parent()));
}
开发者ID:CardiacImagingCharite,项目名称:CardiacPerfusion,代码行数:32,代码来源:ctimagetreeitem.cpp

示例2: getImage

FilterImageType::Pointer getImage(const FileNamesContainer &filenames, DictionaryArray &dictArray) {
	typedef itk::ImageSeriesReader< FilterImageType > ReaderType;
	ReaderType::Pointer reader = ReaderType::New();
	ImageIOType::Pointer gdcmImageIO = ImageIOType::New();
	reader->SetImageIO( gdcmImageIO );
	reader->SetFileNames(filenames);
	reader->Update();
	ReaderType::DictionaryArrayRawPointer dict;

	dict = reader->GetMetaDataDictionaryArray();
	for( ReaderType::DictionaryArrayType::const_iterator it = dict->begin(); it != dict->end(); ++it) {
		dictArray.push_back( **it );
	}
	
	return reader->GetOutput();
}
开发者ID:hmeyer,项目名称:myLibs,代码行数:16,代码来源:itkbasics.cpp

示例3:

itk::Image<unsigned char, 3>::Pointer boner::Importer::import(std::string path)
{

    itk::Image<unsigned char, 3>::Pointer image;

    typedef itk::ImageSeriesReader<itk::Image<unsigned char, 3>> ReaderType;
    ReaderType::Pointer reader = ReaderType::New();
    itk::GDCMSeriesFileNames::Pointer namegenerator = itk::GDCMSeriesFileNames::New();
    namegenerator->SetInputDirectory(path);

    reader->SetImageIO(itk::GDCMImageIO::New());

    reader->SetFileNames(namegenerator->GetInputFileNames());
    image = reader->GetOutput();
    image->Update();

    return image;
}
开发者ID:raphimulator,项目名称:BoneR-Kit,代码行数:18,代码来源:Importer.cpp

示例4: main


//.........这里部分代码省略.........
		typedef itk::ImageFileWriter< ImageType > WriterType;
		WriterType::Pointer writer = WriterType::New();
		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;
				}
开发者ID:cgallego,项目名称:getBreastdata_section3,代码行数:67,代码来源:dcm23d.cpp

示例5: convert

void QtDcmConvert::convert()
{
    if (QtDcmPreferences::instance()->useDcm2nii())
    {
        QString program = QtDcmPreferences::instance()->getDcm2niiPath();
        QStringList arguments;
        arguments << "-x" << "N";
        arguments << "-r" << "N";
        arguments << "-g" << "N";
        arguments << "-o" << d->outputDirectory << d->inputDirectory;
        
        QProcess * process = new QProcess(this);
        process->setStandardOutputFile(d->tempDirectory + QDir::separator() + "logs" + QDir::separator() + d->serieUID + ".txt");
        process->start(program, arguments);
        process->waitForFinished();

        delete process;
    }
    else
    {
        typedef signed short                                PixelType;
        const unsigned int Dimension = 3;
        typedef itk::Image< PixelType, Dimension >          ImageType;
        typedef itk::ImageSeriesReader< ImageType >         ReaderType;
        typedef itk::ImageFileWriter<ImageType>             WriterType;
        typedef itk::GDCMImageIO                            ImageIOType;
        typedef itk::GDCMSeriesFileNames                    NamesGeneratorType;
        typedef std::vector< std::string >                  FileNamesContainer;
        typedef std::vector< std::string >                  SeriesIdContainer;

//     ImageType::Pointer image = 0;

        ReaderType::Pointer reader = ReaderType::New();
        ImageIOType::Pointer dicomIO = ImageIOType::New();

        NamesGeneratorType::Pointer inputNames = NamesGeneratorType::New();
        inputNames->SetUseSeriesDetails ( true );
        inputNames->AddSeriesRestriction ( "0008|0021" );
        inputNames->AddSeriesRestriction ( "0020,0037" );
        inputNames->LoadSequencesOn();
        inputNames->LoadPrivateTagsOn();
        inputNames->SetInputDirectory ( d->inputDirectory.toStdString() );
        try
        {
            const SeriesIdContainer & seriesUID = inputNames->GetSeriesUIDs();
            std::string seriesIdentifier = seriesUID.begin()->c_str();
            FileNamesContainer filenames = inputNames->GetFileNames ( seriesIdentifier );

            dicomIO->SetFileName ( filenames.begin()->c_str() );
            try
            {
                dicomIO->ReadImageInformation();
            }
            catch ( itk::ExceptionObject &e )
            {
                qDebug() << e.GetDescription();
                return;
            }

            reader->UseStreamingOn();
            reader->SetFileNames ( filenames );
            reader->SetImageIO ( dicomIO );

            try
            {
                reader->Update();
            }
            catch ( itk::ExceptionObject &excp )
            {
                std::cerr << excp << std::endl;
                return;
            }

//         IteratorType itOut;
//
//         image = reader->GetOutput();
//
//         RegionType region;
//         region.SetSize ( 0, image->GetLargestPossibleRegion().GetSize() [0] );
//         region.SetSize ( 1, image->GetLargestPossibleRegion().GetSize() [1] );
//         region.SetSize ( 2, image->GetLargestPossibleRegion().GetSize() [2] );
//         image->SetRegions ( region );
//         image->Allocate();
//         SpacingType spacing;
//         spacing[0] = image->GetSpacing() [0];
//         spacing[1] = image->GetSpacing() [1];
//         spacing[2] = image->GetSpacing() [2];
//         spacing[3] = 1;
//         image->SetSpacing ( spacing );
//         PointType origin;
//         origin[0] = image->GetOrigin() [0];
//         origin[1] = image->GetOrigin() [1];
//         origin[2] = image->GetOrigin() [2];
//         origin[3] = 0;
//         image->SetOrigin ( origin );
//         DirectionType direction;
//         for ( unsigned int i=0; i<4; i++ )
//             for ( unsigned int j=0; j<4; j++ )
//             {
//                 if ( ( i < 3 ) && ( j < 3 ) )
//.........这里部分代码省略.........
开发者ID:NicolasSchnitzler,项目名称:qtdcm,代码行数:101,代码来源:QtDcmConvert.cpp

示例6: main

int main() {


    typedef unsigned short    PixelType;
    const unsigned int      Dimension = 3;

    typedef itk::Image< PixelType, Dimension >         ImageType;

    typedef itk::VTKImageExport<ImageType> ImageExportType;
    typedef itk::ImageSeriesReader< ImageType >        ReaderType;
    ReaderType::Pointer reader = ReaderType::New();
    typedef itk::GDCMImageIO       ImageIOType;
    ImageIOType::Pointer dicomIO = ImageIOType::New();

    reader->SetImageIO( dicomIO );
    typedef itk::GDCMSeriesFileNames NamesGeneratorType;
    NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();

    nameGenerator->SetUseSeriesDetails( true );
    nameGenerator->AddSeriesRestriction("0008|0021" );
    nameGenerator->SetDirectory( "/Users/mac/BIOMED/Subjects/testSubject");

    typedef std::vector< std::string >    SeriesIdContainer;
    const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();
    std::cout << seriesUID.size() << std::endl;
    SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
    SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();
    while( seriesItr != seriesEnd )
    {
        std::cout << seriesItr->c_str() << std::endl;
        seriesItr++;
    }
    std::string seriesIdentifier;
    seriesIdentifier = seriesUID.begin()->c_str();
    std::cout << seriesIdentifier.c_str() << std::endl;

    typedef std::vector< std::string >   FileNamesContainer;
    FileNamesContainer fileNames;
    fileNames = nameGenerator->GetFileNames( seriesIdentifier );

    reader->SetFileNames( fileNames );
    try
    {
        reader->Update();
    }
    catch (itk::ExceptionObject &ex)
    {
        std::cout << ex << std::endl;
    }

//------------------------------------------------------------------------
// ITK to VTK pipeline connection.
//------------------------------------------------------------------------

// Create the itk::VTKImageExport instance and connect it to the
// itk::CurvatureFlowImageFilter.
    ImageExportType::Pointer exporter = ImageExportType::New();
    exporter->SetInput(reader->GetOutput());
    exporter->Update();

// Create the vtkImageImport and connect it to the
// itk::VTKImageExport instance.
    vtkImageImport* importer = vtkImageImport::New();
    ConnectPipelines(exporter, importer);

//------------------------------------------------------------------------
// VTK pipeline.
//------------------------------------------------------------------------


    //Demo Display DICOM Image
    /*
    string folder = "/Users/mac/BIOMED/Subjects/testSubject";
    // Read all the DICOM files in the specified directory.
    vtkSmartPointer<vtkDICOMImageReader> reader2 =
            vtkSmartPointer<vtkDICOMImageReader>::New();
    reader2->SetDirectoryName(folder.c_str());
    reader2->Update();
*/

    vtkSmartPointer<vtkImageSliceMapper> imageSliceMapper = vtkSmartPointer<vtkImageSliceMapper>::New();
    imageSliceMapper->SetInputConnection(importer->GetOutputPort());

    //imageSliceMapper->SetInputData(importer->GetOutput());
    imageSliceMapper->Update();


    vtkSmartPointer<vtkImageSlice> imageSlice = vtkSmartPointer<vtkImageSlice>::New();
    imageSlice->SetMapper(imageSliceMapper);



    vtkSmartPointer<vtkSmartVolumeMapper> volumeMapper =
            vtkSmartPointer<vtkSmartVolumeMapper>::New();
    volumeMapper->SetBlendModeToComposite();
    volumeMapper->SetInputConnection(importer->GetOutputPort());

    vtkSmartPointer<vtkVolumeProperty> volumeProperty =
            vtkSmartPointer<vtkVolumeProperty>::New();
    volumeProperty->ShadeOff();
//.........这里部分代码省略.........
开发者ID:TeamFireCSC621821,项目名称:testProject,代码行数:101,代码来源:main.cpp

示例7: main

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);


    // new for itk 4.8
    itk::JPEGImageIOFactory::RegisterOneFactory();

    // init
    m_pInvertIntensityFilter = InvertIntensityFilterType::New();
    m_pConnector = FilterType::New();


    //////////////////////////
    // vtk objects
    // QT/VTK interact
    m_pRenderer = vtkRenderer::New();
//    ui.vtkWidget->GetRenderWindow()->AddRenderer(m_pRenderer);
    m_pRenderWindow = vtkRenderWindow::New();
    m_pRenderWindow->AddRenderer(m_pRenderer);
    m_pRenderWindowInteractor = vtkRenderWindowInteractor::New();
    m_pRenderWindowInteractor->SetRenderWindow(m_pRenderWindow);

    m_pTissueExtractor = vtkMarchingCubes::New(); //vtkContourFilter::New();
    m_pTissueNormals = vtkPolyDataNormals::New();
    m_pTissueMapper = vtkPolyDataMapper::New();
    m_pTissue = vtkActor::New();
    m_pTextActor = vtkActor2D::New();
    m_pTextMapper = vtkTextMapper::New();

    // read a volume
    // QString strVolumeIndex;
    //strVolumeIndex.sprintf("../", nZoomOut,
    //										iWidth, iLength, iHeight);
    QString strSeriesFormat;
    strSeriesFormat = QString("K:/Projects/TestVol3/%04d.jpg");

    //qDebug() << strSeriesFormat;

    NameGeneratorType::Pointer pNameGenerator = NameGeneratorType::New();

    pNameGenerator->SetSeriesFormat(strSeriesFormat.toStdString());
    unsigned int nStartIndex = 1;
    pNameGenerator->SetStartIndex(nStartIndex); //0 );
    pNameGenerator->SetEndIndex(256);
    pNameGenerator->SetIncrementIndex( 2 );

    ///////////
    // optional
    //pReader->SetImageIO(itk::JPEGImageIO::New());

    ReaderType::Pointer pReader = ReaderType::New();
    pReader->SetFileNames(pNameGenerator->GetFileNames());

    try
    {
        pReader->Update();
    }
    catch (itk::ExceptionObject & err )
    {
        std::cerr << "ExceptionObject caught !" << std::endl;
        std::cerr << err << std::endl;
        return EXIT_FAILURE;
    }

    m_pImageData = pReader->GetOutput();
//    m_pImageData->DisconnectPipeline();

    // execute pipeline
    m_pInvertIntensityFilter->SetInput(m_pImageData);
    m_pConnector->SetInput(m_pInvertIntensityFilter->GetOutput()); //m_pReader->GetOutput());
#if VTK_MAJOR_VERSION <= 5
    m_pTissueExtractor->SetInput(m_pConnector->GetOutput());
#else
    m_pConnector->Update();
    m_pTissueExtractor->SetInputData(m_pConnector->GetOutput());
#endif
    //int nIsoSurface = ui.lineEditValue->text().toInt();
    //if(nIsoSurface == 0)
    int nIsoSurface = 155;
    m_pTissueExtractor->SetValue(0, nIsoSurface);

#if VTK_MAJOR_VERSION <= 5
    m_pTissueNormals->SetInput(m_pTissueExtractor->GetOutput());
#else
    m_pTissueNormals->SetInputConnection(m_pTissueExtractor->GetOutputPort());
#endif
    //m_pTissueNormals->SetFeatureAngle(60.0);
#if VTK_MAJOR_VERSION <= 5
    m_pTissueMapper->SetInput(m_pTissueNormals->GetOutput());
#else
    m_pTissueMapper->SetInputConnection(m_pTissueNormals->GetOutputPort());
#endif
    m_pTissueMapper->ScalarVisibilityOff();
    m_pTissue->SetMapper(m_pTissueMapper);

        //if(!m_pVolumeMapper)
        //{
        //	m_pVolumeMapper = vtkFixedPointVolumeRayCastMapper::New();
        //	m_pVolumeMapper->SetInput(m_pConnector->GetOutput());
//.........这里部分代码省略.........
开发者ID:jrkwon,项目名称:VolumeViewer,代码行数:101,代码来源:main.cpp


注:本文中的readertype::Pointer::SetFileNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。