[ITK] [ITK-users] post a message

Yaniv, Ziv Rafael (NIH/NLM/LHC) [C] zivrafael.yaniv at nih.gov
Thu Jun 28 12:11:12 EDT 2018


Hello Leena,

The ITK users mailing list is deprecated. In the future, please post questions to the ITK discourse forum https://discourse.itk.org/

With respect to the runtime error, your png image is likely a color image even if it looks grayscale, it is what we call a vector image (multi-channel) in SimpleITK, and the operation of img>20 does not make sense for such images, hence the exception.

As it is not clear what you want to do “threshold a color image” is not a well-defined operation, please post on the discourse forum and provide additional details so that we can help you.

You can see all of the relevant information with respect to “img”, by printing the image “print(img)” will show you the actual structure of the image you read.

         hope this helps
               Ziv

From: leena m <leenzz.m at gmail.com>
Date: Wednesday, June 27, 2018 at 11:38 PM
To: "insight-users at itk.org" <insight-users at itk.org>
Subject: [ITK-users] post a message



i'm a beginner in python wen i apply thresholding i'm getting error

import SimpleITK as sitk

img = sitk.ReadImage("Sub1.png")

img=img>20

i'm getting error as

RuntimeError                              Traceback (most recent call last)

<ipython-input-48-a1d4494dca15> in <module>()

      1 #img = sitk.Image(img.GetSize(), sitk.sitkUInt8)

----> 2 img=img>20



~/sitkpy/lib/python3.5/site-packages/SimpleITK/SimpleITK.py in __gt__(self, other)

   4424            return Greater( self, other )

   4425         try:

-> 4426            return Greater( self, float(other) )

   4427         except (ValueError, TypeError):

   4428            return NotImplemented



~/sitkpy/lib/python3.5/site-packages/SimpleITK/SimpleITK.py in Greater(*args)

  34345

  34346     """

> 34347     return _SimpleITK.Greater(*args)

  34348 class GridImageSource(ImageFilter_0):

  34349     """



RuntimeError: Exception thrown in SimpleITK Greater: /tmp/SimpleITK/Code/Common/include/sitkMemberFunctionFactory.hxx:209:

sitk::ERROR: Pixel type: vector of 8-bit unsigned integer is not supported in 2D byN3itk6simple18GreaterImageFilterE

I applied img = sitk.Image(img.GetSize(), sitk.sitkUInt8)

but I'm getting a black image

Is there any option like double(img) or im2bw in python.Will normalize work?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://itk.org/pipermail/community/attachments/20180628/45424934/attachment-0001.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:
https://itk.org/mailman/listinfo/insight-users


More information about the Community mailing list