Hello to all,<br> I am trying to develop my first filter in itk using visualstudio2010 and
 cmake. This filter devides my input image into neighborhoods of nine 
pixels and finds their maximum value. I have made some changes in my .txx file, but  I am still having some problems when I build the project and I would like some help:<br><br>#ifndef __itkmax_value_filter_txx<br>#define __itkmax_value_filter_txx<br>
 <br>#include &quot;max_value_filter.h&quot;<br>#include &quot;itkObjectFactory.h&quot;<br>#include &quot;itkImageRegionIterator.h&quot;<br>#include &quot;itkConstNeighborhoodIterator.h&quot;<br> <br>namespace itk<br>{<br>
 <br>template&lt; class TImage&gt;<br>void max_value_filter&lt; TImage&gt;<br>::GenerateData()<br>{<br>  typename TImage::ConstPointer input = this-&gt;GetInput();<br> <br>  typename TImage::Pointer output = this-&gt;GetOutput();<br>
  output-&gt;SetRegions(input-&gt;GetLargestPossibleRegion());<br>  output-&gt;Allocate();  <br> <br>  itk::ImageRegionIterator&lt;TImage&gt; outputIterator(output, output-&gt;GetLargestPossibleRegion());<br>  <br>  TImage::SizeType radius;<br>
  radius[0] = 1;<br>  radius[1] = 1;<br> <br>  itk::ConstNeighborhoodIterator&lt;TImage&gt; inputIterator(radius,input);<br><span style="background-color: rgb(255, 255, 102);">error C2664: &#39;itk::ConstNeighborhoodIterator&lt;TImage&gt;::ConstNeighborhoodIterator(const itk::ConstNeighborhoodIterator&lt;TImage&gt; &amp;)&#39; : cannot convert parameter 1 from &#39;itk::Size&lt;VDimension&gt;&#39; to &#39;const itk::ConstNeighborhoodIterator&lt;TImage&gt; &amp;</span><br>
 <br> <br><br><br>  while(!inputIterator.IsAtEnd())<br>    {<br><br>    for(unsigned int i = 1; i &lt; 9; i++)<br>      {<br>      TImage::IndexType index = inputIterator.GetIndex(i);<br>    <br>      }<br><br>    outputIterator.Set(index-&gt;GetMax());<br>
 <span style="background-color: rgb(255, 255, 102);">error C2065: &#39;index&#39; : undeclared identifier</span><br><span style="background-color: rgb(255, 255, 102);"> error C2227: left of &#39;-&gt;GetMax&#39; must point to class/struct/union/generic type</span><br style="background-color: rgb(255, 255, 102);">
<br>    ++inputIterator;<br>    ++outputIterator;<br>    }<br><br> <br>}<br> <br>}// end namespace<br> <br> <br>#endif<br><br><div class="gmail_quote">2011/3/1 Ryan Smith <span dir="ltr">&lt;<a href="mailto:ryanleesmith@gmail.com">ryanleesmith@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi John-<div>Did you get this up and running? Myself and others on the list would be interested in the final code you developed.  Thanks-</div>
<div>-Ryan<font color="#888888"><br><br></font><div class="gmail_quote"><div><div></div><div class="h5">On Mon, Feb 28, 2011 at 8:05 AM, john smith <span dir="ltr">&lt;<a href="mailto:mkitkinsightuser@gmail.com" target="_blank">mkitkinsightuser@gmail.com</a>&gt;</span> wrote:<br>

</div></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><div></div><div class="h5">I get these failures when I build my project.In the following lines I write again my code and I highlight all the failures under the line on which they have occured. Can you explain some of these mistakes as I am still influenced in C?<br>


<br><br>---------------------------<div><div>max_value_neighborhood.cxx-----------------------------<br>--------------------------------------------------------------------------------------------------<br>#include &quot;itkImage.h&quot;<br>



#include &quot;itkImageFileReader.h&quot;<br>#include &quot;itkImageFileWriter.h&quot;<br> <br>#include &quot;max_value_filter.h&quot;<br> <br>int main(int, char*[])<br>{<br>  // Setup types<br>  typedef itk::Image&lt;unsigned char, 2&gt;   ImageType;<br>



  typedef itk::max_value_filter&lt;ImageType&gt;  FilterType;<br> <br>  typedef itk::ImageFileReader&lt;ImageType&gt; ReaderType;<br>  ReaderType::Pointer reader = ReaderType::New();<br>  reader-&gt;SetFileName(&quot;test.png&quot;);<br>



  reader-&gt;Update();<br> <br>  // Create and the filter<br>  FilterType::Pointer filter = FilterType::New();<br></div><span style="background-color: rgb(255, 255, 102);"> see reference to class template instantiation &#39;itk::max_value_filter&lt;TImage&gt;&#39; being compiled</span><div>

<br>
  filter-&gt;SetInput(reader-&gt;GetOutput());<br>  filter-&gt;Update();<br> <br>  typedef  itk::ImageFileWriter&lt; ImageType  &gt; WriterType;<br>
  WriterType::Pointer writer = WriterType::New();<br>  writer-&gt;SetFileName(&quot;result.png&quot;);<br>  writer-&gt;SetInput(filter-&gt;GetOutput());<br>  writer-&gt;Update();<br> <br>  return EXIT_SUCCESS;<br>}<br><br>


<br><br>----------------------------</div><div><div>max_value_filter.txx--------------------------------<br>
-------------------------------------------------------------------------------------<br>#ifndef __itkmax_value_filter_txx<br>#define __itkmax_value_filter_txx<br> <br>#include &quot;max_value_filter.h&quot;<br>#include &quot;itkObjectFactory.h&quot;<br>



#include &quot;itkImageRegionIterator.h&quot;<br>#include &quot;itkConstNeighborhoodIterator.h&quot;<br> <br>namespace itk<br>{<br> <br>template&lt; class TImage&gt;<br>void max_value_filter&lt; TImage&gt;<br>::GenerateData()<br>



{<br></div><span style="background-color: rgb(255, 255, 102);"> while compiling class template member function &#39;void itk::max_value_filter&lt;TImage&gt;::GenerateData(void)&#39;</span><div><br>  typename TImage::ConstPointer input = this-&gt;GetInput();<br>


 <br>  typename TImage::Pointer output = this-&gt;GetOutput();<br>  output-&gt;SetRegions(input-&gt;GetLargestPossibleRegion());<br>  output-&gt;Allocate();  <br>
 <br>  itk::ImageRegionIterator&lt;TImage&gt; outputIterator(output, output-&gt;GetLargestPossibleRegion());<br>  itk::ImageRegionConstIterator&lt;TImage&gt; inputIterator(input, input-&gt;GetLargestPossibleRegion());<br>



 <br> <br><br><br>  while(!inputIterator.IsAtEnd())<br>    {<br><br>TImage::IndexType max = inputIterator.GetIndex(0);<br></div><span style="background-color: rgb(255, 255, 102);"> &#39;itk::ImageConstIterator&lt;TImage&gt;::GetIndex&#39; : function does not take 1 arguments</span><div>

<br>
<br>    for(unsigned int i = 1; i &lt; 9; i++)<br>      {<br>      TImage::IndexType index = inputIterator.GetIndex(i);<br>
     <br><br>        if (max&lt;index) <br></div><span style="background-color: rgb(255, 255, 102);">error C2676: binary &#39;&lt;&#39; : &#39;itk::Index&lt;VIndexDimension&gt;&#39; does not define this operator or a conversion to a type acceptable to the predefined operator</span><br>


                      {<br>                        max = inputIterator.GetIndex(i);  <br><span style="background-color: rgb(255, 255, 102);">error C2660: &#39;itk::ImageConstIterator&lt;TImage&gt;::GetIndex&#39; : function does not take 1 arguments</span>                     <br>

<div>
                      }<br><br> <br>      bool IsInBounds;<br>      inputIterator.GetPixel(i, IsInBounds);<br></div><span style="background-color: rgb(255, 255, 102);"> &#39;GetPixel&#39; : is not a member of &#39;itk::ImageRegionConstIterator&lt;TImage&gt;&#39;</span><div>

<br>

 <br>      }<br><br>    outputIterator.Set(inputIterator.Get(max));<br></div><span style="background-color: rgb(255, 255, 102);">error C2660: &#39;itk::ImageConstIterator&lt;TImage&gt;::Get&#39; : function does not take 1 arguments</span><div>

<br>
<br>    ++inputIterator;<br>    ++outputIterator;<br>    }<br><br> <br>}<br> <br>}// end namespace<br> <br> <br>#endif</div></div><br></div><br><br><br><br><div class="gmail_quote">2011/2/28 David Doria <span dir="ltr">&lt;<a href="mailto:daviddoria@gmail.com" target="_blank">daviddoria@gmail.com</a>&gt;</span><div>

<div></div><div><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="gmail_quote"><div>On Mon, Feb 28, 2011 at 10:22 AM, john smith <span dir="ltr">&lt;<a href="mailto:mkitkinsightuser@gmail.com" target="_blank">mkitkinsightuser@gmail.com</a>&gt;</span> wrote:<br>


<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi to all,<br><br> I am trying to develop my first filter in itk using visualstudio2010 and cmake. This filter devides my input image into neighborhoods of nine pixels and finds their maximum value. Then, this value is transfered to one pixel of my output image. I have written the following code, but I have some failures that I cannot understand. Could someone help me to overide my problems? Furthermore, I would like to know if it is possible to write my own filter only with .cxx and .txt files, like<i> <a href="http://www.itk.org/Wiki/ITK/Examples/Iterators/ConstNeighborhoodIterator" target="_blank">http://www.itk.org/Wiki/ITK/Examples/Iterators/ConstNeighborhoodIterator</a></i>. <br>




<br>Thanks<br><br></blockquote><div> </div></div>Can you describe the failures? Are they compiler errors? Crashes? Incorrect results?<br><br><div>David </div></div>
<br>
</blockquote></div></div></div><br>
<br></div></div><div class="im">_____________________________________<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></div></blockquote></div><br></div>
</blockquote></div><br>