<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">David,<div><br></div><div>If you are still having problems with the<span class="Apple-style-span" style="font-family: arial, helvetica, clean, sans-serif; font-size: small; line-height: 15px; ">&nbsp;ImageToListSampleAdaptor you can</span></div><div><span class="Apple-style-span" style="font-family: arial, helvetica, clean, sans-serif; font-size: small; line-height: 15px; "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, helvetica, clean, sans-serif; font-size: small; line-height: 15px; ">create an image with pixel intensity values to be correlated with the pixel label&nbsp;</span></div><div><span class="Apple-style-span" style="font-family: arial, helvetica, clean, sans-serif; font-size: small; line-height: 15px; "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, helvetica, clean, sans-serif;
 font-size: small; line-height: 15px; ">identified using the classifier, that is a colored image with intensity values&nbsp;</span></div><div><span class="Apple-style-span" style="font-family: arial, helvetica, clean, sans-serif; font-size: small; line-height: 15px; "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, helvetica, clean, sans-serif; font-size: small; line-height: 15px; ">which distinguish different pixel classes then iterate over that image and get&nbsp;</span></div><div><span class="Apple-style-span" style="font-family: arial, helvetica, clean, sans-serif; font-size: small; line-height: 15px; "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, helvetica, clean, sans-serif; font-size: small; line-height: 15px; ">the coordinates of any pixel knowing its label (i.e. class which is represented&nbsp;</span></div><div><span class="Apple-style-span" style="font-family: arial, helvetica,
 clean, sans-serif; font-size: small; line-height: 15px; "><br></span></div><div><span class="Apple-style-span" style="font-family: arial, helvetica, clean, sans-serif; font-size: small; line-height: 15px; ">with a color). The code for that would be pretty simple as follows:</span></div><div><span class="Apple-style-span" style="font-family: arial, helvetica, clean, sans-serif; font-size: small; line-height: 15px; "><br></span></div><div><font class="Apple-style-span" face="arial, helvetica, clean, sans-serif"><span class="Apple-style-span" style="line-height: 15px; font-size: small;"><div>int ClassLabel = 0;</div><div><br></div><div>for ( iterator.GoToBegin(); !iterator.IsAtEnd(); ++iterator )</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp;{</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&nbsp;&nbsp;int intensity = interator.Get();</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">
        </span> &nbsp;if ( intensity == ClassLabel )</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>{</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                                        </span>index =&nbsp;iterator.GetIndex();</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;std::cout &lt;&lt; " Class 1 Pixel Index = " &lt;&lt; index &lt;&lt; std::endl;</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                                </span>}</div><div><br></div><div>&nbsp;&nbsp; &nbsp; &nbsp;}</div><div><br></div><div>Regards,</div><div><br></div><div>Dawood</div></span></font><br>--- On <b>Fri, 11/12/10, David Doria <i>&lt;daviddoria@gmail.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: David Doria
 &lt;daviddoria@gmail.com&gt;<br>Subject: Re: [Insight-users] Applying labels from KmeansModelEstimator toinput image pixels<br>To: "Magnotta, Vincent A" &lt;vincent-magnotta@uiowa.edu&gt;<br>Cc: "Dawood Masslawi" &lt;davoud_zzz@yahoo.com&gt;, insight-users@itk.org<br>Date: Friday, November 12, 2010, 10:15 AM<br><br><div class="plainMail">On Thu, Nov 11, 2010 at 10:25 PM, Magnotta, Vincent A<br>&lt;<a ymailto="mailto:vincent-magnotta@uiowa.edu" href="/mc/compose?to=vincent-magnotta@uiowa.edu">vincent-magnotta@uiowa.edu</a>&gt; wrote:<br>&gt; I would suggest that you look at itkScalarImageKmeansImageFilter.txx. This<br>&gt; is essentially performing this classification using scalar images. A<br>&gt; ListSampleAdaptor is used to classify the image. The algorithm then iterates<br>&gt; over the Samples setting the image. Since this is a Adaptor class, it is<br>&gt; assumed that the ordering of the samples is the same as the image.<br>&gt;<br>&gt;
 Vince<br><br>Thanks Vince. I think I have the big picture structure now, but I must<br>still be doing something incorrectly.<br><br>Here is my current attempt:<br><a href="http://www.itk.org/Wiki/ITK/Examples/Broken/Statistics/ImageKmeansModelEstimator" target="_blank">http://www.itk.org/Wiki/ITK/Examples/Broken/Statistics/ImageKmeansModelEstimator</a><br><br>It segfaults on the first call to<br><br>membershipIterator.GetClassLabel();<br><br>Any ideas why that would happen?<br><br>Thanks,<br><br>David<br></div></blockquote></div></td></tr></table><br>