I use version 2.2 of simpleitk.
It was implemented by referring to the following code for registration.
https://simpleitk.readthedocs.io/en/master/link_ImageRegistrationMethodBSpline2_docs.html
Previously, image registration was performed using python, and good results were obtained.
However, this time, I tried to registration with the same parameter and the same image using CSharp, and I got a bad result.
In both cases, The main parts are as follows.
transformDomainMeshSize=[10]*moving.GetDimension()
tx = sitk.BSplineTransformInitializer(fixed, transformDomainMeshSize, 3)
R = sitk.ImageRegistrationMethod()
R.SetMetricAsMattesMutualInformation(50)
R.SetOptimizerAsGradientDescentLineSearch(5.0, 100, convergenceMinimumValue=1e-1, convergenceWindowSize=5)
R.SetOptimizerScalesFromPhysicalShift()
R.SetInitialTransform(tx)
R.SetInterpolator(sitk.sitkLinear)
R.SetShrinkFactorsPerLevel([4,2,1])
R.SetSmoothingSigmasPerLevel([4,2,1])
outTx = R.Execute(fixed, moving)
<C#>
var transformDomainMeshSize = new VectorUInt32();
transformDomainMeshSize.Add(10);
transformDomainMeshSize.Add(10);
var tx = new BSplineTransformInitializerFilter();
tx.SetTransformDomainMeshSize(transformDomainMeshSize);
var tx_t = tx.Execute(fixedImage);
R = new ImageRegistrationMethod();
R.SetMetricAsMattesMutualInformation(50);
R.SetOptimizerAsGradientDescentLineSearch(5.0, 100, 1e-1, 5);
R.SetOptimizerScalesFromPhysicalShift();
R.SetInitialTransform(tx_t);
R.SetInterpolator(InterpolatorEnum.sitkLinear);
VectorUInt32 shrinkFactorsPerLevel = new VectorUInt32(3)
{
4,
2,
1
};
VectorDouble smoothingSigmasPerLevel = new VectorDouble(3)
{
4,
2,
1
};
R.SetShrinkFactorsPerLevel(shrinkFactorsPerLevel);
R.SetSmoothingSigmasPerLevel(smoothingSigmasPerLevel);
For other parts, I think the same function and parameter were used.
Is there any difference in performance between python and CSharp in SimpleITK?
Or is it a problem with my code?
Please give me advice.