hi,
<div><br></div><div>I run ImageRegistration7 example in ITK.</div><div>and the output like following</div><div>-------------------------------------</div><div><div> Scale = 1.08438</div><div> Angle (radians) 0.154531</div>
<div> Angle (degrees) 8.85397</div><div> Center X = 170.327</div><div> Center Y = 148.556</div><div> Translation X = -26.6822</div><div> Translation Y = -93.4428</div><div> Iterations = 500</div><div> Metric value = 4551.86</div>
<div>---------------------------------------</div><div><br></div><div>I made a program in which i use a same metric, transformation, interpolate object type as above example, with same two input image file. I set above value to calculate metric value directly from metric object, but the result is not same as what the example made..</div>
<div><br></div><div>here is the code, did i miss something? </div><div>I'm running out of time! really appreciate any help!</div><div><br></div><div>-------------------------------------------------------------------------</div>
<div>int main( int argc, char * argv[] )</div><div><div>{</div><div><span style="white-space:pre">        </span>const unsigned int Dimension = 2;</div>
<div><span style="white-space:pre">        </span>typedef unsigned char PixelType;</div><div><span style="white-space:pre">        </span>typedef itk::Image< PixelType, Dimension > ImageType;</div>
<div><span style="white-space:pre">        </span>typedef itk::ImageFileReader< ImageType > ReaderType;</div><div><br></div><div><span style="white-space:pre">        </span>ReaderType::Pointer fixedReader = ReaderType::New();</div>
<div><span style="white-space:pre">        </span>ReaderType::Pointer movingReader = ReaderType::New();</div><div><br></div><div><span style="white-space:pre">        </span>fixedReader->SetFileName( "fixed.bmp" );</div>
<div><span style="white-space:pre">        </span>movingReader->SetFileName( "moving.bmp" );</div><div><br></div><div>
<span style="white-space:pre">        </span>try </div><div><span style="white-space:pre">        </span>{</div><div><span style="white-space:pre">                </span>fixedReader->Update();</div>
<div><span style="white-space:pre">                </span>movingReader->Update();</div><div><span style="white-space:pre">        </span>}</div><div><span style="white-space:pre">        </span>catch( itk::ExceptionObject & excep )</div>
<div><span style="white-space:pre">        </span>{</div><div><span style="white-space:pre">                </span>std::cerr << "Exception catched !" << std::endl;</div><div>
<span style="white-space:pre">                </span>std::cerr << excep << std::endl;</div><div><span style="white-space:pre">        </span>}</div><div><br></div><div><span style="white-space:pre">        </span>typedef itk::MeanSquaresImageToImageMetric< ImageType, ImageType > MetricType;</div>
<div><span style="white-space:pre">        </span>MetricType::Pointer metric = MetricType::New();</div><div><br></div><div><span style="white-space:pre">        </span>typedef itk::CenteredSimilarity2DTransform < double > TransformType;</div>
<div><span style="white-space:pre">        </span>TransformType::Pointer transform = TransformType::New();</div>
<div><br></div><div><span style="white-space:pre">        </span>typedef itk::LinearInterpolateImageFunction< ImageType, double > InterpolatorType;</div>
<div><span style="white-space:pre">        </span>InterpolatorType::Pointer interpolator = InterpolatorType::New();</div><div><br></div><div><span style="white-space:pre">        </span>ImageType::Pointer fixedImage = fixedReader->GetOutput();</div>
<div><span style="white-space:pre">        </span>ImageType::Pointer movingImage = movingReader->GetOutput();</div><div><br></div><div><span style="white-space:pre">        </span>typedef itk::CenteredTransformInitializer< TransformType, ImageType, ImageType > TransformInitializerType;</div>
<div><span style="white-space:pre">        </span>TransformInitializerType::Pointer initializer = TransformInitializerType::New();</div><div><br></div><div><span style="white-space:pre">        </span>initializer->SetTransform( transform );</div>
<div><span style="white-space:pre">        </span>initializer->SetFixedImage( fixedImage );</div><div><span style="white-space:pre">        </span>initializer->SetMovingImage( movingImage );</div>
<div><span style="white-space:pre">        </span>initializer->MomentsOn();</div><div><span style="white-space:pre">        </span>initializer->InitializeTransform();</div><div><br></div><div><span style="white-space:pre">        </span>metric->SetTransform( transform );</div>
<div><span style="white-space:pre">        </span>metric->SetInterpolator( interpolator );</div>
<div><span style="white-space:pre">        </span>metric->SetFixedImage( fixedImage );</div><div><span style="white-space:pre">        </span>metric->SetMovingImage( movingImage );</div>
<div><span style="white-space:pre">        </span>metric->SetFixedImageRegion( fixedImage->GetBufferedRegion() );</div><div><br></div><div><span style="white-space:pre">        </span>try </div>
<div><span style="white-space:pre">        </span>{</div><div><span style="white-space:pre">                </span>metric->Initialize();</div><div><span style="white-space:pre">        </span>}</div>
<div><span style="white-space:pre">        </span>catch( itk::ExceptionObject & excep )</div><div><span style="white-space:pre">        </span>{</div><div><span style="white-space:pre">                </span>std::cerr << "Exception catched !" << std::endl;</div>
<div><span style="white-space:pre">                </span>std::cerr << excep << std::endl;</div><div><span style="white-space:pre">                </span>return EXIT_FAILURE;</div><div><span style="white-space:pre">        </span>}</div>
<div><span style="white-space:pre">        </span></div><div><span style="white-space:pre">        </span></div><div><span style="white-space:pre">        </span>transform->SetScale(1.08438);</div>
<div><span style="white-space:pre">        </span>transform->SetAngle(8.85397);</div><div><span style="white-space:pre">        </span>TransformType::TranslationType translation;</div><div>
<span style="white-space:pre">        </span>translation[0] = -26.6822;</div><div><span style="white-space:pre">        </span>translation[1] = -93.6822;</div><div><br></div><div><span style="white-space:pre">        </span>MetricType::TransformParametersType transformParams = transform->GetParameters();</div>
<div><br></div><div><span style="white-space:pre">        </span>double metricval = metric->GetValue(transformParams);</div><div><span style="white-space:pre">        </span></div><div><span style="white-space:pre">        </span>return EXIT_SUCCESS;</div>
<div>}</div><div><br></div></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div>