Hi Luis,<br>Here is the code I used. It is the example ResampleImageFilter5 with a change in the transform.<br>The images were dicom mammography 3d images. <br>The same problem appeared when I used .vtk 3d images . I didnt changed <br>
the input and output pixel type<br><br>Thanks ,<br>Giorgos<br><br><br>#include &quot;itkImage.h&quot;<br>#include &quot;itkImageFileReader.h&quot;<br>#include &quot;itkImageFileWriter.h&quot;<br>#include &quot;itkResampleImageFilter.h&quot;<br>
#include &quot;itkLinearInterpolateImageFunction.h&quot;<br>#include &quot;itkSimilarity3DTransform.h&quot;<br><br>int main( int argc, char * argv[] )<br>{<br>&nbsp; if( argc &lt; 5 )<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; &quot;Usage: &quot; &lt;&lt; std::endl;<br>
&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; argv[0] &lt;&lt; &quot;&nbsp; inputImageFile&nbsp; outputImageFile&nbsp; degrees&nbsp; scale&quot; &lt;&lt; std::endl; <br>&nbsp;&nbsp;&nbsp; return EXIT_FAILURE;<br>&nbsp;&nbsp;&nbsp; }<br><br>&nbsp; const&nbsp;&nbsp;&nbsp;&nbsp; unsigned int&nbsp;&nbsp; Dimension = 3;<br>&nbsp; typedef&nbsp;&nbsp; unsigned char&nbsp; InputPixelType;<br>
&nbsp; typedef&nbsp;&nbsp; unsigned char&nbsp; OutputPixelType;<br><br>&nbsp; typedef itk::Image&lt; InputPixelType,&nbsp; Dimension &gt;&nbsp;&nbsp; InputImageType;<br>&nbsp; typedef itk::Image&lt; OutputPixelType, Dimension &gt;&nbsp;&nbsp; OutputImageType;<br><br>&nbsp; typedef itk::ImageFileReader&lt; InputImageType&nbsp; &gt;&nbsp; ReaderType;<br>
&nbsp; typedef itk::ImageFileWriter&lt; OutputImageType &gt;&nbsp; WriterType;<br><br>&nbsp; ReaderType::Pointer reader = ReaderType::New();<br>&nbsp; WriterType::Pointer writer = WriterType::New();<br><br>&nbsp; reader-&gt;SetFileName( argv[1] );<br>
&nbsp; writer-&gt;SetFileName( argv[2] );<br>&nbsp;&nbsp;&nbsp; typedef itk::Similarity3DTransform&lt; double &gt;&nbsp; TransformType;<br>&nbsp; TransformType::Pointer transform = TransformType::New();<br><br>&nbsp; typedef TransformType::ParametersType ParametersType;<br>
&nbsp; ParametersType parameters;<br>&nbsp;&nbsp; double angleInDegrees = atof( argv[3] );<br>&nbsp; <br>&nbsp;&nbsp; double scale&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; = atof( argv[4] );<br>&nbsp;&nbsp;&nbsp; <br>&nbsp; transform-&gt;SetScale(scale);<br>&nbsp; typedef itk::ResampleImageFilter&lt;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InputImageType, OutputImageType &gt;&nbsp; FilterType;<br>
<br>&nbsp; FilterType::Pointer filter = FilterType::New();<br><br><br>&nbsp; typedef itk::LinearInterpolateImageFunction&lt; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; InputImageType, double &gt;&nbsp; InterpolatorType;<br>&nbsp; InterpolatorType::Pointer interpolator = InterpolatorType::New();<br>
&nbsp;<br>&nbsp; filter-&gt;SetInterpolator( interpolator );<br><br>&nbsp; filter-&gt;SetDefaultPixelValue( 0 );<br><br>&nbsp; reader-&gt;Update();<br>&nbsp; const InputImageType::SpacingType&amp;<br>&nbsp;&nbsp;&nbsp; spacing = reader-&gt;GetOutput()-&gt;GetSpacing();<br>
&nbsp; const InputImageType::PointType&amp;<br>&nbsp;&nbsp;&nbsp; origin&nbsp; = reader-&gt;GetOutput()-&gt;GetOrigin();<br>&nbsp; InputImageType::SizeType size = <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; reader-&gt;GetOutput()-&gt;GetLargestPossibleRegion().GetSize();<br><br>&nbsp; filter-&gt;SetOutputOrigin( origin );<br>
&nbsp; filter-&gt;SetOutputSpacing( spacing );<br>&nbsp; filter-&gt;SetSize( size );<br><br><br>&nbsp; filter-&gt;SetInput( reader-&gt;GetOutput() );<br>&nbsp; writer-&gt;SetInput( filter-&gt;GetOutput() );<br>&nbsp; TransformType::InputPointType rotationCenter;<br>
&nbsp; rotationCenter[0] = origin[0] + spacing[0] * size[0] / 2.0;<br>&nbsp; rotationCenter[1] = origin[1] + spacing[1] * size[1] / 2.0;<br>&nbsp; rotationCenter[2] = origin[2] + spacing[2] * size[2] / 2.0;<br>&nbsp; transform-&gt;SetCenter( rotationCenter );<br>
<br>&nbsp; typedef TransformType::VersorType VersorType;<br>&nbsp; typedef VersorType::VectorType VectorType;<br>&nbsp; VersorType rotation;<br>&nbsp; VectorType axis;<br>&nbsp; axis[0]=0.0;<br>&nbsp; axis[1]=0.0;<br>&nbsp; axis[2]=1.0;<br>&nbsp;&nbsp; double degreesToRadians = atan(1.0) / 45.0;<br>
&nbsp;&nbsp;&nbsp; const double angle = angleInDegrees * degreesToRadians;<br>&nbsp;rotation.Set (axis, angle);<br>&nbsp; transform-&gt;SetRotation( rotation );<br>&nbsp; <br>&nbsp; TransformType::OutputVectorType translation;<br><br>&nbsp; translation[0] =&nbsp;&nbsp; 0.0;<br>
&nbsp; translation[1] =&nbsp;&nbsp; 0.0;<br>&nbsp; translation[2] =&nbsp;&nbsp; 0.0;<br>&nbsp; transform-&gt;SetTranslation (translation);<br>&nbsp; <br><br>&nbsp; filter-&gt;SetTransform( transform );<br><br>&nbsp; try <br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; writer-&gt;Update();<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; catch( itk::ExceptionObject &amp; excep )<br>
&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; &quot;Exception catched !&quot; &lt;&lt; std::endl;<br>&nbsp;&nbsp;&nbsp; std::cerr &lt;&lt; excep &lt;&lt; std::endl;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp; return EXIT_SUCCESS;<br>}<br><br><br><div class="gmail_quote">On Fri, Mar 28, 2008 at 6:18 PM, Luis Ibanez &lt;<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>&gt; wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Giorgos,<br>
<br>
1) How different are the intensities of the output image ?<br>
<br>
2) What Transform are you using ?<br>
<br>
3) What interpolator are you using ?<br>
<br>
4) What image type did you defined for the input ?<br>
<br>
5) What image type did you defined for the output ?<br>
<br>
6) What is the modality of the input image ?<br>
<br>
...<br>
<br>
7) Please post your code to the list.<br>
<br>
<br>
 &nbsp; Thanks<br>
<br>
<br>
 &nbsp; &nbsp; &nbsp;Luis<br>
<br>
<br>
-----------------------<br>
<div><div></div><div class="Wj3C7c">Giorgos Pichis wrote:<br>
&gt; Hi there,<br>
&gt; I tried to resample a 3d image (.vtk) with a transformation,<br>
&gt; but the output image ( &nbsp;writer-&gt;SetInput(filter-&gt;GetOutput() ); &nbsp; )<br>
&gt; had different intensity values than the input image.<br>
&gt; Do you know what might be the problem?<br>
&gt; Thanks<br>
&gt;<br>
&gt;<br>
</div></div>&gt; ------------------------------------------------------------------------<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Insight-users mailing list<br>
&gt; <a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br>
&gt; <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</blockquote></div><br>