ITK/Examples/VectorImages/VectorImage

From KitwarePublic
< ITK‎ | Examples
Revision as of 19:12, 21 October 2010 by Daviddoria (talk | contribs) (Created page with "==VectorImage.cxx== <source lang="cpp"> #include "itkVectorImage.h" int main(int, char *[]) { typedef itk::VectorImage<float, 2> ImageType; ImageType::RegionType region; ...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

VectorImage.cxx

<source lang="cpp">

  1. include "itkVectorImage.h"

int main(int, char *[]) {

 typedef itk::VectorImage<float, 2>  ImageType;
 ImageType::RegionType region;
 ImageType::IndexType start;
 start[0] = 0;
 start[1] = 0;
 ImageType::SizeType size;
 size[0] = 2;
 size[1] = 3;
 region.SetSize(	size);
 region.SetIndex(start);
 ImageType::Pointer image = ImageType::New();
 image->SetRegions(region);
 image->SetVectorLength(2);
 image->Allocate();
 ImageType::IndexType pixelIndex;
 pixelIndex[0] = 1;
 pixelIndex[1] = 1;
 ImageType::PixelType pixelValue = image->GetPixel(pixelIndex);
 std::cout << "pixel (1,1) = " << pixelValue << std::endl;
 return EXIT_SUCCESS;

} </source>

CMakeLists.txt

<source lang="cmake"> cmake_minimum_required(VERSION 2.6)

PROJECT(VectorImage)

FIND_PACKAGE(ITK REQUIRED) INCLUDE(${ITK_USE_FILE})

ADD_EXECUTABLE(VectorImage VectorImage.cxx) TARGET_LINK_LIBRARIES(VectorImage ITKIO ITKBasicFilters ITKCommon )

</source>