int
main(int argc, char * argv[])
{
if (argc < 3)
{
std::cerr << "Missing Parameters " << std::endl;
std::cerr << "Usage: " << argv[0];
std::cerr << " inputImageFile outputImageFile" << std::endl;
return EXIT_FAILURE;
}
std::string inputImageFile = argv[1];
std::string outputImageFile = argv[2];
ImageReaderType::Pointer reader = ImageReaderType::New();
reader->SetFileName(inputImageFile);
using GradientMagnitudeImageFilter =
GradientMagnitudeImageFilter::Pointer grad =
GradientMagnitudeImageFilter::New();
grad->SetInput(reader->GetOutput());
grad->UseImageSpacingOn();
using GradientMagnitudeOutputImageType =
GradientMagnitudeImageFilter::OutputImageType;
using ComposeRGBFilterType =
ComposeRGBFilterType::Pointer composeRGB = ComposeRGBFilterType::New();
composeRGB->SetInput1(grad->GetOutput());
composeRGB->SetInput2(grad->GetOutput());
composeRGB->SetInput3(grad->GetOutput());
composeRGB->UpdateOutputInformation();
composeRGB->GetOutput()->GetLargestPossibleRegion();
0, largest.GetIndex(0) + (unsigned long)(0.25 * largest.GetSize(0)));
1, largest.GetIndex(1) + (unsigned long)(0.25 * largest.GetSize(1)));
halfIO.
SetSize(0, (
unsigned long)(0.5 * largest.GetSize(0)));
halfIO.
SetSize(1, (
unsigned long)(0.5 * largest.GetSize(1)));
using ToVectorImageAdaptorType =
ToVectorImageAdaptorType::Pointer adaptor = ToVectorImageAdaptorType::New();
adaptor->SetImage(composeRGB->GetOutput());
ImageWriterType::Pointer writer = ImageWriterType::New();
writer->SetFileName(outputImageFile);
writer->SetNumberOfStreamDivisions(10);
writer->SetIORegion(halfIO);
writer->SetInput(adaptor);
try
{
writer->Update();
}
catch (const itk::ExceptionObject & err)
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}