static void CreateImage(ImageType::Pointer image);
int main(int, char *[])
{
ImageType::Pointer image = ImageType::New();
CreateImage(image);
std::cout << "Original size: " << image->GetLargestPossibleRegion().GetSize() << std::endl;
ShrinkImageFilterType;
ShrinkImageFilterType::Pointer shrinkFilter
= ShrinkImageFilterType::New();
shrinkFilter->SetInput(image);
shrinkFilter->SetShrinkFactor(0, 2);
shrinkFilter->SetShrinkFactor(1, 3);
shrinkFilter->Update();
std::cout << "New size: " << shrinkFilter->GetOutput()->GetLargestPossibleRegion().GetSize() << std::endl;
return EXIT_SUCCESS;
}
void CreateImage(ImageType::Pointer image)
{
ImageType::RegionType region(start, size);
image->SetRegions(region);
image->Allocate();
image->FillBuffer(0);
for(unsigned int r = 20; r < 80; r++)
{
for(unsigned int c = 20; c < 30; c++)
{
pixelIndex[0] = r;
pixelIndex[1] = c;
image->SetPixel(pixelIndex, 255);
}
}
}