You can find the highest value and corresponding index as you &#39;draw&#39; the line. Pseudo-code:<div><br></div><div>itk::LineConstIterator&lt;ImageType&gt; it(image, startIndex, endIndex);</div><div>it.GoToBegin();</div>
<div>ImageType::PixelType maxValue = 0;</div><div>ImageType::IndexType maxIndex;</div><div>while(!it.IsAtEnd())</div><div>{</div><div>DrawLine();</div><div>if(it.Get() &gt; maxValue)</div><div>  {</div><div>  maxValue = it.Get();</div>
<div>  maxIndex = it.GetIndex();</div><div>  }</div><div>++it;</div><div>}</div><div><br><br><div class="gmail_quote">2011/5/2 LaMoOsH .. <span dir="ltr">&lt;<a href="mailto:xlolla28x@hotmail.com">xlolla28x@hotmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">



<div>
Hi<br>
 <br>
Thank you for your help. <br>
 <br>
No, i dont have a list of indices.<br>
I just used the LineConstIterator to draw a line between my two points. <br>
now i need check the gray-level value between these two points and find the pixel with the maximun gray-level value on that line.<br>
so i want my output to be an index.<br>
should i make an if loop inside the while loop that checks for the highest value?<br>
 <br>
Thanks . <br>
 <br>
 <br> <br>
&gt; Date: Sun, 1 May 2011 19:04:45 -0400<br>&gt; Subject: Re: [Insight-users] Gradient Magnitude<br>&gt; From: <a href="mailto:daviddoria@gmail.com" target="_blank">daviddoria@gmail.com</a><br>&gt; CC: <a href="mailto:xlolla28x@hotmail.com" target="_blank">xlolla28x@hotmail.com</a>; <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a><div class="im">
<br>&gt; <br>&gt; On Sun, May 1, 2011 at 6:57 PM, Neil Panjwani &lt;<a href="mailto:paniwani@gmail.com" target="_blank">paniwani@gmail.com</a>&gt; wrote:<br>&gt; &gt; If you know the indexes of the line, you could use the image region iterator<br>
&gt; &gt; with index to scan those indices and find the highest value using an if<br>&gt; &gt; statement.<br>&gt; <br>&gt; Here is an example of what Neil suggested (you&#39;d have to check<br>&gt; &quot;iterator.GetIndex() == AnyOfYourIndices&quot; for every pixel visited by<br>
&gt; the iterator):<br>&gt; <a href="http://www.vtk.org/Wiki/ITK/Examples/Iterators/ImageRegionIteratorWithIndex" target="_blank">http://www.vtk.org/Wiki/ITK/Examples/Iterators/ImageRegionIteratorWithIndex</a><br>&gt; <br>
&gt; If you have the end points of the line rather than the list of indices<br>&gt; composing the line, you could use this:<br>&gt; <a href="http://www.vtk.org/Wiki/ITK/Examples/Iterators/LineConstIterator" target="_blank">http://www.vtk.org/Wiki/ITK/Examples/Iterators/LineConstIterator</a><br>
&gt; <br>&gt; David<br>                          
                      </div></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.html" target="_blank">http://www.kitware.com/products/protraining.html</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>