<div>Hi to all</div><div> </div><div>I&#39;m trying to test the &#39;ThresholdImageFilter&#39; setting up its values (lower and upper) with variables (variables &#39;lower&#39; and &#39;upper&#39;). I&#39;m not sure if this is valid because a TypeError appears (see green output).</div>
<div> </div><div>I&#39;d like to know if it is possible to do in some way this setting up with variables. I don&#39;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\&lt;ipython-input-51-8eecea2cdc9b&gt; in &lt;module&gt;()<br>      2 upper=average+100;<br>      3 threshold = sitk.ThresholdImageFilter()<br>
----&gt; 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         &quot;&quot;&quot;<br>&gt; 19341         return _SimpleITK.ThresholdImageFilter_SetLower(self, *args, **kwargs)<br>  19342 <br>  19343     def GetLower(self):</font></div><div><font color="#006600">TypeError: in method &#39;ThresholdImageFilter_SetLower&#39;, argument 2 of type &#39;double&#39;</font></div>