[Insight-users] Getting PixelType& from VectorImage
Eduardo Suarez-Santana
esuarez at itccanarias.org
Thu Mar 24 12:13:37 EDT 2011
I'd like to assign a component of a pixel of a VectorImage. I'm trying
to use the Value() method from an iterator without success. It works
with Image type, but I get a compiler error with VectorImage.
How can I assign just one component of a VectorImage?
Thanks,
-Eduardo
++++++++++++++++ testVector.cxx
#include "itkImageRegionIterator.h"
#include "itkVectorImage.h"
int main(int argc, char *argv[] )
{
typedef itk::VectorImage<float,2> ImageType;
//typedef itk::Image<float,2> ImageType;
ImageType::Pointer image = ImageType::New();
ImageType::SizeType regionSize;
regionSize[0] = 5;
regionSize[1] = 4;
ImageType::IndexType regionIndex;
regionIndex[0] = 0;
regionIndex[1] = 0;
ImageType::RegionType region;
region.SetSize(regionSize);
region.SetIndex(regionIndex);
// comment next line to try with itk::Image
image->SetVectorLength( 5 );
image->SetRegions( region );
image->Allocate();
itk::ImageRegionIterator<ImageType> oo( image, region );
oo.GoToBegin();
while( !oo.IsAtEnd() )
{
// what I would like to do is something like
//oo.Value()[2]=29837.0;
// next line prints a compiler error when using VectorImage
oo.Value();
++oo;
}
}
+++++++++++++++ CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
find_package(ITK)
if(ITK_FOUND)
include(${ITK_USE_FILE})
else(ITK_FOUND)
message(FATAL_ERROR "Please set ITK_DIR.")
endif(ITK_FOUND)
project(testVector)
add_executable(testVector testVector.cxx)
target_link_libraries(testVector ${ITK_LIBRARIES})
More information about the Insight-users
mailing list