Laplacian Recursive Gaussian Image Filter#
Synopsis#
Compute the Laplacian of an image.
Results#
Code#
Python#
#!/usr/bin/env python
import itk
import argparse
parser = argparse.ArgumentParser(
description="Laplacian Recursive Gaussian Image Filter."
)
parser.add_argument("input_image")
parser.add_argument("output_image")
args = parser.parse_args()
input_image = itk.imread(args.input_image, pixel_type=itk.F)
output_image = itk.laplacian_recursive_gaussian_image_filter(input_image)
itk.imwrite(output_image, args.output_image)
C++#
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkLaplacianRecursiveGaussianImageFilter.h"
int
main(int argc, char * argv[])
{
if (argc != 3)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0];
std::cerr << " <InputFileName> <OutputFileName>";
std::cerr << std::endl;
return EXIT_FAILURE;
}
constexpr unsigned int Dimension = 2;
using InputPixelType = unsigned char;
using InputImageType = itk::Image<InputPixelType, Dimension>;
const auto input = itk::ReadImage<InputImageType>(argv[1]);
using OutputPixelType = float;
using OutputImageType = itk::Image<OutputPixelType, Dimension>;
using FilterType = itk::LaplacianRecursiveGaussianImageFilter<InputImageType, OutputImageType>;
auto filter = FilterType::New();
filter->SetInput(input);
filter->Update();
try
{
itk::WriteImage(filter->GetOutput(), argv[2]);
}
catch (const itk::ExceptionObject & e)
{
std::cerr << "Error: " << e << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
Classes demonstrated#
-
template<typename TInputImage, typename TOutputImage = TInputImage>
class LaplacianRecursiveGaussianImageFilter : public itk::ImageToImageFilter<TInputImage, TOutputImage> Computes the Laplacian of Gaussian (LoG) of an image.
Computes the Laplacian of Gaussian (LoG) of an image by convolution with the second derivative of a Gaussian. This filter is implemented using the recursive gaussian filters.
- ITK Sphinx Examples: