[vtkusers] DICOM data resolution reduction

O'Connor, Aonghus A.OConnor at ucc.ie
Thu Oct 5 08:23:10 EDT 2006


Thanks Glen,
That saved me so much hassle.
Would you recommend the VTK Users guide for solving these kind of problems?
Aonghus.



-----Original Message-----
From: glehmann.atamai at gmail.com [mailto:glehmann.atamai at gmail.com] On Behalf
Of Glen Lehmann
Sent: 05 October 2006 13:10
To: O'Connor, Aonghus
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] DICOM data resolution reduction

Hi Aonghus,

The simplist way to reduce the size of our input vtkImageData is to
use vtkImageResample:

vtkImageResample *resample = vtkImageResample::New();
resample->SetInputConnection( vtkImporter->GetOutputPort() );
resample->SetAxisMagnificationFactor(0, 0.25);
resample->SetAxisMagnificationFactor(1, 0.25);
resample->SetAxisMagnificationFactor(2, 0.25);

Since your data is already in unsigned char format, vtkImageShiftScale
will not reduce the footprint of your data any further (otherwise it
could be used to cast your data to unsigned char).

At this point, you still have the original vtkImageData in memory.
You may also want to do something like:

vtkImageData *resampledData = resample->GetOutput();
resampledData->Update();
resampledData->Register(NULL); // break the pipeline

// clean up any objects before the break in the pipeline
reader->Delete();
vtkImporter->Delete();

Also note that instead of reducing the size of the vtkImageData, you
could also reduce the size of the vtkPolyData that's output from your
contour filter by running vtkDecimatePro.

HTH,

Glen

On 05/10/06, O'Connor, Aonghus <A.OConnor at ucc.ie> wrote:
>
>
>
>
> 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();
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
>



More information about the vtkusers mailing list