[Insight-users] Compare images by mean square difference

Marta t_s_80 at gmx.de
Fri Jan 30 05:35:30 EST 2009


Thanks a lot for looking over my code! I checked the images, and they  
have been filled with data. However, I figured out, that the rescaling  
is the reason for the high values ( even if I don't understand why ).  
It's working fine, if I use the original images.

Am 29.01.2009 um 20:42 schrieb Bill Lorensen:

> Your code looks OK. Are you sure that the two images have been  
> filled with data?
>
> On Thu, Jan 29, 2009 at 9:25 AM,  <t_s_80 at gmx.de> wrote:
>> Hello,
>>
>> I simply want to compare two images (without registration) by mean  
>> square value. All I have found to do so, is the  
>> MeanSquaresImageToImageMetric that is also used for
>> registration. Is it correct to use it also in my case?
>>
>> I wrote a method (you can see below) that get two identical images,  
>> apart from the image content (same size, same spacing, same origin).
>> It is working, but the results can't be right. The values are very  
>> large, even if the content of the images is equal. What is wrong  
>> with my method? Did I forget something?
>> Or is it wrong to use the Metric this way?
>>
>> Thanks a lot for your help,
>> Marta
>>
>> --------------------------------------------------------------------------------------------------------------------
>>
>> void  
>> THIS::calculateMeanSquaresErrorBetweenImages( ImageType::Pointer  
>> image1, ImageType::Pointer image2 ) {
>>
>>       /*
>>       //This part is actually in the header:
>>       int Dimension = 2;
>>       typedef unsigned short InputPixelType;
>>       typedef unsigned short OutputPixelType;
>>       typedef itk::Image< InputPixelType, Dimension > ImageType;
>>       typedef itk::Image< OutputPixelType, Dimension >  
>> OutputImageType;
>>       typedef itk::RescaleIntensityImageFilter< ImageType,  
>> OutputImageType > RescaleFilterType;*/
>>
>>       typedef itk::MeanSquaresImageToImageMetric< OutputImageType,  
>> OutputImageType > MetricType;
>>       typedef itk::LinearInterpolateImageFunction< OutputImageType  
>> > LinearInterpolatorType;
>>       typedef itk::CenteredRigid2DTransform< double > TransformType;
>>
>>       RescaleFilterType::Pointer rescaler1 =  
>> RescaleFilterType::New( );
>>       RescaleFilterType::Pointer rescaler2 =  
>> RescaleFilterType::New( );
>>
>>       rescaler1->SetOutputMinimum(   0 );
>>       rescaler1->SetOutputMaximum( 65535 );
>>
>>       rescaler2->SetOutputMinimum(   0 );
>>       rescaler2->SetOutputMaximum( 65535 );
>>
>>       rescaler1->SetInput( image1 );
>>       rescaler2->SetInput( image2 );
>>
>>       LinearInterpolatorType::Pointer interpolator =  
>> LinearInterpolatorType::New( );
>>
>>       OutputImageType::Pointer image1 = rescaler1->GetOutput( );
>>       OutputImageType::Pointer image2 = rescaler2->GetOutput( );
>>
>>       rescaler1->Update( );
>>       rescaler2->Update( );
>>
>>       MetricType::Pointer metric = MetricType::New( );
>>
>>       metric->SetFixedImage( image1 );
>>       metric->SetMovingImage( image2  );
>>       metric->SetFixedImageRegion( image1- 
>> >GetLargestPossibleRegion( ) );
>>
>>       TransformType::Pointer transform =  
>> Transform::TransformType::New( );
>>       transform->SetIdentity( );
>>       metric->SetTransform( transform );
>>       metric->SetTransformParameters ( transform->GetParameters( ) );
>>       metric->SetInterpolator( interpolator );
>>       metric->Initialize( );
>>
>>       std::cout << "Metrik Value: " << metric->GetValue( transform- 
>> >GetParameters( ) ) << std::endl;
>>
>> }
>> --
>> Psssst! Schon vom neuen GMX MultiMessenger gehört? Der kann`s mit  
>> allen: http://www.gmx.net/de/go/multimessenger
>> _______________________________________________
>> 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