int main(int argc, char* argv[])
{
if( argc < 3 )
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0]
<< " inputImage outputImage"
<< " [variance upperThreshold lowerThreshold]" << std::endl;
return EXIT_FAILURE;
}
const char * inputFilename = argv[1];
const char * outputFilename = argv[2];
float variance = 2.0;
float upperThreshold = 0.0;
float lowerThreshold = 0.0;
if( argc > 3 )
{
variance = atof( argv[3] );
}
if( argc > 4 )
{
upperThreshold = atof( argv[4] );
}
if( argc > 5 )
{
lowerThreshold = atof( argv[5] );
}
std::cout << "Variance = " << variance << std::endl;
std::cout << "UpperThreshold = " << upperThreshold << std::endl;
std::cout << "LowerThreshold = " << lowerThreshold << std::endl;
const unsigned int Dimension = 2;
typedef unsigned char CharPixelType;
typedef double RealPixelType;
CastToRealFilterType;
CannyFilterType;
RescaleFilterType;
ReaderType::Pointer reader = ReaderType::New();
CastToRealFilterType::Pointer toReal = CastToRealFilterType::New();
CannyFilterType::Pointer cannyFilter = CannyFilterType::New();
RescaleFilterType::Pointer rescale = RescaleFilterType::New();
WriterType::Pointer writer = WriterType::New();
reader->SetFileName( inputFilename );
writer->SetFileName( outputFilename );
toReal->SetInput( reader->GetOutput() );
cannyFilter->SetInput( toReal->GetOutput() );
rescale->SetInput( cannyFilter->GetOutput() );
writer->SetInput( rescale->GetOutput() );
cannyFilter->SetVariance( variance );
cannyFilter->SetUpperThreshold( upperThreshold );
cannyFilter->SetLowerThreshold( lowerThreshold );
try
{
writer->Update();
}
{
std::cout << "ExceptionObject caught !" << std::endl;
std::cout << err << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}