Hi Steban,<br><br>You code seem to be ok.<br><br>However we are missing some important information from <br>your image.<br><br>In particular:<br><br><br> A) What are the coordinates of the Origin ?<br> you can get this with image->GetOrigin()<br>
<br> B) What is the orientation of the image ?<br> you can get this with image->GetDirection()<br><br><br>Your manual computation seems to assume that<br>the origin coordinates are (0,0,0) and that the <br>
direction cosines are given by an Identity matrix.<br><br><br>If you want to understand the rotation of the image<br>you should first experiment with Translations set <br>to Zero. Otherwise, as you probably know, a <br>
Rotation followed by a Translation will generate<br>a different apparent center of rotation.<br><br><br>You are also missing to include in your email the<br>values that you are passing as angles for the<br>Euler transform.<br>
<br>Also, a screenshot of the output image that lead <br>you to suspect that something is wrong, will be<br>useful for this discussion. Could you please post<br>this screenshot in a public web site ?<br><br><br><br> Thanks<br>
<br><br> Luis<br><br><br>-------------------------------------------------------------------<br><div class="gmail_quote">On Mon, Jun 29, 2009 at 1:24 PM, Oscar Esteban Sanz-Dranguet <span dir="ltr"><<a href="mailto:oesteban@die.upm.es">oesteban@die.upm.es</a>></span> 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,<br>
<br>
I try to apply a rigid transform to some mri images. After SetCenter, only rotation about Y axis seems to use this center. Why I don't get the correct center of rotation about X and Z axis? (code at the end)<br>
<br>
Best Regards,<br>
Oscar Esteban<br>
<br>
<br>
<<<<<<<<<<<<<<<<< CODE >>>>>>>>>>>>>>>>>>>>>><br>
int main( int argc, char *argv[] )<br>
{<br>
if ( argc < 8 )<br>
{<br>
std::cerr << "Missing Parameters " << std::endl;<br>
std::cerr << "Usage: " << argv[0];<br>
std::cerr << " inputImageFile outputImageFile";<br>
std::cerr << " traslationX traslationY traslationZ";<br>
std::cerr << " rotationX rotationY rotationZ";<br>
std::cerr << std::endl;<br>
return 1;<br>
}<br>
<br>
typedef itk::ImageFileReader< ImageType > ImageReaderType;<br>
<br>
typedef itk::Euler3DTransform< double > TransformType;<br>
<br>
// Read images<br>
ImageReaderType::Pointer imageReader = ImageReaderType::New();<br>
imageReader->SetFileName( argv[1] );<br>
imageReader->Update();<br>
ImageType::Pointer image = imageReader->GetOutput();<br>
ImageType::SpacingType spacing = image->GetSpacing();<br>
ImageType::IndexType pixelCenter = { 128, 128, 58 };<br>
<br>
image->SetPixel( pixelCenter, 255);<br>
<br>
TransformType::Pointer transform = TransformType::New();<br>
<br>
TransformType::InputPointType center;<br>
center[0] = 128.5 * spacing[0];<br>
center[1] = 128.5 * spacing[1];<br>
center[2] = 58.5 * spacing[2];<br>
transform->SetCenter( center );<br>
<br>
TransformType::OutputVectorType translation;<br>
translation[0] = atof( argv[3] ) * spacing[0];<br>
translation[1] = atof( argv[4] ) * spacing[1];<br>
translation[2] = atof( argv[5] ) * spacing[2];<br>
<br>
transform->SetRotation( deg2rad( atof( argv[6] ) ), deg2rad( atof( argv[7] ) ), deg2rad( atof( argv[8] ) ) );<br>
transform->SetTranslation( translation );<br>
<br>
transform->Print(std::cout, 3);<br>
<br>
typedef itk::ResampleImageFilter< ImageType, ImageType > ResampleFilterType;<br>
ResampleFilterType::Pointer resampler = ResampleFilterType::New();<br>
<br>
resampler->SetTransform( transform );<br>
resampler->SetInput( image );<br>
resampler->SetReferenceImage( image );<br>
resampler->UseReferenceImageOn( );<br>
resampler->Update();<br>
<br>
typedef itk::ImageFileWriter< ImageType > WriterType;<br>
WriterType::Pointer writer = WriterType::New();<br>
writer->SetFileName( argv[2] );<br>
writer->SetInput( resampler->GetOutput() );<br>
writer->Update();<br>
<br>
return EXIT_SUCCESS;<br>
}<br>
<br>
<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>
Please keep messages on-topic and check the ITK FAQ at: <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>
</blockquote></div><br>