It’s been chaotic lately.
My purpose is to calculate the normalized mutual information of pre-registration and post-registration images, and make a comparison to observe the registration effect.
This is my code for calculating normalized mutual information:
def mi(im1,im2,bin):
registation=sitk.ImageRegistrationMethod()
registation.SetMetricAsMattesMutualInformation(numberOfHistogramBins=bin)
registation.SetMetricSamplingStrategy(registation.NONE)
Registation. SetMetricSamplingPercentage (0.01)
res=registation.MetricEvaluate(im1,im2)
return -res
For the unregistered image, because the spatial position does not match, I will go first
fixed_image.setorigin(moving_image.getorigin())
Then calculate the mutual information according to the above function.
My questions are: first, whether the above function computes normalized mutual information or non-normalized mutual information; Second: if I input two identical images into the function, the result is greater than 1, and the result of my image registration is about 0.8, I don’t understand, if two images are the same, shouldn’t the value obtained be 1
If my calculation method is wrong, how can I write code to calculate the mutual information before and after registration and then compare it?