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

Nick Hu nhu at sten.sunnybrook.utoronto.ca
Fri Aug 13 10:34:07 EDT 2004


Hi Luis,

Your advice is very helpful. I added try/catch and the error message is
pretty straightforward:
"
itk::ERROR:MUtualInformationImageToImageMetric: Standard deviation is too
small
"
I changed the standard deviation from the default 0.4 to 2.0 and it works. I
checked the manual and it says the standard deviation of 0.4 works well for
normalized images. Does it mean it is better to normalize the image before
using this metric, instead of trying different SD values for different
images?

Thank you very much for your help!

Regards,
NIck
----- Original Message ----- 
From: "Luis Ibanez" <luis.ibanez at kitware.com>
To: "Nick Hu" <nhu at sten.sunnybrook.utoronto.ca>
Cc: <insight-users at itk.org>
Sent: Thursday, August 12, 2004 7:35 PM
Subject: Re: ImageToImageMetric--image similarity


> 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