<div dir="ltr"><div class="gmail-votecell gmail-post-layout--left"><div class="gmail-vote">
<div class="gmail-favoritecount"><b></b></div>
</div>
</div>
<div class="gmail-postcell gmail-post-layout--right">
<div class="gmail-post-text">
<p>i'm a beginner in python
wen i apply thresholding i'm getting error</p>
<pre class="gmail-lang-py gmail-prettyprint gmail-prettyprinted"><code><span class="gmail-kwd">import</span><span class="gmail-pln"> </span><span class="gmail-typ">SimpleITK</span><span class="gmail-pln"> </span><span class="gmail-kwd">as</span><span class="gmail-pln"> sitk
img </span><span class="gmail-pun">=</span><span class="gmail-pln"> sitk</span><span class="gmail-pun">.</span><span class="gmail-typ">ReadImage</span><span class="gmail-pun">(</span><span class="gmail-str">"Sub1.png"</span><span class="gmail-pun">)</span><span class="gmail-pln">
img</span><span class="gmail-pun">=</span><span class="gmail-pln">img</span><span class="gmail-pun">></span><span class="gmail-lit">20</span></code></pre>
<p>i'm getting error as</p>
<pre class="gmail-lang-py gmail-prettyprint gmail-prettyprinted"><code><span class="gmail-typ">RuntimeError</span><span class="gmail-pln"> </span><span class="gmail-typ">Traceback</span><span class="gmail-pln"> </span><span class="gmail-pun">(</span><span class="gmail-pln">most recent call last</span><span class="gmail-pun">)</span><span class="gmail-pln">
</span><span class="gmail-pun"><</span><span class="gmail-pln">ipython</span><span class="gmail-pun">-</span><span class="gmail-pln">input</span><span class="gmail-pun">-</span><span class="gmail-lit">48</span><span class="gmail-pun">-</span><span class="gmail-pln">a1d4494dca15</span><span class="gmail-pun">></span><span class="gmail-pln"> </span><span class="gmail-kwd">in</span><span class="gmail-pln"> </span><span class="gmail-pun"><</span><span class="gmail-pln">module</span><span class="gmail-pun">>()</span><span class="gmail-pln">
</span><span class="gmail-lit">1</span><span class="gmail-pln"> </span><span class="gmail-com">#img = sitk.Image(img.GetSize(), sitk.sitkUInt8)</span><span class="gmail-pln">
</span><span class="gmail-pun">----></span><span class="gmail-pln"> </span><span class="gmail-lit">2</span><span class="gmail-pln"> img</span><span class="gmail-pun">=</span><span class="gmail-pln">img</span><span class="gmail-pun">></span><span class="gmail-lit">20</span><span class="gmail-pln">
</span><span class="gmail-pun">~/</span><span class="gmail-pln">sitkpy</span><span class="gmail-pun">/</span><span class="gmail-pln">lib</span><span class="gmail-pun">/</span><span class="gmail-pln">python3</span><span class="gmail-pun">.</span><span class="gmail-lit">5</span><span class="gmail-pun">/</span><span class="gmail-pln">site</span><span class="gmail-pun">-</span><span class="gmail-pln">packages</span><span class="gmail-pun">/</span><span class="gmail-typ">SimpleITK</span><span class="gmail-pun">/</span><span class="gmail-typ">SimpleITK</span><span class="gmail-pun">.</span><span class="gmail-pln">py </span><span class="gmail-kwd">in</span><span class="gmail-pln"> __gt__</span><span class="gmail-pun">(</span><span class="gmail-pln">self</span><span class="gmail-pun">,</span><span class="gmail-pln"> other</span><span class="gmail-pun">)</span><span class="gmail-pln">
</span><span class="gmail-lit">4424</span><span class="gmail-pln"> </span><span class="gmail-kwd">return</span><span class="gmail-pln"> </span><span class="gmail-typ">Greater</span><span class="gmail-pun">(</span><span class="gmail-pln"> self</span><span class="gmail-pun">,</span><span class="gmail-pln"> other </span><span class="gmail-pun">)</span><span class="gmail-pln">
</span><span class="gmail-lit">4425</span><span class="gmail-pln"> </span><span class="gmail-kwd">try</span><span class="gmail-pun">:</span><span class="gmail-pln">
</span><span class="gmail-pun">-></span><span class="gmail-pln"> </span><span class="gmail-lit">4426</span><span class="gmail-pln"> </span><span class="gmail-kwd">return</span><span class="gmail-pln"> </span><span class="gmail-typ">Greater</span><span class="gmail-pun">(</span><span class="gmail-pln"> self</span><span class="gmail-pun">,</span><span class="gmail-pln"> float</span><span class="gmail-pun">(</span><span class="gmail-pln">other</span><span class="gmail-pun">)</span><span class="gmail-pln"> </span><span class="gmail-pun">)</span><span class="gmail-pln">
</span><span class="gmail-lit">4427</span><span class="gmail-pln"> </span><span class="gmail-kwd">except</span><span class="gmail-pln"> </span><span class="gmail-pun">(</span><span class="gmail-typ">ValueError</span><span class="gmail-pun">,</span><span class="gmail-pln"> </span><span class="gmail-typ">TypeError</span><span class="gmail-pun">):</span><span class="gmail-pln">
</span><span class="gmail-lit">4428</span><span class="gmail-pln"> </span><span class="gmail-kwd">return</span><span class="gmail-pln"> </span><span class="gmail-typ">NotImplemented</span><span class="gmail-pln">
</span><span class="gmail-pun">~/</span><span class="gmail-pln">sitkpy</span><span class="gmail-pun">/</span><span class="gmail-pln">lib</span><span class="gmail-pun">/</span><span class="gmail-pln">python3</span><span class="gmail-pun">.</span><span class="gmail-lit">5</span><span class="gmail-pun">/</span><span class="gmail-pln">site</span><span class="gmail-pun">-</span><span class="gmail-pln">packages</span><span class="gmail-pun">/</span><span class="gmail-typ">SimpleITK</span><span class="gmail-pun">/</span><span class="gmail-typ">SimpleITK</span><span class="gmail-pun">.</span><span class="gmail-pln">py </span><span class="gmail-kwd">in</span><span class="gmail-pln"> </span><span class="gmail-typ">Greater</span><span class="gmail-pun">(*</span><span class="gmail-pln">args</span><span class="gmail-pun">)</span><span class="gmail-pln">
</span><span class="gmail-lit">34345</span><span class="gmail-pln">
</span><span class="gmail-lit">34346</span><span class="gmail-pln"> </span><span class="gmail-str">"""
> 34347 return _SimpleITK.Greater(*args)
34348 class GridImageSource(ImageFilter_0):
34349 """</span><span class="gmail-pln">
</span><span class="gmail-typ">RuntimeError</span><span class="gmail-pun">:</span><span class="gmail-pln"> </span><span class="gmail-typ">Exception</span><span class="gmail-pln"> thrown </span><span class="gmail-kwd">in</span><span class="gmail-pln"> </span><span class="gmail-typ">SimpleITK</span><span class="gmail-pln"> </span><span class="gmail-typ">Greater</span><span class="gmail-pun">:</span><span class="gmail-pln"> </span><span class="gmail-pun">/</span><span class="gmail-pln">tmp</span><span class="gmail-pun">/</span><span class="gmail-typ">SimpleITK</span><span class="gmail-pun">/</span><span class="gmail-typ">Code</span><span class="gmail-pun">/</span><span class="gmail-typ">Common</span><span class="gmail-pun">/</span><span class="gmail-pln">include</span><span class="gmail-pun">/</span><span class="gmail-pln">sitkMemberFunctionFactory</span><span class="gmail-pun">.</span><span class="gmail-pln">hxx</span><span class="gmail-pun">:</span><span class="gmail-lit">209</span><span class="gmail-pun">:</span><span class="gmail-pln">
sitk</span><span class="gmail-pun">::</span><span class="gmail-pln">ERROR</span><span class="gmail-pun">:</span><span class="gmail-pln"> </span><span class="gmail-typ">Pixel</span><span class="gmail-pln"> type</span><span class="gmail-pun">:</span><span class="gmail-pln"> vector of </span><span class="gmail-lit">8</span><span class="gmail-pun">-</span><span class="gmail-pln">bit unsigned integer </span><span class="gmail-kwd">is</span><span class="gmail-pln"> </span><span class="gmail-kwd">not</span><span class="gmail-pln"> supported </span><span class="gmail-kwd">in</span><span class="gmail-pln"> </span><span class="gmail-lit">2D</span><span class="gmail-pln"> byN3itk6simple18GreaterImageFilterE</span></code></pre>
<p>I applied img = sitk.Image(img.GetSize(), sitk.sitkUInt8)</p>
<p>but I'm getting a black image</p>
<p>Is there any option like double(img) or im2bw in python.Will normalize work?</p>
</div>
<div class="gmail-post-taglist">
<a href="https://stackoverflow.com/questions/tagged/python" class="gmail-post-tag gmail-js-gps-track" title="show questions tagged 'python'" rel="tag"></a></div></div><br></div>