[Insight-users] Seg fault while using itkMutualInformationImageToImageMetric
Tuhin
Thu, 30 Jan 2003 13:45:13 -0600
Hello all,
I am trying to use the itkMutualInformationImageToImageMetric class to
calculate the mutual information between two images. I don't want to
register the images using itk, I just want the mutual information. I have
tried to get the following code to run on a Linux box with last night's itk
source and I get a seg-fault (no exception is raised) at the last line in the
try block. Any regarding my issue would be appreciated.
TIA,
Tuhin
//My typedefs
typedef itk::Image<unsigned char,3> ImageType;
typedef itk::MutualInformationImageToImageMetric<ImageType,ImageType>
MetricType;
typedef itk::QuaternionRigidTransform<double> TransformType;
typedef itk::ImageRegistrationMethod<ImageType,ImageType> RegistrationType;
//Set up the ITK MutualInformation calculator
MetricType::Pointer mi = MetricType::New();
MetricType::ParametersType params;
TransformType::Pointer transform = TransformType::New();
RegistrationType::Pointer reg = RegistrationType::New();
try {
mi->SetMovingImageStandardDeviation(1);
mi->SetFixedImageStandardDeviation(1);
mi->SetNumberOfSpatialSamples(50);
reg->SetMetric(mi);
reg->SetTransform(transform);
reg->SetFixedImage(orig_imp->GetOutput());
reg->SetMovingImage(defo_imp->GetOutput());
params.resize(7);
for(int i = 0; i < 7; i++) {
params(i) = 0;
}
params(3) = 1;
cout << mi->GetValue(params) << endl;
}
catch (itk::ExceptionObject &e) {
cout << "Exception detected: " << e;
return -1;
}