[Insight-users] question for itkMeanSquaresImageToImageMetric

Luis Ibanez luis.ibanez@kitware.com
Tue, 01 Apr 2003 10:55:41 -0500


Hi Zhiyong,


I see your point now,

You seem to be using a version of ITK previous to 1.2

Note that the movingImageTransform is not an identity
transform. It is an Affine transform contaning the origin
and spacing of the image. When you map the point through
this transform, you are doing the computation that you
just described in your message.

---

That being said,

This is done differently since version 1.2.
Images do not have internal transforms any more.

They now use the

 > TransformPhysicalPointToContinuousIndex()

as you suggested.

----

Please take a look at the code in version 1.2
or the cvs main trunk.


In any case, all the three versions are taking
spacing into account when they map the physical
point into the index.

---

itkSetMacro and itkGetMacro (as well as all the
other ITK macros) are defined in:

   Insight/Code/Common/itkMacro.h

You shouldn't care about the Macros, they generate
most of  the Get Set methods in the classes. The
actual name of the methods appear in the Doxygen
documentation.


----


Regards




    Luis




------------------------------
Zhiyong Xie wrote:
 > Luis:
 >
 > Thanks for your answer. I am still confused about this code.
 > Suppose a 2D image spacing is (0.6, 0.6), origin is (3, 4).
 > The coordinate of pixel (2, 2) will be (3+2*0.6, 4+2*0.6)=(4.2, 5.2).
 > It keeps untouch after identity transform. With this code, the
 > closest pixel on gradient image is (4, 5), instead of  (2, 2).
 > Is this correct? Why not use the function "TransformPhysicalPointToIndex
 > <http://www.itk.org/Doxygen/html/classitk_1_1Image.html#a16> "
 > for this purpose?
 >
 > BTW, where I can find the definition of "itkSet(or Get)ObjectMacro"?
 > I can only guess what it does. also, I am not sure when I can use it and
 > when I should define my own function to get/set the pointer to object.
 >
 > Thanks
 >
 > Sean
 >
 >
 > Luis Ibanez wrote:
 >
 >> Hi Sean,
 >>
 >>
 >> Short answer:
 >>
 >>    Yes, the MeanSquaresImageToImageMetric
 >>    does take into account the image spacing.
 >>
 >>
 >>
 >> Long answer:
 >>
 >> The MeanSquaresImageToImageMetric obtains the derivative of the
 >> metric by multiplying the gradient of the image with the jacobian
 >> of the transformation.
 >>
 >> The gradient of the image is computed using the
 >>
 >>        GradientRecursiveGaussianImageFilter
 >>
 >> This filter takes into account the image spacing when it is
 >> computing the gradient.  Henceforth the image spacing is propagated
 >> to the MetricDerivative.
 >>
 >> The particular piece of code that you refer is simply finding
 >> the closest pixel in the gradient image, to the point mapped
 >> by the transform.
 >>
 >>
 >>  Regards,
 >>
 >>
 >>    Luis
 >>
 >>
 >> ---------------------------------------------------------
 >> Zhiyong Xie wrote:
 >>
 >>> I got a question for source code of
 >>> itkMeanSquaresImageToImageMetric.txx.
 >>> In function GetDerivative and GetValueAndDerivative, the index of
 >>> gradient
 >>> image was computed as follows:
 >>> /**** source code*/
 >>> typename Superclass::OutputPointType tempPoint =
 >>>               movingImageTransform->TransformPoint( transformedPoint );
 >>>
 >>>      typename MovingImageType::IndexType mappedIndex;
 >>>      for( unsigned int j = 0; j < MovingImageType::ImageDimension; 
j++ )
 >>>        {
 >>>        mappedIndex[j] = static_cast<long>( vnl_math_rnd( tempPoint[j]
 >>> ) );
 >>>        }
 >>>
 >>>      const GradientPixelType gradient =
 >>>                                m_GradientImage->GetPixel( 
mappedIndex );
 >>>
 >>> /***  *  */
 >>>
 >>> If the image spacing is not 1 (say 0.8), doese it generate correct
 >>> result?
 >>>
 >>> Thanks
 >>>
 >>> Sean
 >>>
 >>>
 >>> _______________________________________________
 >>> Insight-users mailing list
 >>> Insight-users@public.kitware.com
 >>> http://public.kitware.com/mailman/listinfo/insight-users
 >>>
 >>
 >>
 >