static void CreateImage(ImageType::Pointer image);
int main(int argc, char *argv[])
{
ImageType::Pointer image = ImageType::New();
CreateImage(image);
TranslationTransformType::Pointer transform =
TranslationTransformType::New();
TranslationTransformType::OutputVectorType translation;
translation[0] = 10;
translation[1] = 20;
transform->Translate(translation);
ResampleImageFilterType::Pointer resampleFilter = ResampleImageFilterType::New();
resampleFilter->SetTransform(transform.GetPointer());
resampleFilter->SetInput(image);
ImageType::SizeType size = image->GetLargestPossibleRegion().GetSize();
resampleFilter->SetSize( size );
resampleFilter->Update();
viewer.
AddImage(resampleFilter->GetOutput());
return EXIT_SUCCESS;
}
void CreateImage(ImageType::Pointer image)
{
ImageType::IndexType start;
start.Fill(0);
ImageType::SizeType size;
size.Fill(100);
ImageType::RegionType region(start, size);
image->SetRegions(region);
image->Allocate();
image->FillBuffer(0);
for(unsigned int r = 40; r < 60; r++)
{
for(unsigned int c = 40; c < 60; c++)
{
ImageType::IndexType pixelIndex;
pixelIndex[0] = r;
pixelIndex[1] = c;
image->SetPixel(pixelIndex, 255);
}
}
}