[Insight-users] Can not reproduce metric value
Quy Pham Sy
phamsyquybk at gmail.com
Sun Oct 4 05:41:12 EDT 2009
Hi,
I found a setting like following (for the code i posted earlier)
--------------------
transform->SetScale(0.92632);
transform->SetAngle(0.15095);
TransformType::TranslationType translation;
translation[0] = 28.29828;
translation[1] = 94.07266;
transform->SetTranslation(translation);
----------------------
which causes the metric produce value 0.
here is two images which were be used to test with
fixed.bmp<http://picasaweb.google.com/lh/photo/qq5iA-PTGX6o3ZtslBX5HQ?authkey=Gv1sRgCPfxyPeBwITjkwE&feat=directlink>(
http://picasaweb.google.com/lh/photo/qq5iA-PTGX6o3ZtslBX5HQ?authkey=Gv1sRgCPfxyPeBwITjkwE&feat=directlink
)
moving.bmp<http://picasaweb.google.com/phamsyquybk/DropBox?authkey=Gv1sRgCPfxyPeBwITjkwE#5388585730742727138>(
http://picasaweb.google.com/phamsyquybk/DropBox?authkey=Gv1sRgCPfxyPeBwITjkwE#5388585730742727138
)
You can see two images are not identical so value 0 is incorrect.
Can someone confirm that?
It may be a bug of 'itkMeanSquaresImageToImageMetric'
Thanks,
Quyps.
2009/10/4 Quy Pham Sy <phamsyquybk at gmail.com>
> Hi,
>
> I found what i missed in the code.
> I forgot set translation of the transform. Sorry for wasting your time!
>
> Here is the code, if you want to.
> ---------------------------------------------------
> ..........
> transform->SetScale(1.08438);
> transform->SetAngle(0.154531);
> TransformType::TranslationType translation;
> translation[0] = -26.6822;
> translation[1] = -93.6822;
>
> *transform->SetTranslation(translation);*
>
> MetricType::TransformParametersType transformParams =
> transform->GetParameters();
>
> double metricval = metric->GetValue(transformParams);
> .............
> ----------------------------------------------------
>
> The metric value is 4570.285. It is much closer to 4551.86, still not the
> same ???
>
> I found a strange problem, i played around with the images, i swap role of
> images (fixed.bmp <-> moving.bmp) and the result i got (2715.557) event
> smaller than the value from registration process (4551.86). As far as i
> know, the registration's result is supposed to produce minimum value of
> metric value (is that right?) if so, what is wrong here?
>
> You can reproduce the result with following two images
> fixed.bmp<http://picasaweb.google.com/lh/photo/qq5iA-PTGX6o3ZtslBX5HQ?authkey=Gv1sRgCPfxyPeBwITjkwE&feat=directlink>;
> moving.bmp<http://picasaweb.google.com/phamsyquybk/DropBox?authkey=Gv1sRgCPfxyPeBwITjkwE#5388585730742727138>
>
> Thanks,
> Quyps
>
> 2009/10/4 Quy Pham Sy <phamsyquybk at gmail.com>
>
> Hi, sorry for this lack,
>> /*For cases*/
>> transform->SetAngle(8.85397); --> metric value = 12528.007
>> transform->SetAngle(0.154531); --> metric value = 10993.347
>>
>> result from example is 4551.86
>>
>> I send you two image, could you please try to reproduce this?
>>
>> Thanks,
>> Quyps
>>
>> 2009/10/3 Bill Lorensen <bill.lorensen at gmail.com>
>>
>>> What value did you get?
>>>
>>> On Sat, Oct 3, 2009 at 4:55 AM, Quy Pham Sy <phamsyquybk at gmail.com>
>>> wrote:
>>> > Hi,
>>> > I tried with radian,
>>> > --------------------------------------------
>>> > .....
>>> > transform->SetScale(1.08438);
>>> > transform->SetAngle(0.154531);
>>> > TransformType::TranslationType translation;
>>> > translation[0] = -26.6822;
>>> > translation[1] = -93.6822;
>>> > .....
>>> > --------------------------------------------
>>> > I got new value but still not '4551.86' (the value from example).
>>> > I read from "ITK software guide ver 2.4" textbook, page 366. they
>>> explained
>>> > (as i understand) that the output transform params from registration
>>> process
>>> > are actually applied to FixeImage, in order to get the minimum metric
>>> > value.
>>> > It is still not clear that, the transform params pass directly to
>>> metric
>>> > object are interpreted same way as in registration process (i mean they
>>> also
>>> > applied to Fixed image instead of Moving Image). I guess the reason may
>>> come
>>> > from this unobvious understanding. Do you have any idea about this?
>>> >
>>> > Thanks,
>>> > Quyps
>>> >
>>> > 2009/10/3 Bill Lorensen <bill.lorensen at gmail.com>
>>> >>
>>> >> /** Set/Get the angle of rotation in radians */
>>> >> ----------
>>> >> void SetAngle(TScalarType angle);
>>> >> itkGetConstReferenceMacro( Angle, TScalarType );
>>> >>
>>> >> Try:
>>> >> transform->SetAngle(0.154531);
>>> >>
>>> >> On Fri, Oct 2, 2009 at 4:09 PM, Quy Pham Sy <phamsyquybk at gmail.com>
>>> wrote:
>>> >> > hi,
>>> >> > I run ImageRegistration7 example in ITK.
>>> >> > and the output like following
>>> >> > -------------------------------------
>>> >> > Scale = 1.08438
>>> >> > Angle (radians) 0.154531
>>> >> > Angle (degrees) 8.85397
>>> >> > Center X = 170.327
>>> >> > Center Y = 148.556
>>> >> > Translation X = -26.6822
>>> >> > Translation Y = -93.4428
>>> >> > Iterations = 500
>>> >> > Metric value = 4551.86
>>> >> > ---------------------------------------
>>> >> > I made a program in which i use a same metric, transformation,
>>> >> > interpolate
>>> >> > object type as above example, with same two input image file. I set
>>> >> > above
>>> >> > value to calculate metric value directly from metric object, but the
>>> >> > result
>>> >> > is not same as what the example made..
>>> >> > here is the code, did i miss something?
>>> >> > I'm running out of time! really appreciate any help!
>>> >> >
>>> >> >
>>> -------------------------------------------------------------------------
>>> >> > int main( int argc, char * argv[] )
>>> >> > {
>>> >> > const unsigned int Dimension = 2;
>>> >> > typedef unsigned char PixelType;
>>> >> > typedef itk::Image< PixelType, Dimension > ImageType;
>>> >> > typedef itk::ImageFileReader< ImageType > ReaderType;
>>> >> > ReaderType::Pointer fixedReader = ReaderType::New();
>>> >> > ReaderType::Pointer movingReader = ReaderType::New();
>>> >> > fixedReader->SetFileName( "fixed.bmp" );
>>> >> > movingReader->SetFileName( "moving.bmp" );
>>> >> > try
>>> >> > {
>>> >> > fixedReader->Update();
>>> >> > movingReader->Update();
>>> >> > }
>>> >> > catch( itk::ExceptionObject & excep )
>>> >> > {
>>> >> > std::cerr << "Exception catched !" << std::endl;
>>> >> > std::cerr << excep << std::endl;
>>> >> > }
>>> >> > typedef itk::MeanSquaresImageToImageMetric< ImageType, ImageType >
>>> >> > MetricType;
>>> >> > MetricType::Pointer metric = MetricType::New();
>>> >> > typedef itk::CenteredSimilarity2DTransform < double >
>>> TransformType;
>>> >> > TransformType::Pointer transform = TransformType::New();
>>> >> > typedef itk::LinearInterpolateImageFunction< ImageType, double >
>>> >> > InterpolatorType;
>>> >> > InterpolatorType::Pointer interpolator = InterpolatorType::New();
>>> >> > ImageType::Pointer fixedImage = fixedReader->GetOutput();
>>> >> > ImageType::Pointer movingImage = movingReader->GetOutput();
>>> >> > typedef itk::CenteredTransformInitializer< TransformType, ImageType,
>>> >> > ImageType > TransformInitializerType;
>>> >> > TransformInitializerType::Pointer initializer =
>>> >> > TransformInitializerType::New();
>>> >> > initializer->SetTransform( transform );
>>> >> > initializer->SetFixedImage( fixedImage );
>>> >> > initializer->SetMovingImage( movingImage );
>>> >> > initializer->MomentsOn();
>>> >> > initializer->InitializeTransform();
>>> >> > metric->SetTransform( transform );
>>> >> > metric->SetInterpolator( interpolator );
>>> >> > 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 EXIT_FAILURE;
>>> >> > }
>>> >> > transform->SetScale(1.08438);
>>> >> > transform->SetAngle(0.154531);
>>> >> > TransformType::TranslationType translation;
>>> >> > translation[0] = -26.6822;
>>> >> > translation[1] = -93.6822;
>>> >> > MetricType::TransformParametersType transformParams =
>>> >> > transform->GetParameters();
>>> >> > double metricval = metric->GetValue(transformParams);
>>> >> > return EXIT_SUCCESS;
>>> >> > }
>>> >> >
>>> >> >
>>> >> >
>>> >> >
>>> >> >
>>> >> >
>>> >> >
>>> >> >
>>> >> >
>>> >> > _____________________________________
>>> >> > Powered by www.kitware.com
>>> >> >
>>> >> > Visit other Kitware open-source projects at
>>> >> > http://www.kitware.com/opensource/opensource.html
>>> >> >
>>> >> > Please keep messages on-topic and check the ITK FAQ at:
>>> >> > http://www.itk.org/Wiki/ITK_FAQ
>>> >> >
>>> >> > Follow this link to subscribe/unsubscribe:
>>> >> > http://www.itk.org/mailman/listinfo/insight-users
>>> >> >
>>> >> >
>>> >
>>> >
>>> >> _____________________________________
>>> > Powered by www.kitware.com
>>> >
>>> > Visit other Kitware open-source projects at
>>> > http://www.kitware.com/opensource/opensource.html
>>> >
>>> > Please keep messages on-topic and check the ITK FAQ at:
>>> > http://www.itk.org/Wiki/ITK_FAQ
>>> >
>>> > Follow this link to subscribe/unsubscribe:
>>> > http://www.itk.org/mailman/listinfo/insight-users
>>> >
>>> >
>>>
>>
>>
>
>
>
>
> --
> Pham Sy Quy
> HCI Lab, Advanced Fusion Technology Department,
> Room 1211, New Millennium Building
> Konkuk University, Seoul, Korea
> Mobile: +82-10-9800-8104
>
--
Pham Sy Quy
HCI Lab, Advanced Fusion Technology Department,
Room 1211, New Millennium Building
Konkuk University, Seoul, Korea
Mobile: +82-10-9800-8104
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20091004/ca5065a3/attachment-0001.htm>
More information about the Insight-users
mailing list