[ITK] Bug in Mattes Mutual information

Lowekamp, Bradley (NIH/NLM/LHC) [C] blowekamp at mail.nih.gov
Mon Jan 23 08:58:36 EST 2017


Hello,

This most common mistake would be that the input images are not “Updated”.

If you are using ImageFileReader to read the images you should call “Update” before any of the code below.

HTH,
Brad

> On Jan 21, 2017, at 2:11 PM, Constantinus Spanakis <c.spanakis83 at gmail.com> wrote:
> 
> Hello. I want to calculate Mattes mutual information of two images. I created a mattes metric
> 
>   metric = MetricType::New();
> 
>   metric->SetTransform(rigidtransform);
> 
>   metric->SetUseAllPixels(true);
>   
>   
>   
>   const unsigned int numberOfParameters = rigidtransform->GetNumberOfParameters();
>   
>   
>   metric->SetFixedImage(fixedImage);
>   metric->SetMovingImage(movingImage);
>   metric->SetFixedImageRegion(fixedImage->GetLargestPossibleRegion());
>   metric->SetNumberOfFixedImageSamples(10000);
>   metric->SetNumberOfHistogramBins(50);
>   metric->SetNumberOfSpatialSamples(10000);
>   metric->SetNumberOfThreads(12);
> 
> 
> I set metric from the begining as a global variable. Then I wrote a function called
> 
> MetricType::MeasureType test(double *arg ){
> 	//printf("test\n");
> 	MetricType::MeasureType v;
> 	int i;
> 	double a, e, f;
> 	a = arg[0];
> 
> 	e = arg[1];
> 	f = arg[2];
> 	rigidtransform->SetAngle(a);
> 	RigidTransformType::OutputVectorType t = rigidtransform->GetTranslation();
> 	t[0] = e;
> 	t[1] = f;
> 	rigidtransform->SetTranslation(t);
> 	
> 	metric->UseAllPixelsOn();
> 	metric->SetTransform(rigidtransform);
> 	
> 	
> 	
> 	
> 	try{
> 		v = metric->GetValue(rigidtransform->GetParameters());
> 	}
> 	catch (itk::ExceptionObject & err){
> 		
> 			
> 		v = 1;
> 	}
> 	
> 	
> 
> 	return v;
> }
> 
> Whenever I call the test function test with arguments:
> 
> double p[3];
>   p[0] = 0;
>   p[1] = 0;
>   p[2] = 0;
> 
> The programm shows an unhandled exception due to Access Violation reading, which doesn't make sense. What could be the problem?
> 
> Thanks in advance
> _______________________________________________
> Community mailing list
> Community at itk.org
> http://public.kitware.com/mailman/listinfo/community



More information about the Community mailing list