[Insight-users] Re: VersorRigid3DTransform

Radhika Sivaramakrishna Radhika Sivaramakrishna" <radshashi at earthlink.net
Wed, 31 Dec 2003 15:52:08 -0800


This is a multi-part message in MIME format.

------=_NextPart_000_003D_01C3CFB6.0B9DBBF0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hi Luis,
Thanks for the explanation. I will look at the Doxygen documentation. I had
the following problem. I ran the VersorRigid3DTransform example
(ImageRegistration8.cxx) on my pair of images (one rotated by 10 degrees
w.r.t the other as I explained in my previous mail). After 24 iterations, it
gave the following exception error. I have enclosed the results obtained, in
my attachment. Please could you tell me what hte problem is.
Thanks
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 3:29 PM
Subject: Re: VersorRigid3DTransform


>
> 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
> >>>
> >>>
> >>>
> >>
> >>
> >>
> >
> >
> >
>
>
>

------=_NextPart_000_003D_01C3CFB6.0B9DBBF0
Content-Type: text/plain;
	name="results.txt"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="results.txt"

0   1.07377e+009   [0.000696933, 0.000757833, -0.00398539, 126.627, =
134.659, 87.
7664, -0.874226, 7.09041, 6.20345]
1   1.07377e+009   [0.00163943, 0.00146432, -0.00864709, 126.627, =
134.658, 87.76
7, -0.874207, 7.01599, 6.13683]
2   1.07377e+009   [0.00277315, 0.0022942, -0.0134934, 126.627, 134.657, =
87.7685
, -0.87421, 6.94132, 6.07054]
3   1.07377e+009   [0.00469267, 0.00349103, -0.0188727, 126.627, =
134.655, 87.770
8, -0.874252, 6.86723, 6.0037]
4   1.07377e+009   [0.00764075, 0.00488291, -0.0249502, 126.627, =
134.652, 87.774
1, -0.874374, 6.79243, 5.93784]
5   1.07377e+009   [0.0120025, 0.00631338, -0.031587, 126.627, 134.648, =
87.7786,
 -0.874693, 6.71738, 5.87252]
6   1.07377e+009   [0.0187473, 0.0078992, -0.0387002, 126.627, 134.643, =
87.7847,
 -0.875401, 6.64219, 5.80784]
7   1.07377e+009   [0.0290275, 0.00942788, -0.046004, 126.627, 134.636, =
87.7925,
 -0.876829, 6.56736, 5.74352]
8   1.07377e+009   [0.0448596, 0.0111416, -0.0538625, 126.627, 134.629, =
87.8028,
 -0.879396, 6.49222, 5.68131]
9   1.07377e+009   [0.0677921, 0.0129146, -0.0624039, 126.627, 134.62, =
87.8158,
-0.883947, 6.41885, 5.62007]
10   1.07377e+009   [0.0986932, 0.0146444, -0.0713277, 126.627, 134.61, =
87.8307,
 -0.891966, 6.35132, 5.55672]
11   1.07377e+009   [0.139157, 0.0163247, -0.0797897, 126.627, 134.599, =
87.8473,
 -0.904535, 6.29018, 5.49361]
12   1.07377e+009   [0.189681, 0.0174957, -0.0878074, 126.627, 134.586, =
87.8667,
 -0.922579, 6.23602, 5.43373]
13   1.07377e+009   [0.249883, 0.0181283, -0.0951621, 126.627, 134.573, =
87.8944,
 -0.945493, 6.18663, 5.38455]
14   1.07379e+009   [0.318978, 0.0182499, -0.10179, 126.627, 134.561, =
87.9414, -
0.968088, 6.14417, 5.36184]
15   1.0738e+009   [0.391643, 0.0184017, -0.107387, 126.627, 134.55, =
87.9934, -0
.991275, 6.10899, 5.3519]
16   1.07381e+009   [0.464827, 0.0186431, -0.1118, 126.627, 134.543, =
88.0517, -1
.00886, 6.08076, 5.35941]
17   1.07381e+009   [0.538336, 0.0189457, -0.115323, 126.627, 134.538, =
88.1115,
-1.02131, 6.05764, 5.3767]
18   1.0738e+009   [0.61357, 0.0192276, -0.11817, 126.627, 134.533, =
88.1697, -1.
03154, 6.03774, 5.39725]
19   1.0738e+009   [0.694608, 0.0193823, -0.120598, 126.627, 134.529, =
88.2206, -
1.0439, 6.01821, 5.41428]
20   1.0738e+009   [0.78022, 0.0197561, -0.123375, 126.627, 134.526, =
88.2647, -1
.05388, 5.99989, 5.43077]
21   1.07379e+009   [0.870308, 0.0206595, -0.126552, 126.627, 134.525, =
88.3013,
-1.05613, 5.98464, 5.44784]
22   1.0738e+009   [0.964428, 0.0221835, -0.130543, 126.627, 134.526, =
88.3265, -
1.04417, 5.97459, 5.46345]
23   1.07381e+009   [1.06033, 0.0236213, -0.134485, 126.627, 134.53, =
88.3299, -1
.01757, 5.96899, 5.46815]
ExceptionObject caught !

itk::ExceptionObject (00F3FC70)
Location: "itk::Versor::Set( const VectorType )"
File: Unknown
Line: 0
Description: Trying to initializa a Versor witha vector whose magnitude =
is great
er than 1 
------=_NextPart_000_003D_01C3CFB6.0B9DBBF0--