int
main(int argc, char ** argv)
{
if (argc < 4)
{
std::cerr << "Missing parameters. " << std::endl;
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " outputImageFile startX startY" << std::endl;
return EXIT_FAILURE;
}
using PixelType = float;
using FastMarchingFilterType =
using NodeContainer = FastMarchingFilterType::NodeContainer;
using NodeType = FastMarchingFilterType::NodeType;
seedPosition[0] = 128;
seedPosition[1] = 128;
constexpr double initialDistance = 1.0;
NodeType node;
constexpr double seedValue = -initialDistance;
node.SetValue(seedValue);
node.SetIndex(seedPosition);
seeds->Initialize();
seeds->InsertElement(0, node);
fastMarching->SetTrialPoints(seeds);
fastMarching->SetSpeedConstant(1.0);
noise->SetSize(size.m_InternalArray);
noise->SetMin(-.7);
noise->SetMax(.8);
adder->SetInput1(noise->GetOutput());
adder->SetInput2(fastMarching->GetOutput());
try
{
fastMarching->SetOutputSize(size);
fastMarching->Update();
adder->Update();
}
{
std::cerr << "Exception caught !" << std::endl;
std::cerr << excep << std::endl;
return EXIT_FAILURE;
}
index[0] = std::stoi(argv[2]);
index[1] = std::stoi(argv[3]);
auto radius = itk::MakeFilled<NeighborhoodIteratorType::RadiusType>(1);
NeighborhoodIteratorType it(radius, input, input->GetRequestedRegion());
it.SetLocation(index);
bool flag = true;
while (flag == true)
{
NeighborhoodIteratorType::OffsetType nextMove{};
flag = false;
PixelType min = it.GetCenterPixel();
for (unsigned int i = 0; i < it.Size(); ++i)
{
if (it.GetPixel(i) < min)
{
min = it.GetPixel(i);
nextMove = it.GetOffset(i);
flag = true;
}
}
it.SetCenterPixel(255.0);
it += nextMove;
}
using WritePixelType = unsigned char;
using RescaleFilterType =
rescaler->SetOutputMinimum(0);
rescaler->SetOutputMaximum(255);
rescaler->SetInput(input);
writer->SetFileName(argv[1]);
writer->SetInput(rescaler->GetOutput());
try
{
writer->Update();
}
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}