ITK/Examples/SimpleOperations/DistanceBetweenIndices
From KitwarePublic
< ITK | Examples
Jump to navigationJump to search
Revision as of 00:58, 12 February 2011 by Daviddoria (talk | contribs) (Created page with "Compute the distance between two indices. ==DistanceBetweenIndices.cxx== <source lang="cpp"> #include "itkPoint.h" #include "itkIndex.h" #include <iostream> #include <string> ...")
Compute the distance between two indices.
DistanceBetweenIndices.cxx
<source lang="cpp">
- include "itkPoint.h"
- include "itkIndex.h"
- include <iostream>
- include <string>
int main(int, char *[]) {
itk::Index<2> pixel1; pixel1.Fill(2);
itk::Index<2> pixel2; pixel2.Fill(4);
itk::Point<double,2> p1; p1[0] = pixel1[0]; p1[1] = pixel1[1];
itk::Point<double,2> p2; p2[0] = pixel2[0]; p2[1] = pixel2[1];
double distance = p0.EuclideanDistanceTo(p1); std::cout << "Distance: " << distance << std::endl;
return EXIT_SUCCESS;
}
</source>
CMakeLists.txt
<source lang="cmake"> cmake_minimum_required(VERSION 2.6)
PROJECT(DistanceBetweenIndices)
FIND_PACKAGE(ITK REQUIRED) INCLUDE(${ITK_USE_FILE})
ADD_EXECUTABLE(DistanceBetweenIndices DistanceBetweenIndices.cxx) TARGET_LINK_LIBRARIES(DistanceBetweenIndices ITKNumerics)
</source>