[Insight-users] Fwd: values for 'ThresholdImageFilter'

Ing. Arturo Vargas Olivares ing.arturo.vargas at gmail.com
Tue May 22 11:49:11 EDT 2012


I've found this alternative

threshold.SetLower(float(lower))
threshold.SetUpper(float(upper))

It works!




---------- Forwarded message ----------
From: Ing. Arturo Vargas Olivares <ing.arturo.vargas at gmail.com>
Date: Tue, May 22, 2012 at 10:53 AM
Subject: values for 'ThresholdImageFilter'
To: insight-users at itk.org


Hi to all

I'm trying to test the 'ThresholdImageFilter' setting up its values (lower
and upper) with variables (variables 'lower' and 'upper'). I'm not sure if
this is valid because a TypeError appears (see green output).

I'd like to know if it is possible to do in some way this setting up with
variables. I don't want to have static values in the threshold all the time.

Thank you in advance for your comments.



In[50]: average
Out[50]: 3594
In[51]: lower=average-100;
   . . . : upper=average+100;
   . . . : threshold = sitk.ThresholdImageFilter()
   . . . : threshold.SetLower(lower)
   . . . : threshold.SetUpper(upper)
   . . . : threshold.SetOutsideValue(4000)
   . . . : image_3 = threshold.Execute(image_2)
   . . . : aa=sitk.GetArrayFromImage(image_3)
   . . . : mplot.figure()
   . . . : mplot.imshow(aa,cmap=cm.gray)
   . . . : mplot.colorbar()
   . . . :
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
C:\Users\Student3\Desktop\MRI images\<ipython-input-51-8eecea2cdc9b> in
<module>()
      2 upper=average+100;
      3 threshold = sitk.ThresholdImageFilter()
----> 4 threshold.SetLower(lower)
      5 threshold.SetUpper(upper)
      6 threshold.SetOutsideValue(4000)
C:\Python27\lib\site-packages\simpleitk-0.4.0-py2.7-win-amd64.egg\SimpleITK.pyc
in SetLower(self, *args, **kwargs)
  19339
  19340         """
> 19341         return _SimpleITK.ThresholdImageFilter_SetLower(self,
*args, **kwargs)
  19342
  19343     def GetLower(self):
TypeError: in method 'ThresholdImageFilter_SetLower', argument 2 of type
'double'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20120522/ca718ea2/attachment.htm>


More information about the Insight-users mailing list