[Insight-users] Getting PixelType& from VectorImage

robert tamburo robert.tamburo at gmail.com
Thu Mar 24 12:26:34 EDT 2011


Hi Eduardo,  Value() cannot be used with a VectorImage. Try doing:

itk::VariableLengthVector<float> vec = oo.Get();
float value = vec[2];

or

float vec = oo.Get()[2];


On Thu, Mar 24, 2011 at 12:13 PM, Eduardo Suarez-Santana <
esuarez at itccanarias.org> wrote:

> 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})
>
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110324/7201c944/attachment.htm>


More information about the Insight-users mailing list