int main( int argc, char * argv[] )
{
if( argc < 4 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile outputImageFile sigma [RescaledOutputImageFile] " << std::endl;
return EXIT_FAILURE;
}
typedef float InputPixelType;
typedef float OutputPixelType;
InputImageType, OutputImageType > FilterType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( argv[1] );
FilterType::Pointer filterX1 = FilterType::New();
FilterType::Pointer filterY1 = FilterType::New();
FilterType::Pointer filterX2 = FilterType::New();
FilterType::Pointer filterY2 = FilterType::New();
filterX1->SetDirection( 0 );
filterY1->SetDirection( 1 );
filterX2->SetDirection( 0 );
filterY2->SetDirection( 1 );
filterX1->SetOrder( FilterType::ZeroOrder );
filterY1->SetOrder( FilterType::SecondOrder );
filterX2->SetOrder( FilterType::SecondOrder );
filterY2->SetOrder( FilterType::ZeroOrder );
const bool normalizeAcrossScale = false;
filterX1->SetNormalizeAcrossScale( normalizeAcrossScale );
filterY1->SetNormalizeAcrossScale( normalizeAcrossScale );
filterX2->SetNormalizeAcrossScale( normalizeAcrossScale );
filterY2->SetNormalizeAcrossScale( normalizeAcrossScale );
filterX1->SetInput( reader->GetOutput() );
filterY1->SetInput( filterX1->GetOutput() );
filterY2->SetInput( reader->GetOutput() );
filterX2->SetInput( filterY2->GetOutput() );
const double sigma = atof( argv[3] );
filterX1->SetSigma( sigma );
filterY1->SetSigma( sigma );
filterX2->SetSigma( sigma );
filterY2->SetSigma( sigma );
OutputImageType,
OutputImageType,
OutputImageType > AddFilterType;
AddFilterType::Pointer addFilter = AddFilterType::New();
addFilter->SetInput1( filterY1->GetOutput() );
addFilter->SetInput2( filterX2->GetOutput() );
try
{
addFilter->Update();
}
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return EXIT_FAILURE;
}
typedef float WritePixelType;
WriterType::Pointer writer = WriterType::New();
writer->SetInput( addFilter->GetOutput() );
writer->SetFileName( argv[2] );
writer->Update();
if (argc > 4)
{
typedef unsigned char CharPixelType;
RescaleFilterType;
RescaleFilterType::Pointer rescale = RescaleFilterType::New();
rescale->SetInput( addFilter->GetOutput() );
rescale->SetOutputMinimum( 0 );
rescale->SetOutputMaximum( 255 );
CharWriterType::Pointer charWriter = CharWriterType::New();
charWriter->SetFileName( argv[4] );
charWriter->SetInput( rescale->GetOutput() );
charWriter->Update();
}
return EXIT_SUCCESS;
}