[Insight-users] Problems converting ImageRegistration2.cxx to C#

Dan Mueller dan.muel at gmail.com
Sat Mar 27 03:11:38 EDT 2010


Hi Carl,

I have implemented the native ITK "ImageRegistration2" example for
ManagedITK. It has been committed to the examples folder in Google
Code:
    http://code.google.com/p/manageditk/source/browse/trunk/Examples/Registration/itk.Examples.Registration.ImageRegistration2.cs

Regarding buffered region:
    // Set requested region
    fixedNormalizer.Update();
    ImageType fixedNormalizerOutput = ImageType.New();
    fixedNormalizer.GetOutput(fixedNormalizerOutput);
    RegionType fixedImageRegion = fixedNormalizerOutput.BufferedRegion;
    fixedImage.RequestedRegion = fixedImageRegion;

Regarding variance:
    // Normailize
    NormalizeFilterType fixedNormalizer = NormalizeFilterType.New();
    NormalizeFilterType movingNormalizer = NormalizeFilterType.New();
    GaussianFilterType fixedSmoother = GaussianFilterType.New();
    GaussianFilterType movingSmoother = GaussianFilterType.New();
    fixedSmoother.Variance = new double[] { 2.0, 2.0 };
    movingSmoother.Variance = new double[] { 2.0, 2.0 };

I get the following results:
itk.Examples.Registration.ImageRegistration2.exe
BrainT1SliceBorder20.png BrainProtonDensitySliceShifted13x17y.png
out.png out1.png out2.png
000:   [000.14, 000.15]
001:   [000.23, 000.23]
002:   [000.29, 000.35]
003:   [000.32, 000.44]
004:   [000.42, 000.52]
005:   [000.44, 000.71]
...
194:   [013.05, 017.21]
195:   [013.06, 017.28]
196:   [013.04, 017.17]
197:   [012.98, 017.05]
198:   [012.95, 017.03]
199:   [012.92, 016.99]
MaximumNumberOfIterations
Result=
 Translation X = 12.9230359242253
 Translation Y = 16.9922266326733
 Iterations    = 200
 Metric value  = 0.609390229850048
 Numb. Samples = 567

Hope this helps.

Cheers, Dan

On 26 March 2010 13:51, Carl Bateman <Carl.Bateman at icr.ac.uk> wrote:
> I'm a new user of Managed-ITK with C# and I'm trying to convert ImageRegistration2.cxx to C# but I'm stuck about half-way through. Specifically, I'm unsure how to convert the following code:
>
>  FixedImageType::RegionType fixedImageRegion = fixedNormalizer->GetOutput()->GetBufferedRegion();
>  registration->SetFixedImageRegion( fixedImageRegion );
>
>  typedef RegistrationType::ParametersType ParametersType;
>  ParametersType initialParameters( transform->GetNumberOfParameters() );
>
> I've got as far as
>  itkImageRegion fixedImageRegion = fixedNormalizer.GetOutput();
>
> but I'm unable ro access the buffered region.
>
> Any advice would be appreciated.
>
>
>
> Additionally, I was having problems setting the variance values for fixedSmoother and movingSmoother (these seem to be arrays in C#). So
> [C++]
>  fixedSmoother->SetVariance( 2.0 );
>  movingSmoother->SetVariance( 2.0 );
>
> becomes
> [C#]
>  fixedSmoother.Variance[0] = 2.0;
>  movingSmoother.Variance[0] = 2.0;
>
> Is this the correct approach?
>
> Many thanks in advance.
>
> Carl Bateman
>
>
> The Institute of Cancer Research: Royal Cancer Hospital, a charitable Company Limited by Guarantee, Registered in England under Company No. 534147 with its Registered Office at 123 Old Brompton Road, London SW7 3RP.


More information about the Insight-users mailing list