[ITK] [ITK-users] Python SimpleITK DivideReal always returns double image

Addison Elliott addison.elliott at gmail.com
Tue Oct 10 23:21:51 EDT 2017


Hey guys,

When using Python 3.0+, the operator / utilizes __truediv__ instead of
__div__. For itk.Image, truediv uses DivideReal and div uses Divide. This
is relevant because DivideReal returns an image with double datatype and
Divide uses the datatype of the input image.

Since I am using 32-bit floats for my images, this requires me to cast to a
32-bit float each time. It would be more convenient if it mimicked the
datatype of the input image OR you could specify the desired datatype.

Here is a test case to show what I mean:

image = sitk.Image(50, 50, 50, sitk.sitkFloat32)
image2 = sitk.DivideReal(image, 4.0)
print(image) # <---- Type is float
print(image2) # <---- Type is double

image = sitk.Image(50, 50, 50, sitk.sitkFloat32)
image2 = sitk.Divide(image, 4.0)
print(image) # <---- Type is float
print(image2) # <---- Type is float

I've been using ITK for a few weeks and SimpleITK for about a week. I've
have SimpleITK built from source.

   - Is this a feature/bug worthy of fixing?
   - Can someone point me in the right direction as to where I should start
   for fixing the issue?
   - Any other tips and comments are welcome!


Addison
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/community/attachments/20171010/5ea69e81/attachment.html>
-------------- next part --------------
The ITK community is transitioning from this mailing list to discourse.itk.org. Please join us there!
________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/insight-users


More information about the Community mailing list