[ITK] How to get to get image similarity metrics under .NET ?

Yaniv, Ziv Rafael (NIH/NLM/LHC) [C] zivrafael.yaniv at nih.gov
Thu Nov 19 09:49:20 EST 2015


Hello Oleg,

It is necessary to set the initial transform as the MetricEvaluate method
will use that transformation to evaluate your similarity metric, the same
way it is done during registration. There is always a transformation
between the two images, even if it is the identity. Something like
method.SetInitialTransform(new Euler3DTransform()) if your images are 3D
or Euler2DTransform() if they are 2D. In your case the you can use any of
the transformation types Translation,AffineŠ as you are creating the
identity transform.

   Ziv



On 11/19/15, 6:57 AM, "Oleg Subachev" <osubachev at gmail.com> wrote:

>Since error message says something about "initial transform" may be it
>is necessary to set up initial transform ?
>As you see from code I do not call SetInitialTransform method at all.
>I hope that no initial transform or default initial transform (if any)
>will be enough.
>I simply want to get similarity metric value for two image files
>without any transform.
>
>-- 
>Best regards,
>Oleg Subachev
>
>On Thu, Nov 19, 2015 at 12:01 PM, Oleg Subachev <osubachev at gmail.com>
>wrote:
>> Thanks all of you.
>> But now the code:
>> using ( ImageRegistrationMethod method = new ImageRegistrationMethod() )
>> {
>> method.SetMetricAsMattesMutualInformation();
>> double metric = method.MetricEvaluate(
>> SimpleITK.ReadImage( "1.png", PixelIDValueEnum.sitkFloat32
>> ),SimpleITK.ReadImage( "2.png", PixelIDValueEnum.sitkFloat32 ));
>> }
>>
>> throws new exception:
>> {"Exception thrown in SimpleITK
>> ImageRegistrationMethod_MetricEvaluate:
>> 
>>..\\..\\..\\..\\..\\SimpleITK\\Code\\Registration\\src\\sitkImageRegistra
>>tionMethod.cxx:922:\nsitk::ERROR:
>> Unexpected error converting initial transform! Possible miss matching
>> dimensions!"}
>>
>> --
>> Best regards,
>> Oleg Subachev
>>
>>
>> On Wed, Nov 18, 2015 at 8:14 PM, Yaniv, Ziv Rafael (NIH/NLM/LHC) [C]
>> <zivrafael.yaniv at nih.gov> wrote:
>>> Hello Oleg,
>>>
>>> The ImageRegistrationMethod only supports images with pixel type
>>> sitkFloat32 and sitkFloat64. You can either specify the pixel type when
>>> reading the image
>>> 
>>>(http://www.itk.org/SimpleITKDoxygen/html/namespaceitk_1_1simple.html#a0
>>>2ff
>>> c30c3c55dd9eeff3f76ba19f35e7) or read the image with its native pixel
>>>type
>>> and then
>>> use the SimpleITK Cast function
>>> 
>>>(http://www.itk.org/SimpleITKDoxygen/html/namespaceitk_1_1simple.html#af
>>>8c9
>>> d7cc96a299a05890e9c3db911885), casting it to either of these two types.
>>>
>>>    Ziv
>>>
>>>
>>>
>>> On 11/18/15, 9:51 AM, "Oleg Subachev" <osubachev at gmail.com> wrote:
>>>
>>>>Thanks, Brad.
>>>>
>>>>But when I try this code:
>>>>using ( ImageRegistrationMethod method = new ImageRegistrationMethod()
>>>>)
>>>>{
>>>>method.SetMetricAsMattesMutualInformation( 50 );
>>>>double metric = method.MetricEvaluate( SimpleITK.ReadImage( "1.png" ),
>>>>SimpleITK.ReadImage( "2.png" ) );
>>>>}
>>>>
>>>>I get the exception:
>>>>{"Exception thrown in SimpleITK
>>>>ImageRegistrationMethod_MetricEvaluate:
>>>>..\\..\\..\\..\\..\\SimpleITK\\Code\\Registration\\src\\sitkImageRegist
>>>>rat
>>>>ionMethod.cxx:862:\nsitk::ERROR:
>>>>Filter does not support fixed image type: vector of 8-bit unsigned
>>>>integer"}
>>>>
>>>>What's wrong ?
>>>>What is the simplest way to get similarity value of two image files ?
>>>>
>>>>--
>>>>Best regards,
>>>>Oleg Subachev
>>>>
>>>>On Tue, Nov 17, 2015 at 6:41 PM, Bradley Lowekamp
>>>><blowekamp at mail.nih.gov> wrote:
>>>>> Hello,
>>>>>
>>>>> You should look into SimpleITK's
>>>>>ImageRegistrationMethod::MetricEvaluate( Image, Image ) member
>>>>>function.
>>>>>
>>>>> Here is a Python example of using the method, C# should be similar:
>>>>>
>>>>>
>>>>>http://insightsoftwareconsortium.github.io/SimpleITK-Notebooks/63_Regi
>>>>>str
>>>>>ation_Initialization.html
>>>>>
>>>>> HTH,
>>>>> Brad
>>>>>
>>>>> On Nov 17, 2015, at 8:24 AM, Oleg Subachev <osubachev at gmail.com>
>>>>>wrote:
>>>>>
>>>>>> I need to get similarity metrics for 2D images under .NET.
>>>>>> According to ITK documentation
>>>>>> (http://www.itk.org/Doxygen/html/ImageSimilarityMetricsPage.html)
>>>>>> there are several Image To Image metrics available.
>>>>>> ITK itself contains corresponding methods.
>>>>>> But I cannot find those methods in SimpleITK :-(
>>>>>> There is SimpleITK.NormalizedCorrelation(Image, Image, Image)
>>>>>>method,
>>>>>> but it seems to have nothing with similarity metrics.
>>>>>>
>>>>>> How to get to get image similarity metrics under .NET ?
>>>>>>
>>>>>> --
>>>>>> Best regards,
>>>>>>
>>>>>> Oleg Subachev
>>>>>> _______________________________________________
>>>>>> Community mailing list
>>>>>> Community at itk.org
>>>>>> http://public.kitware.com/mailman/listinfo/community
>>>>>
>>>>_______________________________________________
>>>>Community mailing list
>>>>Community at itk.org
>>>>http://public.kitware.com/mailman/listinfo/community
>>>
>_______________________________________________
>Community mailing list
>Community at itk.org
>http://public.kitware.com/mailman/listinfo/community



More information about the Community mailing list