# Comparing Vector Images in my Tests (using itkTestMain.h)

**URL:** <https://discourse.slicer.org/t/comparing-vector-images-in-my-tests-using-itktestmain-h/1684>\
**Category:** Development\
**Created:** [December 19, 2017, 12:33am UTC](https://discourse.slicer.org/t/comparing-vector-images-in-my-tests-using-itktestmain-h/1684 "2017-12-19T00:33:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mschwier](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mschwier/32/394_2.png) [@mschwier](https://discourse.slicer.org/u/mschwier)\
**Post date:** [December 19, 2017, 12:33am UTC](https://discourse.slicer.org/t/comparing-vector-images-in-my-tests-using-itktestmain-h/1684/1 "2017-12-19T00:33:34Z")

</div>

I am using itkTestMain.h as parent for module tests. However, I also need to compare Vector Images against their baseline and this is apparently not supported [because the images are cast to double.](https://github.com/Slicer/Slicer/blob/1b713d1701dea926134ec6366134fa3e08caf21e/Base/CLI/Testing/itkTestMain.h#L263)

Did I overlook something or can you suggest an easy way to include Vector Image comparison in my tests?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 19, 2017, 12:50am UTC](https://discourse.slicer.org/t/comparing-vector-images-in-my-tests-using-itktestmain-h/1684/2 "2017-12-19T00:50:15Z")

</div>

This should be available in ITK. I don’t know how they compare color images if they don’t have this. It could worth [asking this from ITK people](https://discourse.itk.org/).

A workaround could be to split the vector image to its components and compare each component separately.

---

<div class="post-metadata">

**Author:** ![mschwier](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mschwier/32/394_2.png) [@mschwier](https://discourse.slicer.org/u/mschwier)\
**Post date:** [December 19, 2017, 5:45pm UTC](https://discourse.slicer.org/t/comparing-vector-images-in-my-tests-using-itktestmain-h/1684/3 "2017-12-19T17:45:59Z")

</div>

Thanks Andras, I asked there (they confirmed it is a limitation currently), and implemented the workaround you suggested. Currently I am doing this in a copy of itkTestMain.h in my project/slicer module. When I put the pull request up for that project, I could share it here, if you’d like to see if it is worth considering integrating it into Slicer!?

---

<div class="post-metadata">

**Author:** ![mschwier](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mschwier/32/394_2.png) [@mschwier](https://discourse.slicer.org/u/mschwier)\
**Post date:** [December 19, 2017, 6:13pm UTC](https://discourse.slicer.org/t/comparing-vector-images-in-my-tests-using-itktestmain-h/1684/4 "2017-12-19T18:13:57Z")

</div>

In case you are interested in the workaround [follow this link](https://github.com/millerjv/PkModeling/pull/69/files#diff-c91316551f37754253eee5cb50c9e042).

It’s a simple straight forward fix, not very sophisticated but better than before at least, since differences in Vector Images are now detected.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 20, 2017, 6:26pm UTC](https://discourse.slicer.org/t/comparing-vector-images-in-my-tests-using-itktestmain-h/1684/5 "2017-12-20T18:26:54Z")

</div>

Thank you. If you can get it integrated ITK then it is enough. Slicer regularly updates its ITK version, so your changes will eventually get into Slicer.

---

<div class="post-metadata">

**Author:** ![mschwier](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mschwier/32/394_2.png) [@mschwier](https://discourse.slicer.org/u/mschwier)\
**Post date:** [December 20, 2017, 6:51pm UTC](https://discourse.slicer.org/t/comparing-vector-images-in-my-tests-using-itktestmain-h/1684/6 "2017-12-20T18:51:22Z")

</div>

Thing is, I only changed the itkTestMain.h, which is not part of ITK anymore (since 4 I think), but it was kept in Slicer for backwards compatibility ([see here](https://issues.slicer.org/view.php?id=2807)).

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [December 20, 2017, 6:54pm UTC](https://discourse.slicer.org/t/comparing-vector-images-in-my-tests-using-itktestmain-h/1684/7 "2017-12-20T18:54:48Z")

</div>

If the file is not part of Slicer then please send us a pull request and we’ll merge your improvements. It would be great if you could also add a test somewhere that uses the new vector image compare feature (e.g., you could add a new test to one of the CLI modules).
