[Insight-users] (no subject)
john smith
mkitkinsightuser at gmail.com
Tue Mar 1 06:46:43 EST 2011
Hello to everyone,
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)
thnaks in advance
---------------------------------
max_value_neighborhood,cxx---------------------------------
-------------------------------------------------------------------------------------------------
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkConstNeighborhoodIterator.h"
int main(int argc, char*argv[])
{
unsigned int max, index;
if(argc < 2)
{
std::cerr << "Required: filename" << std::endl;
return EXIT_FAILURE;
}
typedef itk::Image<unsigned char, 2> ImageType;
typedef itk::ImageFileReader<ImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(argv[1]);
reader->Update();
ImageType::Pointer image = reader->GetOutput();
ImageType::SizeType regionSize;
regionSize[0] = 50;
regionSize[1] = 50;
ImageType::IndexType regionIndex;
regionIndex[0] = 0;
regionIndex[1] = 0;
ImageType::RegionType region;
region.SetSize(regionSize);
region.SetIndex(regionIndex);
ImageType::SizeType radius;
radius[0] = 1;
radius[1] = 1;
itk::ConstNeighborhoodIterator<ImageType> inputIterator(radius,
image,region);
while(!inputIterator.IsAtEnd())
{
ImageType::IndexType max = inputIterator.GetIndex(0);
for(unsigned int i = 1; i < 9; i++)
{
ImageType::IndexType index = inputIterator.GetIndex(i);
if ( max < index)
{
max =
inputIterator.GetIndex(i);
}
}
std::cout << max << std::endl;
++inputIterator;
}
return EXIT_SUCCESS;
}
----------------------------------------------CMakeLists.txt--------------------------
--------------------------------------------------------------------------------------
cmake_minimum_required(VERSION 2.6)
PROJECT(max_value_neighborhood)
FIND_PACKAGE(ITK REQUIRED)
INCLUDE(${ITK_USE_FILE})
ADD_EXECUTABLE(max_value_neighborhood max_value_neighborhood.cxx)
TARGET_LINK_LIBRARIES(max_value_neighborhood
ITKNumerics ITKBasicFilters ITKCommon ITKIO)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110301/87a9e3d0/attachment-0001.htm>
More information about the Insight-users
mailing list