[Insight-users] Apply Transform

Oscar Esteban Sanz-Dranguet oesteban at die.upm.es
Thu Sep 24 12:24:02 EDT 2009


Hi Luis,

I missed your reply. Sorry about that. You asked me this question:

> What do you mean by the
>       "12 criterions of definition of the Euler angles"
> are you talking about the array of Transform parameters ? 
Yes, but, if I'm right, there are 12 conventions for definition of the 
Euler angles 
(http://en.wikipedia.org/wiki/Euler_angles#Other_conventions) and I 
think that the convention used for the images that I have is not the 
same that used on ITK. Could it be the reason why I can't apply the 
inverse transform?

Thanks,

Oscar Esteban
BIT - UPM (http://www.die.upm.es/im/)
+34 913 366 827 ext.4248



Luis Ibanez escribió:
>
>
> Hi Oscar,
>
>
>
>               Thanks for letting us know.
>
>
> Yes,
> it is common to find medical images whose direction cosines
> have negative components.
>
>
> Yes,
> image->GetDirection() will show you what the direction cosines are.
>
>
>
> What do you mean by the
>
>       "12 criterions of definition of the Euler angles"
>
> are you talking about the array of Transform parameters ?
>
>
>
>     Please let us know,
>
>
>         Luis
>
>
> ----------------------------------
> Oscar Esteban Sanz-Dranguet wrote:
>> Hi Luis,
>>
>> Following your recommendations, I've found that physical coordinates 
>> of Y axis are negative (¿?), so it was not a bug. The X and Z axis 
>> are positive. How can I detect if an axis should be accessed with 
>> negative coordinates? Should I use image->GetDirection()?
>>
>> The other question I've found is 'what of the 12 criterions of 
>> definition of the Euler angles is using ITK?' After a quick search on 
>> the software guide, I didn't find it.
>>
>> For the tests, I assumed the origin on (0,0,0) because I knew that it 
>> was certainly, but I've updated my code to take the origin into 
>> account :). I tested using only rotations referred to one axis and 
>> testing where a white point setted on the center was going.
>>
>> Many thanks,
>> Oscar Esteban
>>
>> Luis Ibanez escribió:
>>
>>> Hi Steban,
>>>
>>> You code seem to be ok.
>>>
>>> However we are missing some important information from
>>> your image.
>>>
>>> In particular:
>>>
>>>
>>>      A) What are the coordinates of the Origin  ?
>>>           you can get this with   image->GetOrigin()
>>>
>>>      B) What is the orientation of the image ?
>>>           you can get this with    image->GetDirection()
>>>
>>>
>>> Your manual computation seems to assume that
>>> the origin coordinates are (0,0,0) and that the
>>> direction cosines are given  by an Identity matrix.
>>>
>>>
>>> If you want to understand the rotation of the image
>>> you should first experiment with Translations set
>>> to Zero.  Otherwise, as you probably know, a
>>> Rotation followed by a Translation will generate
>>> a different apparent center of rotation.
>>>
>>>
>>> You are also missing to include in your email the
>>> values that you are passing as angles for the
>>> Euler transform.
>>>
>>> Also, a screenshot of the output image that lead
>>> you to suspect that something is wrong, will be
>>> useful for this discussion. Could you please post
>>> this screenshot in a public web site ?
>>>
>>>
>>>
>>>      Thanks
>>>
>>>
>>>           Luis
>>>
>>>
>>> -------------------------------------------------------------------
>>> On Mon, Jun 29, 2009 at 1:24 PM, Oscar Esteban Sanz-Dranguet 
>>> <oesteban at die.upm.es <mailto:oesteban at die.upm.es>> wrote:
>>>
>>>     Hi,
>>>
>>>     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)
>>>
>>>     Best Regards,
>>>     Oscar Esteban
>>>
>>>
>>>     <<<<<<<<<<<<<<<<< CODE >>>>>>>>>>>>>>>>>>>>>>
>>>     int main( int argc, char *argv[] )
>>>      {
>>>      if ( argc < 8 )
>>>       {
>>>       std::cerr << "Missing Parameters " << std::endl;
>>>       std::cerr << "Usage: " << argv[0];
>>>       std::cerr << " inputImageFile outputImageFile";
>>>       std::cerr << " traslationX traslationY traslationZ";
>>>       std::cerr << " rotationX rotationY rotationZ";
>>>       std::cerr << std::endl;
>>>       return 1;
>>>       }
>>>
>>>      typedef itk::ImageFileReader< ImageType > ImageReaderType;
>>>
>>>      typedef itk::Euler3DTransform< double > TransformType;
>>>
>>>      // Read images
>>>      ImageReaderType::Pointer  imageReader  = ImageReaderType::New();
>>>      imageReader->SetFileName( argv[1] );
>>>      imageReader->Update();
>>>      ImageType::Pointer  image =  imageReader->GetOutput();
>>>      ImageType::SpacingType spacing = image->GetSpacing();
>>>      ImageType::IndexType pixelCenter = { 128, 128, 58 };
>>>
>>>      image->SetPixel( pixelCenter, 255);
>>>
>>>      TransformType::Pointer      transform     = TransformType::New();
>>>
>>>      TransformType::InputPointType center;
>>>      center[0] = 128.5 * spacing[0];
>>>      center[1] = 128.5 * spacing[1];
>>>      center[2] = 58.5 *  spacing[2];
>>>      transform->SetCenter( center );
>>>
>>>      TransformType::OutputVectorType translation;
>>>      translation[0] = atof( argv[3] ) * spacing[0];
>>>      translation[1] = atof( argv[4] ) * spacing[1];
>>>      translation[2] = atof( argv[5] ) * spacing[2];
>>>
>>>      transform->SetRotation( deg2rad( atof( argv[6] ) ), deg2rad(
>>>     atof( argv[7] ) ), deg2rad( atof( argv[8] ) ) );
>>>      transform->SetTranslation( translation );
>>>
>>>      transform->Print(std::cout, 3);
>>>
>>>      typedef itk::ResampleImageFilter< ImageType, ImageType >       
>>> ResampleFilterType;
>>>      ResampleFilterType::Pointer resampler = ResampleFilterType::New();
>>>
>>>      resampler->SetTransform( transform );
>>>      resampler->SetInput( image );
>>>      resampler->SetReferenceImage( image );
>>>      resampler->UseReferenceImageOn( );
>>>      resampler->Update();
>>>
>>>      typedef itk::ImageFileWriter< ImageType >  WriterType;
>>>      WriterType::Pointer writer =  WriterType::New();
>>>      writer->SetFileName( argv[2] );
>>>      writer->SetInput( resampler->GetOutput() );
>>>      writer->Update();
>>>
>>>      return EXIT_SUCCESS;
>>>      }
>>>
>>>
>>>     _____________________________________
>>>     Powered by www.kitware.com <http://www.kitware.com>
>>>
>>>     Visit other Kitware open-source projects at
>>>     http://www.kitware.com/opensource/opensource.html
>>>
>>>     Please keep messages on-topic and check the ITK FAQ at:
>>>     http://www.itk.org/Wiki/ITK_FAQ
>>>
>>>     Follow this link to subscribe/unsubscribe:
>>>     http://www.itk.org/mailman/listinfo/insight-users
>>>
>>>
>>>
>>> -- 
>>> This message has been scanned for viruses and
>>> dangerous content by *MailScanner* <http://www.mailscanner.info/>, 
>>> and is
>>> believed to be clean. 
>>
>>
>


More information about the Insight-users mailing list