# How to assert that images are equal, in Python unit test?

**URL:** <https://discourse.itk.org/t/how-to-assert-that-images-are-equal-in-python-unit-test/7302>\
**Category:** Engineering\
**Created:** [November 6, 2024, 4:19pm UTC](https://discourse.itk.org/t/how-to-assert-that-images-are-equal-in-python-unit-test/7302 "2024-11-06T16:19:55Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![matt.mccormick](https://discourse.itk.org/user_avatar/discourse.itk.org/matt.mccormick/32/7_2.png) [@matt.mccormick](https://discourse.itk.org/u/matt.mccormick)\
**Post date:** [November 11, 2024, 5:35pm UTC](https://discourse.itk.org/t/how-to-assert-that-images-are-equal-in-python-unit-test/7302/21 "2024-11-11T17:35:26Z")

</div>

> [@blowekamp](#):
>
> The ComparisonImageFilter class also has the following methods to get the Min, Max, Mean, and Total difference.

Yes, and it as also worth noting that `itkwasm-compare-images` produces these in a convenient way – they are also available in `metrics`.

---

<div class="post-metadata">

**Author:** ![blowekamp](https://discourse.itk.org/user_avatar/discourse.itk.org/blowekamp/32/79_2.png) [@blowekamp](https://discourse.itk.org/u/blowekamp)\
**Post date:** [November 12, 2024, 2:04pm UTC](https://discourse.itk.org/t/how-to-assert-that-images-are-equal-in-python-unit-test/7302/22 "2024-11-12T14:04:09Z")

</div>

This reminds me that one of the reasons I didn’t use this filter more was that it didn’t work with VectorImages and Images of Vectors as I recall. That was back in the day where complex meta-programming would have been required to dispatch to different functions for these different types.

I would imaging that now with the constexpr if statements, this would be much easier to support in the filter. Using constexpr if statements in SimpleITK really makes the code a lot more straight forwards and easier to read.

[Previous page](https://discourse.itk.org/t/how-to-assert-that-images-are-equal-in-python-unit-test/7302.md?page=1)
