Hello,<br><br>Well, I have made all the changes and my program gives me (I think) correct results. But I have some questions to continue my project. As a following step, I want to write all my max values from every neighborhood iterator in a single pixel of an output image. How can organize my max values as an object (maybe by creating a new region iterator?), to put it through a new writer filter, in order to take my output image? Also, supposing that I have taken my output image, then this project which will be consisted of an .cxx and .txt file format (for visual studio and cmake), could be considered as a new developed Filter?<br>
<br>Thanks <br><br>#include "itkImage.h"<br>#include "itkImageFileReader.h"<br><br><br>#include "itkConstNeighborhoodIterator.h"<br> <br>int main(int argc, char*argv[])<br>{<br> unsigned int max, index, counter;<br>
<br> if(argc < 2)<br> {<br> std::cerr << "Required: filename" << std::endl;<br> return EXIT_FAILURE;<br> }<br> <br> typedef itk::Image<unsigned char, 2> ImageType;<br> <br>
typedef itk::ImageFileReader<ImageType> ReaderType;<br> ReaderType::Pointer reader = ReaderType::New();<br> reader->SetFileName(argv[1]);<br> reader->Update();<br> <br> ImageType::Pointer image = reader->GetOutput();<br>
<br> ImageType::SizeType regionSize;<br> regionSize[0] = 50;<br> regionSize[1] = 50;<br> <br> ImageType::IndexType regionIndex;<br> regionIndex[0] = 0;<br> regionIndex[1] = 0;<br> <br> ImageType::RegionType region;<br>
region.SetSize(regionSize);<br> region.SetIndex(regionIndex);<br> <br> ImageType::SizeType radius;<br> radius[0] = 1;<br> radius[1] = 1;<br><br> <br> itk::ConstNeighborhoodIterator<ImageType> inputIterator(radius, image,region); <br>
<br><br> counter=0;<br> while(!inputIterator.IsAtEnd())<br> {<br><br> max = inputIterator.GetPixel(0);<br> counter = counter+1;<br> for(unsigned int i = 1; i < 9; i++)<br> {<br><br> index = inputIterator.GetPixel(i);<br>
<br> if ( max < index) <br> {<br> max == inputIterator.GetPixel(i); <br> }<br> <br> }<br><br> std::cout << max << std::endl;<br>
<br> ++inputIterator;<br> <br> }<br> <br> std::cout << counter << " counter" << std::endl;<br> <br><br> return EXIT_SUCCESS;<br>}<br><br><div class="gmail_quote">2011/3/1 David Doria <span dir="ltr"><<a href="mailto:daviddoria@gmail.com">daviddoria@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div>On Tue, Mar 1, 2011 at 6:46 AM, john smith <span dir="ltr"><<a href="mailto:mkitkinsightuser@gmail.com" target="_blank">mkitkinsightuser@gmail.com</a>></span> wrote:</div>
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hello to everyone,<br>I am trying to read an input image, using a reader object. Then devide the image, using neighborhood iterator and finally, find the max value of every neighborhood iterator and get it on my command prompt window. I think that this can be done wtith the following code, but when I build it, it doesn't recognise the ' < ' operator. Can somebody help me? (I use visualstudoi 2010 and Cmake)<br>
<br>thnaks in advance<br><br></blockquote><div><br></div><div>You are trying to compare two Index objects, for which the < operator is not implemented. I think you want to change GetIndex to GetPixel in both cases:</div>
<div><br></div><div>ImageType::IndexType max = inputIterator.GetIndex(0);</div><div>...</div><div>ImageType::IndexType index = inputIterator.GetIndex(i);</div>
<div><br></div><div>David </div></div><br>
</blockquote></div><br>