[Insight-users] How to use metrics for pixel difference of two pictures

soheilghafurian soheilghafurian at yahoo.com
Fri Oct 7 09:29:08 EDT 2011


Hi guys

This is the problem from my last topic, but because it got too long and I
thought I should make a new topic for that.

I want to calculate the pixel difference between two pictures using
MeaSquaresImageToImageMetric, but I get this runtime error:

Debug Error! 
This application has requested the Runtime to terminate it in an unusal way. 

Does anyone know what is wrong with my code? It would be great help for me.

here is the code ( the previous one + two new corrections you made) : 

#include "itkImage.h" 
#include "itkImageFileReader.h" 
#include <itkMeanSquaresImageToImageMetric.h>
#include <itkIdentityTransform.h>
  
#include "QuickView.h" 

using namespace std ; 
  
int main() 
{ 
  typedef itk::Image< double, 2 >         ImageType; 
  typedef itk::ImageFileReader<ImageType> ReaderType; 
  
  ReaderType::Pointer reader = ReaderType::New(); 
  reader->SetFileName("Image.png"); 
  reader->Update() ; 
  
  QuickView viewer; 
  viewer.AddImage<ImageType>(reader->GetOutput()); 
  

  ImageType::Pointer FixedImage = reader->GetOutput() ; 
  ImageType::Pointer MovingImage = reader->GetOutput() ; 

  typedef itk::MeanSquaresImageToImageMetric < ImageType , ImageType >
MetricType ; 
  typedef itk::IdentityTransform < double , 2 > TransformType ; 

  MetricType::Pointer metric = MetricType::New() ; 
  TransformType::Pointer transform = TransformType::New() ; 

  metric->SetFixedImage( FixedImage ) ; 
  metric->SetMovingImage( MovingImage ) ; 
  metric->SetTransform( transform ) ; 

  TransformType::ParametersType params ; 

  metric->Initialize() ; 
  cout<&lt;endl&lt;&lt; metric-&gt;GetValue( params ) << endl ; 

//  viewer.Visualize(); 
  
  return EXIT_SUCCESS; 
}

--
View this message in context: http://itk-insight-users.2283740.n2.nabble.com/How-to-use-metrics-for-pixel-difference-of-two-pictures-tp6869322p6869322.html
Sent from the ITK Insight Users mailing list archive at Nabble.com.


More information about the Insight-users mailing list