#include "itkConfigure.h"
#if ( ITK_VERSION_MAJOR < 4 ) //These are all defaults in ITKv4
int main(int argc, char *argv[])
{
return 0;
}
#else
void CreateHalfMask(ImageType::Pointer image, ImageType::Pointer &mask);
int main(int argc, char *argv[])
{
if(argc < 2)
{
std::cerr << "Usage: " << argv[0] << " filename" << std::endl;
return EXIT_FAILURE;
}
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(argv[1]);
reader->Update();
ImageType::Pointer mask = ImageType::New();
CreateHalfMask(reader->GetOutput(), mask);
MaskFilterType::Pointer maskFilter = MaskFilterType::New();
maskFilter->SetInput(reader->GetOutput());
maskFilter->SetMaskImage(mask);
mask->Print(std::cout);
reader->GetOutput(),true,
itksys::SystemTools::GetFilenameName(argv[1]));
std::stringstream desc;
desc << "Mask";
mask.GetPointer(),
true,
desc.str());
std::stringstream desc2;
desc2 << "MaskFilter";
maskFilter->GetOutput(),
true,
desc2.str());
return EXIT_SUCCESS;
}
void CreateHalfMask(ImageType::Pointer image, ImageType::Pointer &mask)
{
ImageType::RegionType region = image->GetLargestPossibleRegion();
mask->SetRegions(region);
mask->Allocate();
ImageType::SizeType regionSize = region.GetSize();
while(!imageIterator.IsAtEnd())
{
{
imageIterator.Set(0);
}
else
{
imageIterator.Set(255);
}
++imageIterator;
}
}
#endif