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&lt; InputImageType &gt; WriterType;</span><br>
<br><div class="gmail_quote">On Wed, Aug 10, 2011 at 1:28 PM, David Brayford <span dir="ltr">&lt;<a href="mailto:dbrayford@gmail.com">dbrayford@gmail.com</a>&gt;</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-&gt;SetInput( caster-&gt;GetOutput() );<br>
<br>
error C2664: &#39;itk::ImageFileWriter&lt;TInputImage&gt;::SetInput&#39; : cannot<br>
convert parameter 1 from &#39;itk::Image&lt;TPixel,VImageDimension&gt; *&#39; to<br>
&#39;const itk::SmartPointer&lt;TObjectType&gt; *&#39;<br>
          with<br>
          [<br>
              TInputImage=itk::SmartPointer&lt;itk::Image&lt;GenerateDRR::InputPixelType,3&gt;&gt;<br>
          ]<br>
          and<br>
          [<br>
              TPixel=GenerateDRR::InputPixelType,<br>
              VImageDimension=3<br>
          ]<br>
          and<br>
          [<br>
              TObjectType=itk::Image&lt;GenerateDRR::InputPixelType,3&gt;<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&lt; InputImageType, InputImageType &gt;<br>
CastFilterType;<br>
        CastFilterType::Pointer caster = CastFilterType::New();<br>
        caster-&gt;SetInput( filter-&gt;GetOutput() );<br>
<br>
         // Write the output<br>
</div>         typedef itk::ImageFileWriter&lt; InputImageType::Pointer &gt; WriterType;<br>
<div class="im">         WriterType::Pointer writer = WriterType::New();<br>
<br>
</div>         // error with caster-&gt;GetOutput()<br>
<div class="im">         writer-&gt;SetInput( caster-&gt;GetOutput() );<br>
         writer-&gt;SetFileName(&quot;output_volume.mhd&quot;);<br>
         writer-&gt;Update();<br>
</div><div><div></div><div class="h5">On Wed, Aug 10, 2011 at 11:01 AM, robert tamburo<br>
&lt;<a href="mailto:robert.tamburo@gmail.com">robert.tamburo@gmail.com</a>&gt; wrote:<br>
&gt; Try changing<br>
&gt; &quot;typedef itk::ImageFileWriter&lt; InputImageType::ConstPointer &gt; WriterType;&quot;<br>
&gt; to<br>
&gt;<br>
&gt; &quot;typedef itk::ImageFileWriter&lt; InputImageType &gt; WriterType;&quot;<br>
&gt;<br>
&gt; On Wed, Aug 10, 2011 at 12:53 PM, David Brayford &lt;<a href="mailto:dbrayford@gmail.com">dbrayford@gmail.com</a>&gt;<br>
&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi,<br>
&gt;&gt;<br>
&gt;&gt; I am trying to write out a 3D volume in ITK that is loaded in from<br>
&gt;&gt; VTK. However, I am having trouble with conversion errors from const<br>
&gt;&gt; even after looking at some examples.<br>
&gt;&gt;<br>
&gt;&gt;        typedef itk::Image&lt; InputPixelType,  Dimension &gt;   InputImageType;<br>
&gt;&gt;        typedef itk::Image&lt; OutputPixelType, Dimension &gt;   OutputImageType;<br>
&gt;&gt;<br>
&gt;&gt;        InputImageType::ConstPointer imagePtr;<br>
&gt;&gt;<br>
&gt;&gt;        vtkImageData * vol = data-&gt;GetVolume()-&gt;getImageData();<br>
&gt;&gt;<br>
&gt;&gt;        typedef itk::VTKImageToImageFilter&lt;InputImageType&gt;<br>
&gt;&gt; VTKToITKConnector;<br>
&gt;&gt;    VTKToITKConnector::Pointer VTK_to_ITK_filter =<br>
&gt;&gt; VTKToITKConnector::New();<br>
&gt;&gt;<br>
&gt;&gt;    VTK_to_ITK_filter-&gt;SetInput(vol);<br>
&gt;&gt;    VTK_to_ITK_filter-&gt;Update();<br>
&gt;&gt;<br>
&gt;&gt;        imagePtr = VTK_to_ITK_filter-&gt;GetOutput();<br>
&gt;&gt;<br>
&gt;&gt;        typedef itk::ResampleImageFilter&lt;InputImageType, InputImageType &gt;<br>
&gt;&gt; FilterType;<br>
&gt;&gt;        FilterType::Pointer filter = FilterType::New();<br>
&gt;&gt;        filter-&gt;SetInput( imagePtr );<br>
&gt;&gt;        filter-&gt;SetDefaultPixelValue( 0 );<br>
&gt;&gt;<br>
&gt;&gt;        typedef itk::CastImageFilter&lt; InputImageType, InputImageType &gt;<br>
&gt;&gt; CastFilterType;<br>
&gt;&gt;        CastFilterType::Pointer caster = CastFilterType::New();<br>
&gt;&gt;        caster-&gt;SetInput( filter-&gt;GetOutput() );<br>
&gt;&gt;<br>
&gt;&gt;         // Write the output<br>
&gt;&gt;         typedef itk::ImageFileWriter&lt; InputImageType::ConstPointer &gt;<br>
&gt;&gt; WriterType;<br>
&gt;&gt;         WriterType::Pointer writer = WriterType::New();<br>
&gt;&gt;<br>
&gt;&gt;         // problem &quot;itk::image&lt;type, type&gt;&quot; is incompatible with type<br>
&gt;&gt; &quot;const itk::image&lt;type, type&gt;&quot;<br>
&gt;&gt;         writer-&gt;SetInput( caster-&gt;GetOutput() );<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;         writer-&gt;SetFileName(&quot;output_volume.mhd&quot;);<br>
&gt;&gt;         writer-&gt;Update();<br>
&gt;&gt; _____________________________________<br>
&gt;&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;&gt;<br>
&gt;&gt; Visit other Kitware open-source projects at<br>
&gt;&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;&gt;<br>
&gt;&gt; Kitware offers ITK Training Courses, for more information visit:<br>
&gt;&gt; <a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
&gt;&gt;<br>
&gt;&gt; Please keep messages on-topic and check the ITK FAQ at:<br>
&gt;&gt; <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
&gt;&gt;<br>
&gt;&gt; Follow this link to subscribe/unsubscribe:<br>
&gt;&gt; <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br>