<div>I lost track of your exact problem, but it looks like you need to 1) update the reader, i.e., </div><div><br></div><div>reader->SetFileName("Image.png");</div><div>reader->Update();</div><div><br></div>
<div>and 2) initialize the metric, i.e.,</div><div><br></div><div>metric->Initialize();</div><div>cout<<endl<< metric->GetValue( params ) << endl ;<br><br><div class="gmail_quote">On Tue, Oct 4, 2011 at 8:24 PM, soheilghafurian <span dir="ltr"><<a href="mailto:soheilghafurian@yahoo.com">soheilghafurian@yahoo.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Cory<br>
<br>
Thanks a lot for your time and consideration. In order to test it, I wrote a<br>
one page code, and it has the same problem. Here is my code. I think there<br>
is a part that should be added, but I don't know what it is.<br>
<br>
#include "itkImage.h"<br>
#include "itkImageFileReader.h"<br>
#include <itkMeanSquaresImageToImageMetric.h><br>
#include <itkIdentityTransform.h><br>
<br>
#include "QuickView.h"<br>
<br>
using namespace std ;<br>
<br>
int main()<br>
{<br>
typedef itk::Image< double, 2 > ImageType;<br>
typedef itk::ImageFileReader<ImageType> ReaderType;<br>
<br>
ReaderType::Pointer reader = ReaderType::New();<br>
reader->SetFileName("Image.png");<br>
<br>
QuickView viewer;<br>
viewer.AddImage<ImageType>(reader->GetOutput());<br>
<br>
<br>
ImageType::Pointer FixedImage = reader->GetOutput() ;<br>
ImageType::Pointer MovingImage = reader->GetOutput() ;<br>
<br>
typedef itk::MeanSquaresImageToImageMetric < ImageType , ImageType ><br>
MetricType ;<br>
typedef itk::IdentityTransform < double , 2 > TransformType ;<br>
<br>
MetricType::Pointer metric = MetricType::New() ;<br>
TransformType::Pointer transform = TransformType::New() ;<br>
<br>
metric->SetFixedImage( FixedImage ) ;<br>
metric->SetMovingImage( MovingImage ) ;<br>
metric->SetTransform( transform ) ;<br>
<br>
TransformType::ParametersType params ;<br>
<br>
cout<<endl<< metric->GetValue( params ) << endl ;<br>
<br>
viewer.Visualize();<br>
<br>
return EXIT_SUCCESS;<br>
}<br>
<br>
--<br>
View this message in context: <a href="http://itk-insight-users.2283740.n2.nabble.com/Pixel-difference-between-two-images-tp6832343p6860559.html" target="_blank">http://itk-insight-users.2283740.n2.nabble.com/Pixel-difference-between-two-images-tp6832343p6860559.html</a><br>
Sent from the ITK Insight Users mailing list archive at Nabble.com.<br>
_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</blockquote></div><br></div>