[Insight-users] An exception about the Mutual information metric
Luis Ibanez
luis.ibanez at kitware.com
Tue Mar 29 11:24:22 EST 2005
Hi Fang,
You get this exception because your current transform is so far off
that the mapped moving image and the fixed image end up having a
minimal overlap.
You must check the origin and spacing of both your Fixed and Moving
images and verify if they have any overlap when you use an identity
transform.
From there you should make sure that the transform is not going too
far from the overlapping position.
Regards,
Luis
--------------------------------------
Fang-Chuan Wu wrote:
> Hello,
>
> I want to compute the value of an image metric by using Mattes Mutual
> Information metric.
>
> When I executed my program, it catches the exception as following:
>
> ---
> Exception catched !
>
> itk::ExceptionObject (0xa05aa88)
> Location: "Unknown"
> File:
> /cygdrive/d/workspace/Insight/Code/Algorithms/itkMattesMutualInformationImageToImageMetric.txx
>
> Line: 705
> Description: itk::ERROR:
> MattesMutualInformationImageToImageMetric(0xa056780): Too many samples
> map outside moving image buffer: 0 / 100000
> --
>
>
> The codes I written as following, as fixed image and moving image are:
> Insight/Examples/Data/BrainT1Slice.png
> Insight/Examples/Data/BrainProtonDensitySlice.png
>
> ---
> #include "metricPlot.h"
>
>
> int main( int argc, char * argv[] )
> {
> if( argc < 3 )
> {
> std::cerr << "Usage: " << std::endl;
> std::cerr << argv[0] << " fixedImage movingImage" << std::endl;
> return 1;
> }
>
>
> ReaderType::Pointer fixedReader = ReaderType::New();
> ReaderType::Pointer movingReader = ReaderType::New();
> MetricType::Pointer metric = MetricType::New();
> TransformType::Pointer transform = TransformType::New();
> InterpolatorType::Pointer interpolator = InterpolatorType::New();
> MetricType::TransformParametersType translation( Dimension );
>
> fixedReader->SetFileName( argv[ 1 ] );
> movingReader->SetFileName( argv[ 2 ] );
>
> try
> {
> fixedReader->Update();
> movingReader->Update();
> }
> catch( itk::ExceptionObject & excep )
> {
> std::cerr << "Exception catched !" << std::endl;
> std::cerr << excep << std::endl;
> }
>
> metric->SetInterpolator( interpolator );
> metric->SetTransform( transform );
>
> metric->SetNumberOfHistogramBins( 20 );
> metric->SetNumberOfSpatialSamples( 100000 );
> transform->SetIdentity();
>
> ImageType::ConstPointer fixedImage = fixedReader->GetOutput();
> ImageType::ConstPointer movingImage = movingReader->GetOutput();
>
> //fixedReader->GetOutput()->Print(std::cout);
> //movingReader->GetOutput()->Print(std::cout);
>
> metric->SetFixedImage( fixedImage );
> metric->SetMovingImage( movingImage );
>
> metric->SetFixedImageRegion( fixedImage->GetBufferedRegion() );
>
> try {
> metric->Initialize();
> }
> catch( itk::ExceptionObject & excep ) {
> std::cerr << "Exception catched !" << std::endl;
> std::cerr << excep << std::endl;
> return -1;
> }
>
> for(int dx=-20; dx<20; dx++){
> translation[0]=dx;
> try{
> std::cout<<dx<<" "<<metric->GetValue( translation )<<std::endl;
> }
> catch( itk::ExceptionObject & excep ){
> std::cerr << "Exception catched !" << std::endl;
> std::cerr << excep << std::endl;
> return -1;
> }
> }
>
> return 0;
> }
> ---
>
> Does anyone knows why I get the exception?
>
>
> Thanks in advace.
>
> Regards,
> Benny
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>
>
More information about the Insight-users
mailing list