As I understand the metric is calculated using the fixedImage, movingImage and the current transform parameters based on the following approach:<br><br>1) Apply transform parameters to the movingImage (transform moving image into the fixed image space, itkSoftwareGuide Figure 8.43 page 410 [*] ).<br>
<br>2) Run through the fixed and moving image indicies and sum the intensity difference.<br><br>But when I look into the code of:<br><br>itkMeanSquaresImageToImageMetric.txx<br><br>it seems that its not how its done.<br><br>
The function:<br><br>GetValueAndDerivative(const TransformParametersType & parameters, <br> MeasureType & value, DerivativeType & derivative) const<br><br>computes the metric value and the gradient. Its basically done by running through the fixed image and summing the difference between the fixed image values and the transformed fixed image values:<br>
<br><br> const RealType diff = movingValue - fixedValue; <br> measure += diff * diff;<br><br><br><br>where:<br><br> OutputPointType transformedPoint = this->m_Transform->TransformPoint( inputPoint ); // Using the current fixed image inputPoint<br>
const RealType movingValue = this->m_Interpolator->Evaluate( transformedPoint );<br> const RealType fixedValue = ti.Value(); // The current value of the pixel in the fixed image.<br><br>As I understand the current transform parameters are applied to the fixed image and the corresponding transformed pixel value is computed. So the 'measure' is actually the difference between the fixed and the transformed fixed image:<br>
<br>1) measure = fixed - T(fixed)<br><br><br>But should the metric not be computed between the fixed and the transformed Moving image as described in the itkSoftwawreGuide:<br><br>2) measure = fixed - T(moving)<br><br>?<br>
<br><br><br><br><br><br>* Caption Figure 8.43:<br><br>"The moving image is mapped into the fixed image space under some spatial transformation.<br>An iterator walks through the fixed image and its coordinates are mapped onto the moving image."<br>
<br>Later on the same page:<br><br>"Figure 8.43 (left) illustrates the mapping of the fixed image space onto the moving image space.<br>The transform maps points from the fixed image coordinate system onto the moving image coordinate system"<br>
<br><br>I assume that the second quote is similar to the implementation, but I still don't see how that is correct.<br><br><br><br><br><br><br><br><br><br><br><br><br> while(!ti.IsAtEnd())<br> {<br><br> index = ti.GetIndex();<br>
<br> InputPointType inputPoint;<br> fixedImage->TransformIndexToPhysicalPoint( index, inputPoint );<br><br> if( this->m_FixedImageMask && !this->m_FixedImageMask->IsInside( inputPoint ) )<br>
{<br> ++ti;<br> continue;<br> }<br><br> OutputPointType transformedPoint = this->m_Transform->TransformPoint( inputPoint );<br><br> if( this->m_MovingImageMask && !this->m_MovingImageMask->IsInside( transformedPoint ) )<br>
{<br> ++ti;<br> continue;<br> }<br><br> if( this->m_Interpolator->IsInsideBuffer( transformedPoint ) )<br> {<br> const RealType movingValue = this->m_Interpolator->Evaluate( transformedPoint );<br>
<br> const TransformJacobianType & jacobian =<br> this->m_Transform->GetJacobian( inputPoint ); <br><br> <br> const RealType fixedValue = ti.Value();<br> this->m_NumberOfPixelsCounted++;<br>
<br> const RealType diff = movingValue - fixedValue; <br>