static void CreateImage(ImageType::Pointer image);
int main(int, char *[])
{
ImageType::Pointer input = ImageType::New();
CreateImage(input);
std::cout << "Input size: " << inputSize << std::endl;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName("input.png");
writer->SetInput(input);
writer->Update();
ImageType::SpacingType outputSpacing;
outputSpacing[0] = input->GetSpacing()[0] * (static_cast<double>(inputSize[0]) / static_cast<double>(outputSize[0]));
outputSpacing[1] = input->GetSpacing()[1] * (static_cast<double>(inputSize[1]) / static_cast<double>(outputSize[1]));
ResampleImageFilterType::Pointer resample = ResampleImageFilterType::New();
resample->SetInput(input);
resample->SetSize(outputSize);
resample->SetOutputSpacing(outputSpacing);
resample->SetTransform(TransformType::New());
resample->UpdateLargestPossibleRegion();
ImageType::Pointer output = resample->GetOutput();
std::cout << "Output size: " << output->GetLargestPossibleRegion().GetSize() << std::endl;
std::cout << "Writing output... " << std::endl;
WriterType::Pointer outputWriter = WriterType::New();
outputWriter->SetFileName("output.png");
outputWriter->SetInput(output);
outputWriter->Update();
return EXIT_SUCCESS;
}
void CreateImage(ImageType::Pointer image)
{
image->SetRegions(region);
image->Allocate();
image->FillBuffer(0);
for(unsigned int r = 40; r < 60; r++)
{
for(unsigned int c = 40; c < 60; c++)
{
pixelIndex[0] = r;
pixelIndex[1] = c;
image->SetPixel(pixelIndex, 255);
}
}
}