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 sigma"
<< 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();
using FaceCalculatorType =
FaceCalculatorType faceCalculator;
FaceCalculatorType::FaceListType faceList;
FaceCalculatorType::FaceListType::iterator fit;
IteratorType out;
NeighborhoodIteratorType it;
gaussianOperator.
SetVariance(std::stod(argv[3]) * std::stod(argv[3]));
for (unsigned int i = 0; i < ImageType::ImageDimension; ++i)
{
faceList = faceCalculator(
input, output->GetRequestedRegion(), gaussianOperator.
GetRadius());
for (fit = faceList.begin(); fit != faceList.end(); ++fit)
{
it =
NeighborhoodIteratorType(gaussianOperator.
GetRadius(), input, *fit);
out = IteratorType(output, *fit);
for (it.GoToBegin(), out.GoToBegin(); !it.IsAtEnd(); ++it, ++out)
{
out.Set(innerProduct(it, gaussianOperator));
}
}
if (i != ImageType::ImageDimension - 1)
{
input = output;
output = tmp;
}
}
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.
A NeighborhoodOperator whose coefficients are a one dimensional, discrete Gaussian kernel.
void SetVariance(const double variance)
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)
virtual void CreateDirectional()
const SizeType GetRadius() const
Applies a linear transformation to the intensity levels of the input Image.
SmartPointer< Self > Pointer
Splits an image into a main region and several "face" regions which are used to handle computations o...