The template parameter for ImageWriter is the image type, not a smart pointer. Use <span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); ">typedef itk::ImageFileWriter< InputImageType > WriterType;</span><br>
<br><div class="gmail_quote">On Wed, Aug 10, 2011 at 1:28 PM, David Brayford <span dir="ltr"><<a href="mailto:dbrayford@gmail.com">dbrayford@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Robert,<br>
<br>
I am still getting an incompatible type mismatch. on the line<br>
writer->SetInput( caster->GetOutput() );<br>
<br>
error C2664: 'itk::ImageFileWriter<TInputImage>::SetInput' : cannot<br>
convert parameter 1 from 'itk::Image<TPixel,VImageDimension> *' to<br>
'const itk::SmartPointer<TObjectType> *'<br>
with<br>
[<br>
TInputImage=itk::SmartPointer<itk::Image<GenerateDRR::InputPixelType,3>><br>
]<br>
and<br>
[<br>
TPixel=GenerateDRR::InputPixelType,<br>
VImageDimension=3<br>
]<br>
and<br>
[<br>
TObjectType=itk::Image<GenerateDRR::InputPixelType,3><br>
]<br>
Types pointed to are unrelated; conversion requires<br>
reinterpret_cast, C-style cast or function-style cast<br>
<div class="im"><br>
<br>
typedef itk::CastImageFilter< InputImageType, InputImageType ><br>
CastFilterType;<br>
CastFilterType::Pointer caster = CastFilterType::New();<br>
caster->SetInput( filter->GetOutput() );<br>
<br>
// Write the output<br>
</div> typedef itk::ImageFileWriter< InputImageType::Pointer > WriterType;<br>
<div class="im"> WriterType::Pointer writer = WriterType::New();<br>
<br>
</div> // error with caster->GetOutput()<br>
<div class="im"> writer->SetInput( caster->GetOutput() );<br>
writer->SetFileName("output_volume.mhd");<br>
writer->Update();<br>
</div><div><div></div><div class="h5">On Wed, Aug 10, 2011 at 11:01 AM, robert tamburo<br>
<<a href="mailto:robert.tamburo@gmail.com">robert.tamburo@gmail.com</a>> wrote:<br>
> Try changing<br>
> "typedef itk::ImageFileWriter< InputImageType::ConstPointer > WriterType;"<br>
> to<br>
><br>
> "typedef itk::ImageFileWriter< InputImageType > WriterType;"<br>
><br>
> On Wed, Aug 10, 2011 at 12:53 PM, David Brayford <<a href="mailto:dbrayford@gmail.com">dbrayford@gmail.com</a>><br>
> wrote:<br>
>><br>
>> Hi,<br>
>><br>
>> I am trying to write out a 3D volume in ITK that is loaded in from<br>
>> VTK. However, I am having trouble with conversion errors from const<br>
>> even after looking at some examples.<br>
>><br>
>> typedef itk::Image< InputPixelType, Dimension > InputImageType;<br>
>> typedef itk::Image< OutputPixelType, Dimension > OutputImageType;<br>
>><br>
>> InputImageType::ConstPointer imagePtr;<br>
>><br>
>> vtkImageData * vol = data->GetVolume()->getImageData();<br>
>><br>
>> typedef itk::VTKImageToImageFilter<InputImageType><br>
>> VTKToITKConnector;<br>
>> VTKToITKConnector::Pointer VTK_to_ITK_filter =<br>
>> VTKToITKConnector::New();<br>
>><br>
>> VTK_to_ITK_filter->SetInput(vol);<br>
>> VTK_to_ITK_filter->Update();<br>
>><br>
>> imagePtr = VTK_to_ITK_filter->GetOutput();<br>
>><br>
>> typedef itk::ResampleImageFilter<InputImageType, InputImageType ><br>
>> FilterType;<br>
>> FilterType::Pointer filter = FilterType::New();<br>
>> filter->SetInput( imagePtr );<br>
>> filter->SetDefaultPixelValue( 0 );<br>
>><br>
>> typedef itk::CastImageFilter< InputImageType, InputImageType ><br>
>> CastFilterType;<br>
>> CastFilterType::Pointer caster = CastFilterType::New();<br>
>> caster->SetInput( filter->GetOutput() );<br>
>><br>
>> // Write the output<br>
>> typedef itk::ImageFileWriter< InputImageType::ConstPointer ><br>
>> WriterType;<br>
>> WriterType::Pointer writer = WriterType::New();<br>
>><br>
>> // problem "itk::image<type, type>" is incompatible with type<br>
>> "const itk::image<type, type>"<br>
>> writer->SetInput( caster->GetOutput() );<br>
>><br>
>><br>
>> writer->SetFileName("output_volume.mhd");<br>
>> writer->Update();<br>
>> _____________________________________<br>
>> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>><br>
>> Visit other Kitware open-source projects at<br>
>> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>><br>
>> Kitware offers ITK Training Courses, for more information visit:<br>
>> <a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
>><br>
>> Please keep messages on-topic and check the ITK FAQ at:<br>
>> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
>><br>
>> Follow this link to subscribe/unsubscribe:<br>
>> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
><br>
><br>
</div></div></blockquote></div><br>