[Insight-users] Re: VersorRigid3DTransform
Luis Ibanez
luis.ibanez at kitware.com
Wed, 31 Dec 2003 14:42:56 -0500
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
>
>
>