Hi everyone,
I am starting to learn how to use the toolkit for image registration.
I have a pair of thermal-visual images that need to be registered. Each image has a different dimensions and with a 90% of the scene is overlapping.
The content below is the structure of each image:
Reference Optical image:
origin: (0.0, 0.0)
size: (1936, 1216)
spacing: (0.26458333333333334, 0.26458333333333334)
direction: (1.0, 0.0, 0.0, 1.0)
pixel type: 32-bit float
number of pixel components: 1
######################################################
Thermal image:
origin: (0.0, 0.0)
size: (640, 480)
spacing: (0.26458333333333334, 0.26458333333333334)
direction: (1.0, 0.0, 0.0, 1.0)
pixel type: 32-bit float
number of pixel components: 1
To perform the registration, I am following the notebook 05_basic_registration and I am not achieving good results. First of all, I read the images as float32 and then I create a initial transform as shown below.
With the initial transform, It’s possible to note that the entire moving image is mapped at the center of the fixed image. I don’t know why. For the second step, I am using the same code as the tutorial with minor changes, as follows:
registration_method = sitk.ImageRegistrationMethod()
# Similarity metric settings.
registration_method.SetMetricAsMattesMutualInformation(numberOfHistogramBins=50)
registration_method.SetMetricSamplingStrategy(registration_method.RANDOM)
registration_method.SetMetricSamplingPercentage(1)
registration_method.SetInterpolator(sitk.sitkLinear)
# Optimizer settings.
registration_method.SetOptimizerAsGradientDescent(learningRate=1.0, numberOfIterations=500, convergenceMinimumValue=1e-6, convergenceWindowSize=100)
# registration_method.SetOptimizerScalesFromPhysicalShift()
# Setup for the multi-resolution framework.
# registration_method.SetShrinkFactorsPerLevel(shrinkFactors = [4,2,1])
# registration_method.SetSmoothingSigmasPerLevel(smoothingSigmas=[2,1,0])
# registration_method.SmoothingSigmasAreSpecifiedInPhysicalUnitsOn()
# Don't optimize in-place, we would possibly like to run this cell multiple times.
registration_method.SetInitialTransform(initial_transform, inPlace=False)
# Connect all of the observers so that we can perform plotting during registration.
registration_method.AddCommand(sitk.sitkStartEvent, rgui.start_plot)
registration_method.AddCommand(sitk.sitkEndEvent, rgui.end_plot)
registration_method.AddCommand(sitk.sitkMultiResolutionIterationEvent, rgui.update_multires_iterations)
registration_method.AddCommand(sitk.sitkIterationEvent, lambda: rgui.plot_values(registration_method))
final_transform = registration_method.Execute(fixed_image_2, moving_image)
# Always check the reason optimization terminated.
print('Final metric value: {0}'.format(registration_method.GetMetricValue()))
print('Optimizer\'s stopping condition, {0}'.format(registration_method.GetOptimizerStopConditionDescription()))
Can I perform such kind of image registration with sampleITK? If yes, what could be wrong in my example?
I was able to achieve good results using the Matlab image registration toolkit with Mattes Mutual Information and with the same parameters.
Thanks in advance,
Paulo