Hi Sergio, <div><br></div><div>I don&#39;t see any problems with the code you<div>attached. What you are observing might be </div><div>due to code you have not attached. Are you </div><div>making sure to call update on the filter that </div>
<div>gives you the label map prior to this piece of </div><div>code? That would be my </div><div>first guess. My second guess would be that </div><div>the foreground/background values you use </div><div>in your binaryimagetolabelmap filter might be </div>
<div>set incorrectly resulting in an empty labelmap. </div><div><br></div><div>In any case, it is always a good idea to attach </div><div>minimal code that compiles and illustrates the </div><div>problem with the input image you use. </div>
<div><br></div><div>Let us know, </div><div>Cagatay</div><div><br><div class="gmail_quote">On Thu, Jun 21, 2012 at 9:51 AM, Sergio Vera <span dir="ltr">&lt;<a href="mailto:sergio.vera@alma3d.com" target="_blank">sergio.vera@alma3d.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello all!<div><br></div><div>I have a LabelMap Image and I want to remove all labels except the ones that have a seed.</div>
<div><br></div><div>Sadly, </div><div><br></div><div><font face="courier new, monospace"><div>std::vector&lt;size_t&gt; selectedLabels;<span style="white-space:pre-wrap">                </span></div>
<div>BOOST_FOREACH(const ITKImgInType::IndexType&amp; seed, d_seeds) {</div><div>  ITKImgInType::PixelType value = labelMap-&gt;GetPixel(seed);</div><div>  if (value != 0) {</div><div>    selectedLabels.push_back(value);<span style="white-space:pre-wrap">                                                        </span></div>

<div>    d_os &lt;&lt; &quot;Label &quot; &lt;&lt; value &lt;&lt; &quot; has been selected as a valid label.\n&quot;;</div><div>  } else {</div><div>    d_os &lt;&lt; &quot;0 found on &quot; &lt;&lt; seed &lt;&lt; &quot; :( \n&quot;;</div>

<div>  }</div><div>}</div></font></div><div><br></div><div>always return a zero value, even if there should be a correct label in that seed position (I&#39;ve checked that on the binary image that generated the LabelMap). The label map has over 1000 LabelObjects</div>

<div><br></div><div>Theoretically LabelImages support the GetPixel() Method (even if it&#39;s slower).</div><div><br></div><div>Any ideas on why this may be happening? I&#39;m using itk 3.20.0 on windows.</div><div><br></div>

<div>Thanks in advance<span class="HOEnZb"><font color="#888888"><br clear="all"><div><br></div>-- <br>Sergio Vera<br><br> Alma IT Systems<br> C/ Vilana, 4B, 4º 1ª<br> 08022 Barcelona<br> T. <a href="tel:%28%2B34%29%20932%20380%20592" value="+34932380592" target="_blank">(+34) 932 380 592</a><br>
 <a href="http://www.alma3d.com" target="_blank">www.alma3d.com</a><br>

</font></span></div>
<br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.php" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br></div></div>