[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/insight-users/attachments/20180628/45424934/attachment.html>


More information about the Insight-users mailing list