I am new with Image Registration and i am trying to register images similar to the following ones.
In most cases it works really well but in cases like this the algorithm stops after a few steps.
I think the problem is that I need to rotate first the moving image to bring it as close as possible to fixed one. but I am not sure how to fix it. I ve tried to apply an affine transformation and then pass it to the bspline as initial transformation but it makes things worse. Any ideas are more than welcome.
One more issue that I have is that I dont know how to extract the inverse
I read that it’s not implemented for the Bsplines but I cannot find any instructions on how to extract it manually.
I would appreciate any help.
here is the registration output
and here is the code and method that worked best from what i’ve tried
fixed_image = sitk.ReadImage(os.path.join(fixed_image_ref), sitk.sitkFloat32)
moving_image = sitk.ReadImage(os.path.join(moving_image_ref), sitk.sitkFloat32) control_pts = 3 transformDomainMeshSize = [control_pts] * moving_image.GetDimension() initial_transform = sitk.BSplineTransformInitializer(fixed_image, transformDomainMeshSize) registration_method = sitk.ImageRegistrationMethod() registration_method.SetMetricSamplingStrategy(registration_method.REGULAR) registration_method.SetMetricSamplingPercentage(0.1) registration_method.SetMetricAsCorrelation() registration_method.SetOptimizerAsLBFGSB(gradientConvergenceTolerance=1e-5, numberOfIterations=200, maximumNumberOfCorrections=5, maximumNumberOfFunctionEvaluations=1000, costFunctionConvergenceFactor=1e+7) registration_method.SetInitialTransform(initial_transform, inPlace=True) registration_method.SetInterpolator(sitk.sitkLinear) registration_method.AddCommand(sitk.sitkIterationEvent, lambda: command_iteration(registration_method)) final_transform = registration_method.Execute(fixed_image, moving_image)