#include <string>
template<typename TImageType>
void WriteFile(typename TImageType::Pointer image, std::string filename);
int main(int, char *[])
{
ImageType4::Pointer image4 = ImageType4::New();
WriteFile<ImageType4>(image4, std::string("image4.mhd"));
ImageType5::Pointer image5 = ImageType5::New();
WriteFile<ImageType5>(image5, std::string("image5.mhd"));
return EXIT_SUCCESS;
}
template<typename TImageType>
void WriteFile(typename TImageType::Pointer image, std::string filename)
{
start[0] = 0;
start[1] = 0;
size[0] = 20;
size[1] = 30;
typename TImageType::RegionType region;
region.SetIndex(start);
image->SetRegions(region);
image->Allocate();
typename WriterType::Pointer writer = WriterType::New();
writer->SetInput(image);
writer->SetFileName(filename);
writer->Update();
}