<HTML><HEAD></HEAD>
<BODY dir=ltr>
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">
<DIV>
<DIV
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none"></DIV></DIV>
<DIV
style="FONT-STYLE: normal; DISPLAY: inline; FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: small; FONT-WEIGHT: normal; TEXT-DECORATION: none">
<DIV dir=ltr>
<DIV style="FONT-FAMILY: 'Calibri'; COLOR: #000000; FONT-SIZE: 12pt">
<DIV>Hi</DIV>
<DIV> </DIV>
<DIV>I am trying to do conversion of image from Cartesian to polar using
itk::ResampleImageFilter but result is not proper.</DIV>
<DIV> </DIV>
<DIV>I am doing polar and Cartesian vice versa conversion using code given at
</DIV>
<DIV><A title=http://www.insight-journal.org/browse/publication/130
href="http://www.insight-journal.org/browse/publication/130">http://www.insight-journal.org/browse/publication/130</A></DIV>
<DIV> </DIV>
<DIV>But it does not producing perfect image as output. Any one can tell me what
I am doing wrong ?</DIV>
<DIV> </DIV>
<DIV>Here is code of my example.</DIV>
<DIV> </DIV>
<DIV>#include "itkImage.h"</DIV>
<DIV>#include "itkImageFileReader.h"</DIV>
<DIV>#include "itkImageFileWriter.h"</DIV>
<DIV>#include "itkResampleImageFilter.h"</DIV>
<DIV>#include "itkAffineTransform.h"</DIV>
<DIV>#include "itkNearestNeighborInterpolateImageFunction.h"</DIV>
<DIV>#include "itkCartesianToPolarTransform.h"</DIV>
<DIV>#include "itkPolarToCartesianTransform.h"</DIV>
<DIV> </DIV>
<DIV>int main( int argc, char * argv[] )</DIV>
<DIV>{</DIV>
<DIV> if( argc < 3 )</DIV>
<DIV> {</DIV>
<DIV> std::cerr << "Usage: " << std::endl;</DIV>
<DIV> std::cerr << argv[0] << "
inputImageFile outputImageFile"; </DIV>
<DIV> return EXIT_FAILURE;</DIV>
<DIV> }</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> const unsigned int Dimension =
2;</DIV>
<DIV> typedef unsigned char InputPixelType;</DIV>
<DIV> typedef unsigned char OutputPixelType;</DIV>
<DIV> typedef itk::Image< InputPixelType, Dimension
> InputImageType;</DIV>
<DIV> typedef itk::Image< OutputPixelType, Dimension >
OutputImageType;</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> typedef itk::ImageFileReader< InputImageType >
ReaderType;</DIV>
<DIV> typedef itk::ImageFileWriter< OutputImageType >
WriterType;</DIV>
<DIV> </DIV>
<DIV> ReaderType::Pointer reader = ReaderType::New();</DIV>
<DIV> WriterType::Pointer writer = WriterType::New();</DIV>
<DIV> </DIV>
<DIV> reader->SetFileName( argv[1] );</DIV>
<DIV> writer->SetFileName( argv[2] );</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> typedef
itk::ResampleImageFilter<InputImageType,OutputImageType> FilterType;</DIV>
<DIV> FilterType::Pointer filter = FilterType::New();</DIV>
<DIV> </DIV>
<DIV>typedef itk::CartesianToPolarTransform<double,Dimension>
TransformType;</DIV>
<DIV> TransformType::Pointer transform = TransformType::New();</DIV>
<DIV> filter->SetTransform( transform );</DIV>
<DIV> </DIV>
<DIV> typedef itk::NearestNeighborInterpolateImageFunction< </DIV>
<DIV>
InputImageType, double > InterpolatorType;</DIV>
<DIV> InterpolatorType::Pointer interpolator =
InterpolatorType::New();</DIV>
<DIV> filter->SetInterpolator( interpolator );</DIV>
<DIV> filter->SetDefaultPixelValue( 0 );</DIV>
<DIV> </DIV>
<DIV> double spacing[ Dimension ];</DIV>
<DIV> spacing[0] = 1.0; // pixel spacing in millimeters along X</DIV>
<DIV> spacing[1] = 1.0; // pixel spacing in millimeters along Y</DIV>
<DIV> </DIV>
<DIV> filter->SetOutputSpacing( spacing );</DIV>
<DIV> </DIV>
<DIV> double origin[ Dimension ];</DIV>
<DIV> origin[0] = 0.0; // X space coordinate of origin</DIV>
<DIV> origin[1] = 0.0; // Y space coordinate of origin</DIV>
<DIV> </DIV>
<DIV> filter->SetOutputOrigin( origin );</DIV>
<DIV> </DIV>
<DIV> InputImageType::DirectionType direction;</DIV>
<DIV> direction.SetIdentity();</DIV>
<DIV> filter->SetOutputDirection( direction );</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> InputImageType::SizeType size;</DIV>
<DIV> size[0] = 512; // number of pixels along X</DIV>
<DIV> size[1] = 512; // number of pixels along Y</DIV>
<DIV> filter->SetSize( size );</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> filter->SetInput( reader->GetOutput() );</DIV>
<DIV> writer->SetInput( filter->GetOutput() );</DIV>
<DIV> writer->Update();</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> return EXIT_SUCCESS;</DIV>
<DIV>}</DIV></DIV></DIV></DIV></DIV></DIV></BODY></HTML>