int
main(int argc, char ** argv)
{
if (argc < 4)
{
std::cerr << "Missing parameters. " << std::endl;
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << " inputImageFile outputImageFile direction"
<< std::endl;
return EXIT_FAILURE;
}
using PixelType = float;
reader->SetFileName(argv[1]);
try
{
reader->Update();
}
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return EXIT_FAILURE;
}
output->SetRegions(reader->GetOutput()->GetRequestedRegion());
output->Allocate();
IteratorType out(output, reader->GetOutput()->GetRequestedRegion());
const NeighborhoodIteratorType::RadiusType radius =
NeighborhoodIteratorType it(
radius, reader->GetOutput(), reader->GetOutput()->GetRequestedRegion());
for (it.GoToBegin(), out.GoToBegin(); !it.IsAtEnd(); ++it, ++out)
{
out.Set(innerProduct(it, sobelOperator));
}
using WritePixelType = unsigned char;
using RescaleFilterType =
rescaler->SetOutputMinimum(0);
rescaler->SetOutputMaximum(255);
rescaler->SetInput(output);
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.
void SetDirection(const unsigned int direction)
const SizeType GetRadius() const
Applies a linear transformation to the intensity levels of the input Image.
A NeighborhoodOperator for performing a directional Sobel edge-detection operation at a pixel locatio...
void CreateDirectional() override