int
main(int argc, char * argv[])
{
if (argc < 3)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0]
<< " inputImageFile outputImageFile [smoothingIterations]"
<< std::endl;
return EXIT_FAILURE;
}
try
{
constexpr unsigned int Dimension = 2;
using InputPixelType = float;
using LabelType = unsigned char;
using PriorType = float;
using PosteriorType = float;
using ClassifierFilterType =
LabelType,
PosteriorType,
PriorType>;
auto filter = ClassifierFilterType::New();
filter->SetInput(input);
if (argc > 3)
{
filter->SetNumberOfSmoothingIterations(std::stoi(argv[3]));
using ExtractedComponentImageType =
ClassifierFilterType::ExtractedComponentImageType;
using SmoothingFilterType =
ExtractedComponentImageType,
ExtractedComponentImageType>;
auto smoother = SmoothingFilterType::New();
smoother->SetNumberOfIterations(1);
smoother->SetTimeStep(0.125);
smoother->SetConductanceParameter(3);
filter->SetSmoothingFilter(smoother);
}
using ClassifierOutputImageType = ClassifierFilterType::OutputImageType;
using RescalerType =
OutputImageType>;
auto rescaler = RescalerType::New();
rescaler->SetInput(filter->GetOutput());
rescaler->SetOutputMinimum(0);
rescaler->SetOutputMaximum(255);
filter->Print(std::cout);
std::cout << "Test passed." << std::endl;
}
{
std::cerr << "ITK exception caught:\n" << excp << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
Performs Bayesian Classification on an image.
Standard exception handling object.
This filter performs anisotropic diffusion on a scalar itk::Image using the classic Perona-Malik,...
Templated n-dimensional image class.
Applies a linear transformation to the intensity levels of the input Image.
Templated n-dimensional vector image class.
ITK_TEMPLATE_EXPORT void WriteImage(TImagePointer &&image, const std::string &filename, bool compress=false)
TOutputImage::Pointer ReadImage(const std::string &filename)