Hello @unicorn,
Similar to the answer to your previous question. The various similarity measures are listed in the SimpleITK documentation (one of them is normalized cross-correlation).
If you want to perform computations using all pixels, iterating is best avoided.
We highly recommend using a broadcasting approach, applying operations to the whole image in one go, same as when working with numpy and most other Python tools (e.g. sitk.Square(img1-img2)
).
If you are more comfortable using numpy then you can just get views of the image data and work in numpy:
arr1 = sitk.GetArrayViewFromImage(img1)
arr2 = sitk.GetArrayViewFromImage(img2)
(arr1-arr2)**2