ITK/Examples/ImageProcessing/LinearInterpolateImageFunction: Difference between revisions
From KitwarePublic
Jump to navigationJump to search
Daviddoria (talk | contribs) (Created page with "==LinearInterpolateImageFunction.cxx== <source lang="cpp"> #include <itkImage.h> #include <itkContinuousIndex.h> #include <itkLinearInterpolateImageFunction.h> typedef itk::Imag...") |
|||
Line 1: | Line 1: | ||
==LinearInterpolateImageFunction.cxx== | ==LinearInterpolateImageFunction.cxx== | ||
<source lang="cpp"> | <source lang="cpp"> | ||
#include | #include "itkImage.h" | ||
#include | #include "itkContinuousIndex.h" | ||
#include | #include "itkLinearInterpolateImageFunction.h" | ||
typedef itk::Image<unsigned char, 1> ImageType; | typedef itk::Image<unsigned char, 1> ImageType; | ||
void CreateImage(ImageType::Pointer image); | static void CreateImage(ImageType::Pointer image); | ||
int main(int, char*[]) | int main(int, char*[]) | ||
Line 53: | Line 52: | ||
} | } | ||
</source> | </source> | ||
Revision as of 05:22, 16 November 2010
LinearInterpolateImageFunction.cxx
<source lang="cpp">
- include "itkImage.h"
- include "itkContinuousIndex.h"
- include "itkLinearInterpolateImageFunction.h"
typedef itk::Image<unsigned char, 1> ImageType;
static void CreateImage(ImageType::Pointer image);
int main(int, char*[]) {
ImageType::Pointer image = ImageType::New(); CreateImage(image);
itk::ContinuousIndex<double, 1> pixel; pixel[0] = 1.3;
itk::LinearInterpolateImageFunction<ImageType, double>::Pointer interpolator = itk::LinearInterpolateImageFunction<ImageType, double>::New(); interpolator->SetInputImage(image); std::cout << "Value at 1.3: " << interpolator->EvaluateAtContinuousIndex(pixel) << std::endl;
return EXIT_SUCCESS;
}
void CreateImage(ImageType::Pointer image)
{
// Create a 1D image ImageType::RegionType region; ImageType::IndexType start; start[0] = 0;
ImageType::SizeType size; size[0] = 10; region.SetSize(size); region.SetIndex(start);
image->SetRegions(region); image->Allocate();
for(unsigned int i = 0; i < 10; i++) { ImageType::IndexType pixelIndex; pixelIndex[0] = i;
image->SetPixel(pixelIndex, i*10); }
} </source>
CMakeLists.txt
<source lang="cmake"> cmake_minimum_required(VERSION 2.6)
PROJECT(LinearInterpolateImageFunction)
FIND_PACKAGE(ITK REQUIRED) INCLUDE(${ITK_USE_FILE})
ADD_EXECUTABLE(LinearInterpolateImageFunction LinearInterpolateImageFunction.cxx) TARGET_LINK_LIBRARIES(LinearInterpolateImageFunction ITKCommon)
</source>