# Different rounding behaviour in itk::MetaImageIO between debug and release

**URL:** <https://discourse.itk.org/t/different-rounding-behaviour-in-itk-metaimageio-between-debug-and-release/3931>\
**Category:** Uncategorized\
**Created:** [March 5, 2021, 10:45am UTC](https://discourse.itk.org/t/different-rounding-behaviour-in-itk-metaimageio-between-debug-and-release/3931 "2021-03-05T10:45:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marco\_giordano](https://discourse.itk.org/user_avatar/discourse.itk.org/marco_giordano/32/1965_2.png) [@marco\_giordano](https://discourse.itk.org/u/marco_giordano)\
**Post date:** [March 5, 2021, 10:45am UTC](https://discourse.itk.org/t/different-rounding-behaviour-in-itk-metaimageio-between-debug-and-release/3931/1 "2021-03-05T10:45:01Z")

</div>

Hi there,

I am using ITK as a library in my code and I experience a different rounding behaviour in debug and release when writing an image to disk.

Basically I create a 3D image by converting it from vtk

…  
ImageType::Pointer image = VTKITKUtils::toITk (vtkVolume);  
// at this point ‘image’ has spacing (1.32812500000, 1.32812500000, 1.00000000000)

// some processing

// Add the MetaImage format to the writer  
itk::MetaImageIO::Pointer metaWriter = itk::MetaImageIO::New ();  
metaWriter-\>SetDoublePrecision (6); // write with lower precision to make output backwards compatible

WriterType::Pointer writer = WriterType::New ();  
writer-\>SetImageIO (metaWriter);  
writer-\>SetInput (caster-\>GetOutput ());  
writer-\>SetFileName (inputFileName.toStdString ());

// … other preprocessing steps, but I never change the spacing

writer-\>Update (); # write down to disk

// in debug mode the spacing of the written image is: (1.32813, 1.32813, 1.00000)  
// in release mode the spacing of the written image is: (1.32812, 1.32812, 1.00000)  
// of course any post-processing at this point will differ in debug and release

Thank you for any help in explaining this behaviour.

My development environment  
OS: Windows 10 Enterprise  
IDE: Microsoft Visual Studio Enterprise 2019 Version 16.4.2  
ITK: itk-5.1.0  
platform x64

Regards,  
Marco

---

<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:** [March 5, 2021, 9:22pm UTC](https://discourse.itk.org/t/different-rounding-behaviour-in-itk-metaimageio-between-debug-and-release/3931/2 "2021-03-05T21:22:42Z")

</div>

Can you create a self contained example? You could base it on [CreateAnImage example](https://itk.org/ITKExamples/src/Core/Common/CreateAnImage/Documentation.html).
