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><br>--------------------------------- max_value_neighborhood,cxx---------------------------------<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;<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> <br> while(!inputIterator.IsAtEnd())<br>
{<br><br>ImageType::IndexType max = inputIterator.GetIndex(0);<br><br> for(unsigned int i = 1; i < 9; i++)<br> {<br> ImageType::IndexType index = inputIterator.GetIndex(i);<br><br><br> if ( max < index) <br>
{<br> max = inputIterator.GetIndex(i); <br> }<br><br> <br> <br> <br> }<br><br> std::cout << max << std::endl;<br>
++inputIterator;<br> <br> }<br> <br> <br> return EXIT_SUCCESS;<br>}<br><br><br><br>----------------------------------------------CMakeLists.txt--------------------------<br>--------------------------------------------------------------------------------------<br>
cmake_minimum_required(VERSION 2.6)<br> <br>PROJECT(max_value_neighborhood)<br> <br>FIND_PACKAGE(ITK REQUIRED)<br>INCLUDE(${ITK_USE_FILE})<br> <br>ADD_EXECUTABLE(max_value_neighborhood max_value_neighborhood.cxx)<br>TARGET_LINK_LIBRARIES(max_value_neighborhood <br>
ITKNumerics ITKBasicFilters ITKCommon ITKIO)<br>