int main( int argc, char *argv[] )
{
if( argc < 7 )
{
std::cerr << "Missing Parameters " << std::endl;
std::cerr << "Usage: " << argv[0];
std::cerr << " inputImage outputImage seedX seedY multiplier iterations" << std::endl;
return 1;
}
typedef unsigned char PixelComponentType;
const unsigned int Dimension = 2;
typedef unsigned char OutputPixelType;
ReaderType::Pointer reader = ReaderType::New();
WriterType::Pointer writer = WriterType::New();
reader->SetFileName( argv[1] );
writer->SetFileName( argv[2] );
OutputImageType > ConnectedFilterType;
ConnectedFilterType::Pointer confidenceConnected
= ConnectedFilterType::New();
confidenceConnected->SetInput( reader->GetOutput() );
writer->SetInput( confidenceConnected->GetOutput() );
const double multiplier = atof( argv[5] );
confidenceConnected->SetMultiplier( multiplier );
const unsigned int iterations = atoi( argv[6] );
confidenceConnected->SetNumberOfIterations( iterations );
confidenceConnected->SetReplaceValue( 255 );
InputImageType::IndexType index;
index[0] = atoi( argv[3] );
index[1] = atoi( argv[4] );
confidenceConnected->SetSeed( index );
confidenceConnected->SetInitialNeighborhoodRadius( 3 );
try
{
writer->Update();
}
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << excep << std::endl;
}
typedef ConnectedFilterType::MeanVectorType MeanVectorType;
const MeanVectorType & mean = confidenceConnected->GetMean();
std::cout << "Mean vector = " << std::endl;
std::cout << mean << std::endl;
typedef ConnectedFilterType::CovarianceMatrixType CovarianceMatrixType;
const CovarianceMatrixType & covariance
= confidenceConnected->GetCovariance();
std::cout << "Covariance matrix = " << std::endl;
std::cout << covariance << std::endl;
return 0;
}