int
main(int argc, char ** argv)
{
  if (argc < 3)
  {
    std::cerr << "Missing parameters. " << std::endl;
    std::cerr << "Usage: " << std::endl;
    std::cerr << argv[0] << " inputImageFile outputImageFile" << std::endl;
    return EXIT_FAILURE;
  }
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 
  
  using PixelType = float;
 
  
 
 
  
  
  
  
  
  
  
  
 
  
  auto reader = ReaderType::New();
  reader->SetFileName(argv[1]);
  try
  {
    reader->Update();
  }
  {
    std::cerr << "ExceptionObject caught !" << std::endl;
    std::cerr << err << std::endl;
    return EXIT_FAILURE;
  }
  
 
  
  
  
  
  
  
  
  
 
  
  NeighborhoodIteratorType it(
    radius, reader->GetOutput(), reader->GetOutput()->GetRequestedRegion());
  
 
  
  
  
  
  
 
  
  auto output = ImageType::New();
  output->SetRegions(reader->GetOutput()->GetRequestedRegion());
  output->Allocate();
 
  IteratorType out(output, reader->GetOutput()->GetRequestedRegion());
  
 
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 
  
  constexpr NeighborhoodIteratorType::OffsetType offset1 = { { -1, -1 } };
  constexpr NeighborhoodIteratorType::OffsetType offset2 = { { 1, -1 } };
  constexpr NeighborhoodIteratorType::OffsetType offset3 = { { -1, 0 } };
  constexpr NeighborhoodIteratorType::OffsetType offset4 = { { 1, 0 } };
  constexpr NeighborhoodIteratorType::OffsetType offset5 = { { -1, 1 } };
  constexpr NeighborhoodIteratorType::OffsetType offset6 = { { 1, 1 } };
  
 
  
  
  
  
  
  
  
  
  
  
  
 
  
  for (it.GoToBegin(), out.GoToBegin(); !it.IsAtEnd(); ++it, ++out)
  {
    float sum;
    sum = it.GetPixel(offset2) - it.GetPixel(offset1);
    sum += 2.0 * it.GetPixel(offset4) - 2.0 * it.GetPixel(offset3);
    sum += it.GetPixel(offset6) - it.GetPixel(offset5);
    out.Set(sum);
  }
  
 
  
  
  
  
  
  
  
  
 
  
  using WritePixelType = unsigned char;
 
  using RescaleFilterType =
 
  auto rescaler = RescaleFilterType::New();
 
  rescaler->SetOutputMinimum(0);
  rescaler->SetOutputMaximum(255);
  rescaler->SetInput(output);
 
  auto writer = WriterType::New();
  writer->SetFileName(argv[2]);
  writer->SetInput(rescaler->GetOutput());
  try
  {
    writer->Update();
  }
  {
    std::cerr << "ExceptionObject caught !" << std::endl;
    std::cerr << err << std::endl;
    return EXIT_FAILURE;
  }
  
 
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
 
 
  return EXIT_SUCCESS;
}
Const version of NeighborhoodIterator, defining iteration of a local N-dimensional neighborhood of pi...
 
Standard exception handling object.
 
Data source that reads image data from a single file.
 
Writes image data to a single file.
 
A multi-dimensional iterator templated over image type that walks a region of pixels.
 
Templated n-dimensional image class.
 
Applies a linear transformation to the intensity levels of the input Image.
 
constexpr TContainer MakeFilled(typename TContainer::const_reference value)