<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
code
{mso-style-priority:99;
font-family:"Courier New";}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;}
span.gmail-kwd
{mso-style-name:gmail-kwd;}
span.gmail-pln
{mso-style-name:gmail-pln;}
span.gmail-typ
{mso-style-name:gmail-typ;}
span.gmail-pun
{mso-style-name:gmail-pun;}
span.gmail-str
{mso-style-name:gmail-str;}
span.gmail-lit
{mso-style-name:gmail-lit;}
span.gmail-com
{mso-style-name:gmail-com;}
span.EmailStyle29
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hello Leena,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The ITK users mailing list is deprecated. In the future, please post questions to the ITK discourse forum
<a href="https://discourse.itk.org/">https://discourse.itk.org/</a><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"> hope this helps<o:p></o:p></p>
<p class="MsoNormal"> Ziv<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:12.0pt;color:black">From: </span></b><span style="font-size:12.0pt;color:black">leena m <leenzz.m@gmail.com><br>
<b>Date: </b>Wednesday, June 27, 2018 at 11:38 PM<br>
<b>To: </b>"insight-users@itk.org" <insight-users@itk.org><br>
<b>Subject: </b>[ITK-users] post a message<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
</div>
<div>
<div>
<p>i'm a beginner in python wen i apply thresholding i'm getting error<o:p></o:p></p>
<pre><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<o:p></o:p></span></pre>
<pre><span class="gmail-pln">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"><o:p></o:p></span></pre>
<pre><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><o:p></o:p></pre>
<p>i'm getting error as<o:p></o:p></p>
<pre><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"><o:p></o:p></span></pre>
<pre><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"><o:p></o:p></span></pre>
<pre><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"><o:p></o:p></span></pre>
<pre><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"><o:p></o:p></span></pre>
<pre><span class="gmail-pln"><o:p> </o:p></span></pre>
<pre><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"><o:p></o:p></span></pre>
<pre><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"><o:p></o:p></span></pre>
<pre><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"><o:p></o:p></span></pre>
<pre><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"><o:p></o:p></span></pre>
<pre><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"><o:p></o:p></span></pre>
<pre><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"><o:p></o:p></span></pre>
<pre><span class="gmail-pln"><o:p> </o:p></span></pre>
<pre><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"><o:p></o:p></span></pre>
<pre><span class="gmail-pln"> </span><span class="gmail-lit">34345</span><span class="gmail-pln"> <o:p></o:p></span></pre>
<pre><span class="gmail-pln"> </span><span class="gmail-lit">34346</span><span class="gmail-pln"> </span><span class="gmail-str">"""<o:p></o:p></span></pre>
<pre><span class="gmail-str">> 34347 return _SimpleITK.Greater(*args)<o:p></o:p></span></pre>
<pre><span class="gmail-str"> 34348 class GridImageSource(ImageFilter_0):<o:p></o:p></span></pre>
<pre><span class="gmail-str"> 34349 """</span><span class="gmail-pln"><o:p></o:p></span></pre>
<pre><span class="gmail-pln"><o:p> </o:p></span></pre>
<pre><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"><o:p></o:p></span></pre>
<pre><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><o:p></o:p></pre>
<p>I applied img = sitk.Image(img.GetSize(), sitk.sitkUInt8)<o:p></o:p></p>
<p>but I'm getting a black image<o:p></o:p></p>
<p>Is there any option like double(img) or im2bw in python.Will normalize work?<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</body>
</html>