[Insight-users] Re: ImageToImageMetric--image similarity

Luis Ibanez luis.ibanez at kitware.com
Thu Aug 12 19:35:11 EDT 2004


Hi Nick,

 >
 > When running the test code, it has an
 > error at the last line: "Aborted",
 >


When you get an "Aborted" message, it usually means
that an exception has been thrown and you are not
catching it.

Please add try/catch blocks around the "Update()" methods
and print out the description returned by the eventual
exceptions.  You will find many examples on how to catch
exceptions in the ITK Software Guide

    http://www.itk.org/ItkSoftwareGuide.pdf


Regards,


    Luis



------------------------------------
Nick Hu wrote:

> Hi Luis,
> 
> According your answer long time agoabout using itkImageToImageMetric to
> calculate image similarity, I wrote a class which could read in two vtk
> images and then output the value of similarity.
> 
> The pseudo code of the class looks like:
> ###############
> //vtk-itk pipeline
> vtkImageExport exporter1, exporter2;
> exporter1->SetInput(vtkImage1)
> exporter1->SetInput(vtkImage1)
> 
> itkVTKImageImport importer1, importer2;
> 
> ConnectPipelines(exporter1, importer1);
> ConnectPipelines(exporter2, importer2);
> 
> //metric
> MutualInformationImageToImageMetric metric;
> IdentityTransform trans;
> NearestNeighborInterpolator interpolator;
> 
> metric->SetTransform;
> metric->SetInterpolator;
> metric->SetFixedImage(updated importer1->GetOutput)
> metric->SetMovingImage(updated importer2->GetOutput)
> metric->SetFixedImageRegion
> 
> metric->Initialize;
> dummyPosition;
> 
> return metric->GetValue(dummyPosition); (error is here)
> ################
> the test code is like:
> 
> vtkReader reader1, reader2;
> vtkImageCast cast1,cast2; (to float)
> vtkImageChangeInfomation reOrient1, reOrient2;
> 
> reader1 -->reOrient1 -->cast1;
> reader2 -->reOrient2 -->cast2;
> 
> similarityMetric metric;
> metric->SetSourceImage( updated cast1 output)
> metric->SetTargetImage( updated cast2 output)
> 
> metric->Update(); (error)
> 
> When running the test code, it has an error at the last line: "Aborted",
> which actually happened at line 97 at "itkImageToImageMetric.txx":
> "m_FixedImage->GetSource()".
> I found a piece of code you mentioned at
> http://public.kitware.com/pipermail/insight-users/2004-May/008511.html, and
> it worked when I tried on two png images. However, if I use
> itkRandomImageSource to create two images and then set them as inputs to the
> metric, I got the same error "Aborted" at "metric->GetValue()" .
> 
> I attached the whole package containing: test images-1.MR and 2.MR, the
> vtkITKImageToImageMetric class-vtkITKImageToImageMetric.cxx and .h, the test
> program-test.cxx and the CMake file. Would you please take a look ?
> I am using ITK 1.6 and vtk 4.2.6.
> Thank you.
> 
> Regards,
> 
> Nick






More information about the Insight-users mailing list