[vtkusers] A series of DICOM images loading
Xiaopeng Yang
yxp233 at postech.ac.kr
Fri Jul 2 01:24:46 EDT 2010
Dear All,
I have succeeded in loading a series of DICOM images and visualized them by
VTK. However, I can just see the last DICOM file. What I want is that
through controlling the scroll of the mouse, I can navigate from one slice
to another slice. Does anybody know how to fulfill the goal?
Attached please find my code.
Thank you.
Xiaopeng
typedef signed short PixelType;
const unsigned int Dimension = 3;
typedef itk::OrientedImage< PixelType, Dimension > ImageType;
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( "F:/Documents and
Settings/Xiaopeng/Desktop/Patient (Pai Sang Pu)/Output/Difussion" );
typedef std::vector< std::string > SeriesIdContainer;
const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();
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();
typedef std::vector< std::string > FileNamesContainer;
FileNamesContainer fileNames;
fileNames = nameGenerator->GetFileNames( seriesIdentifier );
reader->SetFileNames( fileNames );
typedef itk::ImageToVTKImageFilter<ImageType>FilterType;
FilterType::Pointer connector = FilterType::New();
try
{
reader->Update();
}
catch (itk::ExceptionObject &ex)
{
std::cout << ex << std::endl;
return EXIT_FAILURE;
}
connector->SetInput(reader->GetOutput());
vtkImageViewer *viewer = vtkImageViewer::New();
vtkRenderWindowInteractor *renderWindowInteractor =
vtkRenderWindowInteractor::New();
viewer->SetupInteractor(renderWindowInteractor);
viewer->SetInput(connector->GetOutput());
viewer->Render();
viewer->SetColorWindow(255);
viewer->SetColorLevel(128);
renderWindowInteractor->Start();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100702/3730f80d/attachment.htm>
More information about the vtkusers
mailing list