# Unexpected Results for "MultiResImageRegistration1.cxx."

**URL:** <https://discourse.itk.org/t/unexpected-results-for-multiresimageregistration1-cxx/4411>\
**Category:** Beginner Questions\
**Tags:** itk, cpp, example, registration\
**Created:** [September 10, 2021, 12:57pm UTC](https://discourse.itk.org/t/unexpected-results-for-multiresimageregistration1-cxx/4411 "2021-09-10T12:57:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Keyn34](https://discourse.itk.org/letter_avatar_proxy/v4/letter/k/9fc29f/32.png) [@Keyn34](https://discourse.itk.org/u/Keyn34)\
**Post date:** [September 10, 2021, 12:57pm UTC](https://discourse.itk.org/t/unexpected-results-for-multiresimageregistration1-cxx/4411/1 "2021-09-10T12:57:26Z")

</div>

Hello everyone!

I just started out with ITK, with base knowledge from VTK. I wanted to work through some Registration examples towards Multi-Resolution Registration.

The Hello World Registration example worked for me, so I wanted to continue with “MultiResImageRegistration1”. I simply created a new CMake Project within Visual Studio 2019 (ITK was also build with Visual Studio 2019, 64 bit in debug), copied the source code and let i compile and run afterwards without any problems. The weird thing are the results, using the simple test \*.png images of the MRI brain scan.

The CheckerBoardBefore image is the following:  
 ![checkerBoardBefore](https://discourse.itk.org/uploads/default/original/2X/4/4de4231169cac22413b6f00bb91cab0777e6e493.png)

The CheckerBoardAfter and Output image are those:  
 ![checkerBoardAfter](https://discourse.itk.org/uploads/default/original/2X/2/2657e5220cb4ac908e085d357c5fe751e05c1292.png) ![output](https://discourse.itk.org/uploads/default/original/2X/d/d6dfa3e6ce563c372708ad8a66bd305afac1cd7b.png)

Why are the images speckled? I literally just copied the example Sourcecode from [https://itk.org/Doxygen/html/Examples\_2RegistrationITKv4\_2MultiResImageRegistration1\_8cxx-example.html](https://itk.org/Doxygen/html/Examples_2RegistrationITKv4_2MultiResImageRegistration1_8cxx-example.html). Is it a possible, breaking, problem that the example is targeted for ITK Version 5.3 and I am using Version 5.2.1?

I am currently using Windows 10, with Visual Studio 2019 as IDE. I configured ITK with CMake 3.16.2 and build it with Visual Studio 2019 as well. The latest Release of ITK (Version 5.2.1) was used. During the configuration I did not change any default setting except the installation prefix and the build shared libraries flag. Everything went smooth except that I encountered the Windows specific “path too long” problem which was obviously easy to fix.

I would be grateful for any suggestion.  
Thank you in advance!

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [September 10, 2021, 2:12pm UTC](https://discourse.itk.org/t/unexpected-results-for-multiresimageregistration1-cxx/4411/2 "2021-09-10T14:12:47Z")

</div>

That example uses [casting from float to uchar](https://github.com/InsightSoftwareConsortium/ITK/blob/v5.2.1/Examples/RegistrationITKv4/MultiResImageRegistration1.cxx#L590) pixels. That causes intensity wrap-around. If you replace cast by [rescale](https://itk.org/Doxygen/html/classitk_1_1RescaleIntensityImageFilter.html), the results should be sane. Or if you started with images which have pixel intensities in 0-255 range. If you update the example to work correctly, [submitting a PR with the fix](https://github.com/InsightSoftwareConsortium/ITK/blob/master/CONTRIBUTING.md) would be highly appreciated.

---

<div class="post-metadata">

**Author:** ![Keyn34](https://discourse.itk.org/letter_avatar_proxy/v4/letter/k/9fc29f/32.png) [@Keyn34](https://discourse.itk.org/u/Keyn34)\
**Post date:** [September 13, 2021, 7:49am UTC](https://discourse.itk.org/t/unexpected-results-for-multiresimageregistration1-cxx/4411/4 "2021-09-13T07:49:03Z")

</div>

Thank you for the response. I checked the intensity values of the used images with ITK-Snap. They appear to be within the 0-255 range.  
But i will test for the rescale approach you suggested. Thank you very much so far.

Edit: Changing the Cast to Rescale definitely resolved the issues of speckles in the images. Thank you very much again.
