int
main(int argc, char * argv[])
{
if (argc != 3)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0];
std::cerr << " <InputFileName> <OutputFileName>";
std::cerr << std::endl;
return EXIT_FAILURE;
}
const char * inputFileName = argv[1];
const char * outputFileName = argv[2];
const int xDiv = 6;
const int yDiv = 4;
const int zDiv = 1;
using PixelType = unsigned char;
const auto input = itk::ReadImage<ImageType>(inputFileName);
median->SetInput(input);
median->SetRadius(2);
writer->SetFileName(outputFileName);
for (int z = 0; z < zDiv; ++z)
{
start[2] = fullSize[2] * double(z) / zDiv;
end[2] = fullSize[2] * (z + 1.0) / zDiv;
size[2] = end[2] - start[2];
for (int y = 0; y < yDiv; ++y)
{
start[1] = fullSize[1] * double(y) / yDiv;
end[1] = fullSize[1] * (y + 1.0) / yDiv;
size[1] = end[1] - start[1];
for (int x = 0; x < xDiv; ++x)
{
start[0] = fullSize[0] * double(x) / xDiv;
end[0] = fullSize[0] * (x + 1.0) / xDiv;
size[0] = end[0] - start[0];
region.SetSize(size);
median->GetOutput()->SetRequestedRegion(region);
median->Update();
result->DisconnectPipeline();
writer->SetInput(result);
ioRegion.
SetSize(0, region.GetSize()[0]);
ioRegion.
SetSize(1, region.GetSize()[1]);
ioRegion.
SetSize(2, region.GetSize()[2]);
writer->SetIORegion(ioRegion);
try
{
writer->Update();
}
{
std::cerr << "Exception for chunk: " << x << ' ' << y << ' ' << z << error << std::endl;
return EXIT_FAILURE;
}
}
}
}
return EXIT_SUCCESS;
}