I worked on iterators in ITK. I wonder if there is any way to use them in simpleITK? If not, what is the alternative?

For example, I want to write compare two images and compute some similarity measure(in my case it is normalised cross-correlation). So in order to implement this, I would be requiring iterators right?

Also please let me know if there is any method built-in sitk to compute normalised cross correction directly without writing code by myself

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
```

1 Like