<div>I've found this alternative</div><div> </div><div>threshold.SetLower(float(lower))<br>threshold.SetUpper(float(upper))</div><div> </div><div>It works!</div><div> </div><div><br><br> </div><div class="gmail_quote">
---------- Forwarded message ----------<br>From: <b class="gmail_sendername">Ing. Arturo Vargas Olivares</b> <span dir="ltr"><<a href="mailto:ing.arturo.vargas@gmail.com">ing.arturo.vargas@gmail.com</a>></span><br>Date: Tue, May 22, 2012 at 10:53 AM<br>
Subject: values for 'ThresholdImageFilter'<br>To: <a href="mailto:insight-users@itk.org">insight-users@itk.org</a><br><br><br><div>Hi to all</div><div> </div><div>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).</div>
<div> </div><div>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.</div><div> </div><div>Thank you in advance for your comments.</div>
<div> </div><div> </div><div> </div><div><font color="#000099">In[50]: average<br></font><font color="#006600">Out[50]: 3594</font></div><div><font color="#000099">In[51]: lower=average-100;<br> . . . : upper=average+100;<br>
. . . : threshold = sitk.ThresholdImageFilter()<br> . . . : threshold.SetLower(lower)<br> . . . : threshold.SetUpper(upper)<br> . . . : threshold.SetOutsideValue(4000)<br> . . . : image_3 = threshold.Execute(image_2)<br>
. . . : aa=sitk.GetArrayFromImage(image_3)<br> . . . : mplot.figure()<br> . . . : mplot.imshow(aa,cmap=cm.gray)<br> . . . : mplot.colorbar()</font></div><div> . . . :</div><div><font color="#006600">---------------------------------------------------------------------------<br>
TypeError Traceback (most recent call last)<br>C:\Users\Student3\Desktop\MRI images\<ipython-input-51-8eecea2cdc9b> in <module>()<br> 2 upper=average+100;<br> 3 threshold = sitk.ThresholdImageFilter()<br>
----> 4 threshold.SetLower(lower)<br> 5 threshold.SetUpper(upper)<br> 6 threshold.SetOutsideValue(4000)</font></div><div><font color="#006600">C:\Python27\lib\site-packages\simpleitk-0.4.0-py2.7-win-amd64.egg\SimpleITK.pyc in SetLower(self, *args, **kwargs)<br>
19339 <br> 19340 """<br>> 19341 return _SimpleITK.ThresholdImageFilter_SetLower(self, *args, **kwargs)<br> 19342 <br> 19343 def GetLower(self):</font></div><div><font color="#006600">TypeError: in method 'ThresholdImageFilter_SetLower', argument 2 of type 'double'</font></div>
</div><br>