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