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 );
GradientMagnitudeImageFilter::Pointer grad = GradientMagnitudeImageFilter::New();
grad->SetInput( reader->GetOutput() );
grad->SetUseImageSpacingOn();
using GradientMagnitudeOutputImageType = GradientMagnitudeImageFilter::OutputImageType;
ComposeRGBFilterType::Pointer composeRGB = ComposeRGBFilterType::New();
composeRGB->SetInput1( grad->GetOutput() );
composeRGB->SetInput2( grad->GetOutput() );
composeRGB->SetInput3( grad->GetOutput() );
composeRGB->UpdateOutputInformation();
+ (unsigned long) (0.25 * largest.GetSize(0)) );
+ (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)) );
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();
}
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}