Registrations errors (Root square mean & joint histogram)

Hello everyone,

I would like to know if there is a function on SimpleITK for Python which calculates RMS and joint histogram.


Hello @Dodox,
Unfortunately, no, but these can be readily implemented in Python:

import SimpleITK as sitk
import matplotlib.pyplot as plt
import numpy as np

# Resample one image onto the other so that we compare the relevant pixels
# Also note we are reading them as float32
img1 = sitk.ReadImage('training_001_ct.mha', sitk.sitkFloat32)
img2 = sitk.ReadImage('training_001_mr_T1.mha', sitk.sitkFloat32)
img2_resampled = sitk.Resample(img2,img1)

# Compute RMSE using numpy, note if the original images are not in floating
# point you may have overflow related errors (int16 may suffer from overlow
# when some values are squared)
arr1 = sitk.GetArrayViewFromImage(img1)
arr2 = sitk.GetArrayViewFromImage(img2_resampled)
RMSE = np.sqrt(np.sum((arr1 - arr2)**2)/

# Use matplotlib for 2D histogram
plt.hist2d(arr1.ravel(), arr2.ravel());


Thank you very much <3 @zivy