[Insight-users] writing out a 3D volume

robert tamburo robert.tamburo at gmail.com
Wed Aug 10 13:35:23 EDT 2011


The template parameter for ImageWriter is the image type, not a smart
pointer. Use typedef itk::ImageFileWriter< InputImageType > WriterType;

On Wed, Aug 10, 2011 at 1:28 PM, David Brayford <dbrayford at gmail.com> wrote:

> Robert,
>
> I am still getting an incompatible type mismatch. on the line
> writer->SetInput( caster->GetOutput() );
>
> error C2664: 'itk::ImageFileWriter<TInputImage>::SetInput' : cannot
> convert parameter 1 from 'itk::Image<TPixel,VImageDimension> *' to
> 'const itk::SmartPointer<TObjectType> *'
>          with
>          [
>
>  TInputImage=itk::SmartPointer<itk::Image<GenerateDRR::InputPixelType,3>>
>          ]
>          and
>          [
>              TPixel=GenerateDRR::InputPixelType,
>              VImageDimension=3
>          ]
>          and
>          [
>              TObjectType=itk::Image<GenerateDRR::InputPixelType,3>
>          ]
>         Types pointed to are unrelated; conversion requires
> reinterpret_cast, C-style cast or function-style cast
>
>
>     typedef itk::CastImageFilter< InputImageType, InputImageType >
> CastFilterType;
>        CastFilterType::Pointer caster = CastFilterType::New();
>        caster->SetInput( filter->GetOutput() );
>
>         // Write the output
>          typedef itk::ImageFileWriter< InputImageType::Pointer >
> WriterType;
>          WriterType::Pointer writer = WriterType::New();
>
>          // error with caster->GetOutput()
>          writer->SetInput( caster->GetOutput() );
>         writer->SetFileName("output_volume.mhd");
>         writer->Update();
> On Wed, Aug 10, 2011 at 11:01 AM, robert tamburo
> <robert.tamburo at gmail.com> wrote:
> > 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/1a2583f5/attachment.htm>


More information about the Insight-users mailing list