<div>HI again,</div>
<div>For some reason, my message was discarded when I sent it to the mailing list the first time. I am sending it again. The two images can be found:</div>
<div><a href="http://www.stanford.edu/~mingchao/image/fixedImage.vtk">http://www.stanford.edu/~mingchao/image/fixedImage.vtk</a></div>
<div>and </div>
<div><a href="http://www.stanford.edu/~mingchao/image/movingImage16.vtk">http://www.stanford.edu/~mingchao/image/movingImage16.vtk</a></div>
<div> </div>
<div> </div>
<div>Hi,</div>
<div> </div>
<div>I followed a standard procedure to calculate the metric between two images. However, I encountered a problem. Bascally I have two images which are subregions of a big image. When I calculate the metric between these two smaller images, the metric value is always -1 (I am using Normalized Correlation Metric). The code is attached to the end of this message. And the two images are attached as well. I don't understand what is wrong.
</div>
<div>Thanks,</div>
<div>Ming</div>
<div> </div>
<div>
<p>#include "itkImage.h"<br>#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"<br>#include "itkMeanSquaresImageToImageMetric.h"<br>#include "itkNormalizedCorrelationImageToImageMetric.h
"<br>#include "itkTranslationTransform.h"<br>#include "itkNearestNeighborInterpolateImageFunction.h"<br>#include "itkLinearInterpolateImageFunction.h"</p>
<p><br>int main( int argc, char * argv[] )<br>{<br> if( argc < 3 )<br> {<br> std::cerr << "Usage: " << std::endl;<br> std::cerr << argv[0] << " fixedImage movingImage" << std::endl;
<br> return 1;<br> }</p>
<p> const unsigned int Dimension = 2;<br> //typedef unsigned char PixelType;<br> typedef float PixelType;</p>
<p> typedef itk::Image< PixelType, Dimension > ImageType;<br> typedef itk::Image< PixelType, Dimension > ImageType;</p>
<p><br> typedef itk::ImageFileReader< ImageType > ReaderType;</p>
<p> ReaderType::Pointer fixedReader = ReaderType::New();<br> ReaderType::Pointer movingReader = ReaderType::New();</p>
<p> fixedReader->SetFileName( argv[ 1 ] );<br> movingReader->SetFileName( argv[ 2 ] );</p>
<p> try <br> {<br> fixedReader->Update();<br> movingReader->Update();<br> }<br> catch( itk::ExceptionObject & excep )<br> {<br> std::cerr << "Exception catched !" << std::endl;
<span></span> <br> std::cerr << excep << std::endl;<br> }</p>
<p> typedef itk::NormalizedCorrelationImageToImageMetric< ImageType, ImageType > MetricType;</p>
<p> MetricType::Pointer metric = MetricType::New();</p>
<p> </p>
<p> typedef itk::TranslationTransform< double, Dimension > TransformType;</p>
<p> TransformType::Pointer transform = TransformType::New();</p>
<p> </p>
<p> typedef itk::NearestNeighborInterpolateImageFunction< <br> ImageType, double > InterpolatorType;</p>
<p> InterpolatorType::Pointer interpolator = InterpolatorType::New();</p>
<p> typedef TransformType::ParametersType ParametersType;<br> ParametersType displacement( transform->GetNumberOfParameters() );<br> displacement.Fill( 0.0 );</p>
<p> metric->SetInterpolator( interpolator );<br> metric->SetTransform( transform );</p>
<p> //transform->SetIdentity();</p>
<p> ImageType::ConstPointer fixedImage = fixedReader->GetOutput();<br> ImageType::ConstPointer movingImage = movingReader->GetOutput();</p>
<p> metric->SetFixedImage( fixedImage );<br> metric->SetMovingImage( movingImage );</p>
<p> metric->SetFixedImageRegion( fixedImage->GetBufferedRegion() );</p>
<p> try <br> {<br> metric->Initialize();<br> }<br> catch( itk::ExceptionObject & excep )<br> {<br> std::cerr << "Exception catched !" << std::endl;<br> std::cerr << excep << std::endl;
<br> return -1;<br> }</p>
<p> const double value = metric->GetValue( displacement );</p>
<p> std::cout << "metric value == " << value << std::endl;<br> std::cout << "displacement = " << displacement << std::endl;</p>
<p> return 0;<br>}<br></p></div><span></span><br clear="all">