[Insight-users] Seg fault while using itkMutualInformationImageToImageMetric

Julien Jomier jjomier@cs.unc.edu
Fri, 31 Jan 2003 10:19:20 -0500


Hi Tuhin,

Try to replace params(i) and params(3)
by params[i] and params[3].

I know that the compiler accepts both but the correct way is to use [].

Let us know if that was the problem.

Thanks.

Julien

----- Original Message -----
From: <Tuhin>
To: <Insight-users@public.kitware.com>
Sent: Thursday, January 30, 2003 2:45 PM
Subject: [Insight-users] Seg fault while using
itkMutualInformationImageToImageMetric


> 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;
>   }
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
>