[Insight-users] An exception about the Mutual information metric
Fang-Chuan Wu
wfc93 at cs.ccu.edu.tw
Tue Mar 29 02:38:12 EST 2005
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
More information about the Insight-users
mailing list