<meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; "><div class="im" style="color: rgb(80, 0, 80); ">
<span class="Apple-style-span" style="font-family: arial; font-size: small; border-collapse: separate; color: rgb(0, 0, 0); ">On Mon, Feb 28, 2011 at 11:05 AM, john smith <span dir="ltr"><<a href="mailto:mkitkinsightuser@gmail.com">mkitkinsightuser@gmail.com</a>></span> wrote:</span></div>
</span><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">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 class="im">max_value_neighborhood.cxx-----------------------------<br>--------------------------------------------------------------------------------------------------<br>#include "itkImage.h"<br>
#include "itkImageFileReader.h"<br>#include "itkImageFileWriter.h"<br> <br>#include "max_value_filter.h"<br> <br>int main(int, char*[])<br>{<br> // Setup types<br> typedef itk::Image<unsigned char, 2> ImageType;<br>
typedef itk::max_value_filter<ImageType> FilterType;<br> <br> typedef itk::ImageFileReader<ImageType> ReaderType;<br> ReaderType::Pointer reader = ReaderType::New();<br> reader->SetFileName("test.png");<br>
reader->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 'itk::max_value_filter<TImage>' being compiled</span><div class="im">
<br>
filter->SetInput(reader->GetOutput());<br> filter->Update();<br> <br> typedef itk::ImageFileWriter< ImageType > WriterType;<br>
WriterType::Pointer writer = WriterType::New();<br> writer->SetFileName("result.png");<br> writer->SetInput(filter->GetOutput());<br> writer->Update();<br> <br> return EXIT_SUCCESS;<br>}<br><br>
<br><br>----------------------------</div><div><div class="im">max_value_filter.txx--------------------------------<br>
-------------------------------------------------------------------------------------<br>#ifndef __itkmax_value_filter_txx<br>#define __itkmax_value_filter_txx<br> <br>#include "max_value_filter.h"<br>#include "itkObjectFactory.h"<br>
#include "itkImageRegionIterator.h"<br>#include "itkConstNeighborhoodIterator.h"<br> <br>namespace itk<br>{<br> <br>template< class TImage><br>void max_value_filter< TImage><br>::GenerateData()<br>
{<br></div><span style="background-color:rgb(255, 255, 102)"> while compiling class template member function 'void itk::max_value_filter<TImage>::GenerateData(void)'</span><div class="im"><br> typename TImage::ConstPointer input = this->GetInput();<br>
<br> typename TImage::Pointer output = this->GetOutput();<br> output->SetRegions(input->GetLargestPossibleRegion());<br> output->Allocate(); <br>
<br> itk::ImageRegionIterator<TImage> outputIterator(output, output->GetLargestPossibleRegion());<br> itk::ImageRegionConstIterator<TImage> inputIterator(input, input->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)"> 'itk::ImageConstIterator<TImage>::GetIndex' : function does not take 1 arguments</span><div class="im">
<br>
<br> for(unsigned int i = 1; i < 9; i++)<br> {<br> TImage::IndexType index = inputIterator.GetIndex(i);<br>
<br><br> if (max<index) <br></div><span style="background-color:rgb(255, 255, 102)">error C2676: binary '<' : 'itk::Index<VIndexDimension>' 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: 'itk::ImageConstIterator<TImage>::GetIndex' : function does not take 1 arguments</span> <br>
<div class="im">
}<br><br> <br> bool IsInBounds;<br> inputIterator.GetPixel(i, IsInBounds);<br></div><span style="background-color:rgb(255, 255, 102)"> 'GetPixel' : is not a member of 'itk::ImageRegionConstIterator<TImage>'</span><div class="im">
<br>
<br> }<br><br> outputIterator.Set(inputIterator.Get(max));<br></div><span style="background-color:rgb(255, 255, 102)">error C2660: 'itk::ImageConstIterator<TImage>::Get' : function does not take 1 arguments</span><div class="im">
<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"><<a href="mailto:daviddoria@gmail.com" target="_blank">daviddoria@gmail.com</a>></span><div>
<div></div><div class="h5"><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"><<a href="mailto:mkitkinsightuser@gmail.com" target="_blank">mkitkinsightuser@gmail.com</a>></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></blockquote><div><br></div><div>Here are a couple of answers to get you going:</div><div> </div><div>1)</div></div><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; "><div class="im" style="color: rgb(80, 0, 80); ">
TImage::IndexType max = inputIterator.GetIndex(0);<br></div><span style="background-color: rgb(255, 255, 102); "> 'itk::ImageConstIterator<TImage>::GetIndex' : function does not take 1 arguments</span></span></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><br></span></font></div><div><span style="background-color: rgb(255, 255, 102); "></span><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">should be:</span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;"><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="color: rgb(80, 0, 80); font-size: 13px; ">TImage::IndexType max = inputIterator.GetIndex();</span><br>
</span></font><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; "><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; ">2)</span></font></div>
<div><span style="background-color: rgb(255, 255, 102); "></span><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; "><meta http-equiv="content-type" content="text/html; charset=utf-8"><span class="Apple-style-span" style="font-size: 13px; "><div class="im" style="color: rgb(80, 0, 80); ">
outputIterator.Set(inputIterator.Get(max));<br></div><span style="background-color: rgb(255, 255, 102); ">error C2660: 'itk::ImageConstIterator<TImage>::Get' : function does not take 1 arguments</span></span></span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; "><span class="Apple-style-span" style="font-size: 13px; "><span style="background-color: rgb(255, 255, 102); "><br>
</span></span></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse;">should be:</span></font></div><div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(80, 0, 80); font-family: arial, sans-serif; font-size: 13px; "> outputIterator.Set(inputIterator.Get());</span></div>
<div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(80, 0, 80); font-family: arial, sans-serif; font-size: 13px; "><br></span></div><div><span class="Apple-style-span" style="border-collapse: collapse; color: rgb(80, 0, 80); font-family: arial, sans-serif; font-size: 13px; ">3)</span></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; "><span class="Apple-style-span" style="font-size: 13px; "><span style="background-color: rgb(255, 255, 102); "><meta http-equiv="content-type" content="text/html; charset=utf-8"><div class="im" style="color: rgb(80, 0, 80); ">
bool IsInBounds;<br> inputIterator.GetPixel(i, IsInBounds);<br></div><span style="background-color: rgb(255, 255, 102); "> 'GetPixel' : is not a member of 'itk::ImageRegionConstIterator<TImage>'</span></span></span></span></font></div>
<div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; "><br></span></font></div><div><font class="Apple-style-span" face="arial, sans-serif"><span class="Apple-style-span" style="border-collapse: collapse; "><span style="background-color: rgb(255, 255, 102); "></span>GetPixels is only defined for Neighborhood iterators.</span></font><br>
<br>David</div></div>