[Insight-users] writing out a 3D volume
robert tamburo
robert.tamburo at gmail.com
Wed Aug 10 13:01:59 EDT 2011
Try changing
"typedef itk::ImageFileWriter< InputImageType::ConstPointer > WriterType;"
to
"typedef itk::ImageFileWriter< InputImageType > WriterType;"
On Wed, Aug 10, 2011 at 12:53 PM, David Brayford <dbrayford at gmail.com>wrote:
> Hi,
>
> I am trying to write out a 3D volume in ITK that is loaded in from
> VTK. However, I am having trouble with conversion errors from const
> even after looking at some examples.
>
> typedef itk::Image< InputPixelType, Dimension > InputImageType;
> typedef itk::Image< OutputPixelType, Dimension > OutputImageType;
>
> InputImageType::ConstPointer imagePtr;
>
> vtkImageData * vol = data->GetVolume()->getImageData();
>
> typedef itk::VTKImageToImageFilter<InputImageType>
> VTKToITKConnector;
> VTKToITKConnector::Pointer VTK_to_ITK_filter = VTKToITKConnector::New();
>
> VTK_to_ITK_filter->SetInput(vol);
> VTK_to_ITK_filter->Update();
>
> imagePtr = VTK_to_ITK_filter->GetOutput();
>
> typedef itk::ResampleImageFilter<InputImageType, InputImageType >
> FilterType;
> FilterType::Pointer filter = FilterType::New();
> filter->SetInput( imagePtr );
> filter->SetDefaultPixelValue( 0 );
>
> typedef itk::CastImageFilter< InputImageType, InputImageType >
> CastFilterType;
> CastFilterType::Pointer caster = CastFilterType::New();
> caster->SetInput( filter->GetOutput() );
>
> // Write the output
> typedef itk::ImageFileWriter< InputImageType::ConstPointer >
> WriterType;
> WriterType::Pointer writer = WriterType::New();
>
> // problem "itk::image<type, type>" is incompatible with type
> "const itk::image<type, type>"
> writer->SetInput( caster->GetOutput() );
>
>
> writer->SetFileName("output_volume.mhd");
> writer->Update();
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110810/95ac2ac0/attachment.htm>
More information about the Insight-users
mailing list