static void
CreateImage(ImageType::Pointer image, const unsigned int x);
int
main(int , char * [])
{
ImageType::Pointer fixedImage = ImageType::New();
CreateImage(fixedImage, 40);
ImageType::Pointer movingImage = ImageType::New();
CreateImage(movingImage, 50);
BlockMatchingImageFilterType::Pointer blockMatchingImageFilter = BlockMatchingImageFilterType::New();
using PointSetType = BlockMatchingImageFilterType::FeaturePointsType;
using PointsContainerPointer = PointSetType::PointsContainerPointer;
PointSetType::Pointer pointSet = PointSetType::New();
PointsContainerPointer points = pointSet->GetPoints();
p0[0] = 40.0;
p0[1] = 40.0;
p1[0] = 40.0;
p1[1] = 60.0;
p2[0] = 60.0;
p2[1] = 40.0;
p3[0] = 60.0;
p2[1] = 60.0;
points->InsertElement(0, p0);
points->InsertElement(1, p1);
points->InsertElement(2, p2);
points->InsertElement(3, p3);
blockMatchingImageFilter->SetFixedImage(fixedImage);
blockMatchingImageFilter->SetMovingImage(movingImage);
blockMatchingImageFilter->SetFeaturePoints(pointSet);
blockMatchingImageFilter->UpdateLargestPossibleRegion();
typename BlockMatchingImageFilterType::DisplacementsType * displacements =
blockMatchingImageFilter->GetDisplacements();
std::cout << "There are " << displacements->GetNumberOfPoints() << " displacements." << std::endl;
return EXIT_SUCCESS;
}
void
CreateImage(ImageType::Pointer image, const unsigned int x)
{
image->SetRegions(region);
image->Allocate();
image->FillBuffer(0);
for (unsigned int r = x; r < x + 20; r++)
{
for (unsigned int c = 40; c < 60; c++)
{
pixelIndex[0] = r;
pixelIndex[1] = c;
image->SetPixel(pixelIndex, 255);
}
}
}