ITK/Examples/Images/Index

From KitwarePublic

Jump to: navigation, search

This class is used to represent a location in an Image.

Index.cxx

#include "itkIndex.h"
 
int main(int, char *[])
{
  itk::Index<2> index;
 
  // Method 1 - set both index[0] and index[1] to the same value (in this case, 0).
  index.Fill(0);
  std::cout << index << std::endl;
 
  // Method 2 - set each component of the index individually.
  index[0] = 1;
  index[1] = 2;
 
  std::cout << index << std::endl;
 
  return EXIT_SUCCESS;
}

CMakeLists.txt

cmake_minimum_required(VERSION 2.8)
 
project(Index)
 
find_package(ITK REQUIRED)
include(${ITK_USE_FILE})
 
add_executable(Index Index.cxx)
 
if( "${ITK_VERSION_MAJOR}" LESS 4 )
  target_link_libraries(Index ITKReview ${ITK_LIBRARIES})
else( "${ITK_VERSION_MAJOR}" LESS 4 )
  target_link_libraries(Index ${ITK_LIBRARIES})
endif( "${ITK_VERSION_MAJOR}" LESS 4 )
Personal tools