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 "itkImage.h"<br>#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"<br>#include "itkResampleImageFilter.h"<br>
#include "itkLinearInterpolateImageFunction.h"<br>#include "itkSimilarity3DTransform.h"<br><br>int main( int argc, char * argv[] )<br>{<br> if( argc < 5 )<br> {<br> std::cerr << "Usage: " << std::endl;<br>
std::cerr << argv[0] << " inputImageFile outputImageFile degrees scale" << std::endl; <br> return EXIT_FAILURE;<br> }<br><br> const unsigned int Dimension = 3;<br> typedef unsigned char InputPixelType;<br>
typedef unsigned char OutputPixelType;<br><br> typedef itk::Image< InputPixelType, Dimension > InputImageType;<br> typedef itk::Image< OutputPixelType, Dimension > OutputImageType;<br><br> typedef itk::ImageFileReader< InputImageType > ReaderType;<br>
typedef itk::ImageFileWriter< OutputImageType > WriterType;<br><br> ReaderType::Pointer reader = ReaderType::New();<br> WriterType::Pointer writer = WriterType::New();<br><br> reader->SetFileName( argv[1] );<br>
writer->SetFileName( argv[2] );<br> typedef itk::Similarity3DTransform< double > TransformType;<br> TransformType::Pointer transform = TransformType::New();<br><br> typedef TransformType::ParametersType ParametersType;<br>
ParametersType parameters;<br> double angleInDegrees = atof( argv[3] );<br> <br> double scale = atof( argv[4] );<br> <br> transform->SetScale(scale);<br> typedef itk::ResampleImageFilter<<br> InputImageType, OutputImageType > FilterType;<br>
<br> FilterType::Pointer filter = FilterType::New();<br><br><br> typedef itk::LinearInterpolateImageFunction< <br> InputImageType, double > InterpolatorType;<br> InterpolatorType::Pointer interpolator = InterpolatorType::New();<br>
<br> filter->SetInterpolator( interpolator );<br><br> filter->SetDefaultPixelValue( 0 );<br><br> reader->Update();<br> const InputImageType::SpacingType&<br> spacing = reader->GetOutput()->GetSpacing();<br>
const InputImageType::PointType&<br> origin = reader->GetOutput()->GetOrigin();<br> InputImageType::SizeType size = <br> reader->GetOutput()->GetLargestPossibleRegion().GetSize();<br><br> filter->SetOutputOrigin( origin );<br>
filter->SetOutputSpacing( spacing );<br> filter->SetSize( size );<br><br><br> filter->SetInput( reader->GetOutput() );<br> writer->SetInput( filter->GetOutput() );<br> TransformType::InputPointType rotationCenter;<br>
rotationCenter[0] = origin[0] + spacing[0] * size[0] / 2.0;<br> rotationCenter[1] = origin[1] + spacing[1] * size[1] / 2.0;<br> rotationCenter[2] = origin[2] + spacing[2] * size[2] / 2.0;<br> transform->SetCenter( rotationCenter );<br>
<br> typedef TransformType::VersorType VersorType;<br> typedef VersorType::VectorType VectorType;<br> VersorType rotation;<br> VectorType axis;<br> axis[0]=0.0;<br> axis[1]=0.0;<br> axis[2]=1.0;<br> double degreesToRadians = atan(1.0) / 45.0;<br>
const double angle = angleInDegrees * degreesToRadians;<br> rotation.Set (axis, angle);<br> transform->SetRotation( rotation );<br> <br> TransformType::OutputVectorType translation;<br><br> translation[0] = 0.0;<br>
translation[1] = 0.0;<br> translation[2] = 0.0;<br> transform->SetTranslation (translation);<br> <br><br> filter->SetTransform( transform );<br><br> try <br> {<br> writer->Update();<br> }<br> catch( itk::ExceptionObject & excep )<br>
{<br> std::cerr << "Exception catched !" << std::endl;<br> std::cerr << excep << std::endl;<br> }<br> return EXIT_SUCCESS;<br>}<br><br><br><div class="gmail_quote">On Fri, Mar 28, 2008 at 6:18 PM, Luis Ibanez <<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>> 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>
Thanks<br>
<br>
<br>
Luis<br>
<br>
<br>
-----------------------<br>
<div><div></div><div class="Wj3C7c">Giorgos Pichis wrote:<br>
> Hi there,<br>
> I tried to resample a 3d image (.vtk) with a transformation,<br>
> but the output image ( writer->SetInput(filter->GetOutput() ); )<br>
> had different intensity values than the input image.<br>
> Do you know what might be the problem?<br>
> Thanks<br>
><br>
><br>
</div></div>> ------------------------------------------------------------------------<br>
><br>
> _______________________________________________<br>
> Insight-users mailing list<br>
> <a href="mailto:Insight-users@itk.org">Insight-users@itk.org</a><br>
> <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>