[vtkusers] DICOM data resolution reduction
O'Connor, Aonghus
A.OConnor at ucc.ie
Thu Oct 5 07:37:42 EDT 2006
Hi,
I have been having difficulty reducing the dataset size of a 512*512*87
DICOM dataset.
The memory requirement for such a large set are too demanding on my
computer. I've set the extent of the dataset to 1 / 4 of the original size
and found that I can render this.
For the whole set I've been messing with vtkImageShiftScale and
vtkImageShrink3D.
Here are the steps I take:
The following works
1. Read the source files into itk::ImageSeriesReader
2. Connect to vtk Importer via ConnectPipeline
3 Set extent to 1 / 4 of original data set
4. Extract Countour
5. Map to polydata
6. render image
The following does not due to memory shortages
1. Read the source files into itk::ImageSeriesReader
2. Connect to vtk Importer via ConnectPipeline
3. Extract Countour
4. Map to polydata
5. render image
Attempt to reduce dataset resolution using vtkImageShiftScale (not working)
1. Read the source files into itk::ImageSeriesReader
2. Connect to vtk Importer via ConnectPipeline
3 reduce using vtkImageShiftScale
4. Extract Countour
5. Map to polydata
6. render image
Attempt to reduce dataset resolution using vtkImageShrink3D (not working)
1. Read the source files into itk::ImageSeriesReader
2. Connect to vtk Importer via ConnectPipeline
3 reduce using vtkImageShrink3D
4. Extract Countour
5. Map to polydata
6. render image
Any help is appreciated.
Regards Aonghus.
typedef signed short PixelType;
typedef itk::Image< PixelType, 3> ImageType;
typedef itk::ImageSeriesReader< ImageType > ReaderType;
typedef std::vector< std::string > FileNamesContainer;
typedef itk::GDCMSeriesFileNames NamesGeneratorType;
typedef std::vector< std::string > SeriesIdContainer;
typedef std::vector< unsigned int> NumSeriesFilesContainer;
typedef itk::GDCMImageIO ImageIOType;
ReaderType::Pointer *reader;
NamesGeneratorType::Pointer *nameGenerator;
SeriesIdContainer *SeriesVector;
NumSeriesFilesContainer *NumFilesVector;
nameGenerator = new NamesGeneratorType::Pointer;
(*nameGenerator) = NamesGeneratorType::New();
(*nameGenerator)->SetUseSeriesDetails( true );
(*nameGenerator)->SetDirectory( "C:\\AOC\\Images\\Bassalt\\06151353"
);
const SeriesIdContainer & seriesUID =
(*nameGenerator)->GetSeriesUIDs();
SeriesVector = new SeriesIdContainer();
NumFilesVector = new NumSeriesFilesContainer();
SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();
SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();
int counter = 0;
while( seriesItr != seriesEnd )
{
SeriesVector->push_back(seriesUID[counter]);
FileNamesContainer fileNames;
fileNames = (*nameGenerator)->GetFileNames( seriesUID[counter]
);
NumFilesVector->push_back(fileNames.size());
seriesItr++;
counter++;
}
reader = new ReaderType::Pointer;
*reader = ReaderType::New();
ImageIOType::Pointer dicomIO = ImageIOType::New();
(*reader)->SetImageIO( dicomIO );
std::string seriesIdentifier;
seriesIdentifier = (*SeriesVector)[1];
FileNamesContainer fileNames;
fileNames = (*nameGenerator)->GetFileNames( seriesIdentifier );
(*reader)->SetFileNames( fileNames );
try
{
(*reader)->Update();
}
catch (itk::ExceptionObject &ex)
{
std::cout << ex << std::endl;
return EXIT_FAILURE;
}
// ITK Export
typedef itk::VTKImageExport< ImageType > ITKExportType;
ITKExportType::Pointer itkVTKExporter= ITKExportType::New();
vtkImageImport *vtkImporter = vtkImageImport::New();
itkVTKExporter->SetInput((*reader)->GetOutput());
ConnectPipelines(itkVTKExporter, vtkImporter);
vtkImporter->Update();
int ext[6];
vtkImporter->GetOutput()->GetWholeExtent(ext);
vtkImporter->GetOutput()->SetWholeExtent(ext[0],ext[0]+(ext[1]-ext[0])/4,
ext[2],ext[2]+(ext[3]-ext[2])/4,ext[4],ext[4]+(ext[5]-ext[4])/4);
vtkImporter->GetOutput()->GetWholeExtent(ext);
vtkImporter->GetOutput()->SetScalarTypeToUnsignedChar();
/*vtkImageShiftScale *shiftscale = vtkImageShiftScale::New();
shiftscale->SetInput(readerDataToCheck);
shiftscale->Update();*/
/*vtkImageShrink3D* mask = vtkImageShrink3D::New();
mask->SetInputConnection(grad->GetOutputPort());
mask->SetShrinkFactors(15, 5, 5);*/
vtkContourFilter *skinExtractor = vtkContourFilter::New();
skinExtractor->SetInputConnection(vtkImporter ->GetOutputPort());
skinExtractor->SetValue(0, 500);
vtkPolyDataMapper *skinMapper = vtkPolyDataMapper::New();
skinMapper->SetInputConnection(skinExtractor->GetOutputPort());
vtkActor *skin = vtkActor::New();
skin->SetMapper(skinMapper);
aRenderer->AddActor(skin);
aRenderer->SetActiveCamera(aCamera);
aRenderer->Render();
aRenderer->ResetCamera ();
aCamera->Dolly(1.5);
aRenderer->SetBackground(1,1,1);
renWin->SetSize(640, 480);
aRenderer->ResetCameraClippingRange ();
iren->Initialize();
iren->Start();
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061005/639b668d/attachment.htm>
More information about the vtkusers
mailing list