[Insight-users] Re: VersorRigid3DTransform
Luis Ibanez
luis.ibanez at kitware.com
Wed, 31 Dec 2003 18:29:25 -0500
Hi Radhika,
Please consult the Doxygen documentation for the
list of methods avilable for every ITK class.
Answers to your questions can easily be found there.
The class
http://www.itk.org/Insight/Doxygen/html/classitk_1_1VersorRigid3DTransform.html
1) has a SetCenter() method
2) The Set/Get Parameters manage 9 elements.
3 for the versor, 3 for translation and
3 for the center of rotation
http://www.itk.org/Insight/Doxygen/html/classitk_1_1VersorRigid3DTransform.html#z1257_0
3) Offset is computed as the result of rotating
the center and adding the translation:
P' = R * ( P - C ) + C + T
Offset = - R * C + C + T
P' = R * P + Offset
R = rotation matrix
P = input point
P' = output point
C = center of rotation
T = translation
4) Yes there is a way of printing the translation:
GetTranslation()
Please check the Doxygen page for details.
Regards,
Luis
-------------------------------------
Radhika Sivaramakrishna wrote:
> Hi Luis,
>
> Thanks for the explanation. It was helpful.
> I had some further questions.
> How do I set the center of rotation to something other than the origin? I
> can do this by explicitly setting the values in finalParameters but how do I
> do it using versors and setting the rotation angle explicitly?
> Also is the optimization done in a 9-parameter space including center of
> rotation or is it a 6-parameter space?
>
> Also, when the offset is printed out (for example in the example given under
> CenteredTransform), is this always given as though the rotation were about
> the origin rather than the center of rotation?
> Is there a way to print out the true translation?
>
> Radhika
>
> ----- Original Message -----
> From: "Luis Ibanez" <luis.ibanez at kitware.com>
> To: "Radhika Sivaramakrishna" <radshashi at earthlink.net>
> Cc: <insight-users at itk.org>
> Sent: Wednesday, December 31, 2003 11:42 AM
> Subject: Re: VersorRigid3DTransform
>
>
>
>>Hi Radhika,
>>
>>A) The memory problem that you are encountering is
>> due to the fact that the "ParameterType" used by
>> ITK transform for representing the array of
>> parameters is indeed a vnl_vector<>.
>>
>> This is a variable size vector that by default has
>> size=0. You must replace the declaration:
>>
>>TransformType::ParametersType finalParameters;
>>
>> with something like:
>>
>>TransformType::ParametersType finalParameters(
>> transform->GetNumberOfParameters() );
>>
>> or something like:
>>
>>TransformType::ParametersType finalParameters =
>> transform->GetParameters();
>>
>> In both cases the vector-size of finalParameters
>> will take the correct value.
>>
>>
>>
>>B) The value that you provided for the parameter[0]
>> doesn't correspond to 10 degrees. A Versors is
>> a unit quaternion. The magnitude of the three
>> versor components is equal to sin(angle/2).
>>
>> You probably computed
>>
>> parameter[0] = 0.174532 = sin( 10 )
>>
>> while you should do
>>
>> parameter[0] = 0.087155 = sin( 10 / 2 )
>>
>>
>>C) Yes there is a better way of initializing the transform.
>> Please look at the methods of the Versor class:
>>http://www.itk.org/Insight/Doxygen/html/classitk_1_1Versor.html
>>
>> You can simply do:
>>
>> TransformType::VersorType versor;
>> versor.SetRotationAroundX( 10.0 * PI / 180.0 );
>> transform->SetRotation( versor );
>>
>> or you could do
>>
>> TransformType::AxisType axis;
>> axis[0] = 1.0;
>> axis[1] = 0.0;
>> axis[2] = 0.0;
>>
>> transform->SetRotation( axis, 10.0 * PI / 180.0 );
>>
>>
>>
>>Please let us know if you have further questions,
>>
>>
>> Thanks
>>
>>
>> Luis
>>
>>
>>-------------------------------
>>Radhika Sivaramakrishna wrote:
>>
>>
>>>Hi Luis,
>>>I was trying to use the VersorRigid3DTransform to artificially transform
>
> a
>
>>>given image by 10 degrees about the center of the image only in the
>>>X-direction (ie no rotation in Y and Z) and no translation either. I am
>>>doing this to get a better understanding of this transform because I
>
> will
>
>>>need to use it to register a large number of unknown cases.
>
> Unfortunately, I
>
>>>am running into some problems.
>>>I modified the example in ImageRegistration8.cxx to do this.
>>>
>>>Here is what I did:
>>>
>>>I read in the fixed and moving image (in my case both are from the same
>>>file). Since no registration is required this time, I only defined a
>>>Transform of type VersorRigid3DTransform.
>>>
>>>I then set the finalparameters of my transform directly in the following
>>>way:
>>>
>>>TransformType::ParametersType finalParameters;
>>>
>>>
>>>
>>> finalParameters[0] = 0.174532;
>>> finalParameters[1] = 0;
>>> finalParameters[2] = 0;
>>> finalParameters[3] = 128.0;
>>> finalParameters[4] = 128.0;
>>> finalParameters[5] = 82;
>>> finalParameters[6] = 0;
>>> finalParameters[7] = 0;
>>> finalParameters[8] = 0;
>>>
>>>since I want a 10 degree rotation in X, my image is of size 256x256x164.
>>>
>>>I then did the usual resampling and casting to create my final image.
>>>However a memory error is reported when I try to set the finalParameters
>>>directly. Can you tell me what the problem is?
>>>
>>>Is there a better way of artificially creating a known transformation?
>>>
>>>Also, when I get to the actual image registration stage, what is the
>
> best
>
>>>optimizer for this transform? Is it the VersorTransformOptimizer?
>>>
>>>Thanks
>>>Radhika
>>>
>>>
>>>
>>
>>
>>
>
>
>