Find Higher Derivatives of Image¶
Synopsis¶
Find higher derivatives of an image.
Results¶
![input image](../../../../_images/Yinyang28.png)
Input image.¶
![VTK Window](../../../../_images/FindHigherDerivativesOfImage.png)
Output In VTK Window¶
Code¶
C++¶
#include "itkImage.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkRescaleIntensityImageFilter.h"
#include "itkRecursiveGaussianImageFilter.h"
#ifdef ENABLE_QUICKVIEW
# include "QuickView.h"
#endif
int
main(int argc, char * argv[])
{
// Verify command line arguments
if (argc < 2)
{
std::cerr << "Usage: " << std::endl;
std::cerr << argv[0] << "inputImageFile" << std::endl;
return EXIT_FAILURE;
}
// Parse command line arguments
std::string inputFilename = argv[1];
// Setup types
using FloatImageType = itk::Image<float, 2>;
using UnsignedCharImageType = itk::Image<unsigned char, 2>;
using readerType = itk::ImageFileReader<UnsignedCharImageType>;
using filterType = itk::RecursiveGaussianImageFilter<UnsignedCharImageType, FloatImageType>;
// Create and setup a reader
readerType::Pointer reader = readerType::New();
reader->SetFileName(inputFilename.c_str());
// Create and setup a gaussian filter
filterType::Pointer gaussianFilter = filterType::New();
gaussianFilter->SetInput(reader->GetOutput());
gaussianFilter->SetDirection(0); // "x" axis
gaussianFilter->SetSecondOrder();
#ifdef ENABLE_QUICKVIEW
QuickView viewer;
viewer.AddImage<UnsignedCharImageType>(reader->GetOutput());
viewer.AddImage<FloatImageType>(gaussianFilter->GetOutput());
viewer.Visualize();
#endif
return EXIT_SUCCESS;
}
Classes demonstrated¶
-
template<typename
TInputImage
, typenameTOutputImage
= TInputImage>
classRecursiveGaussianImageFilter
: public itk::RecursiveSeparableImageFilter<TInputImage, TOutputImage> Base class for computing IIR convolution with an approximation of a Gaussian kernel.
RecursiveGaussianImageFilter is the base class for recursive filters that approximate convolution with the Gaussian kernel. This class implements the recursive filtering method proposed by R.Deriche in IEEE-PAMI Vol.12, No.1, January 1990, pp 78-87, “Fast Algorithms for Low-Level Vision”
Details of the implementation are described in the technical report: R. Deriche, “Recursively Implementing The Gaussian and Its Derivatives”, INRIA, 1993, ftp://ftp.inria.fr/INRIA/tech-reports/RR/RR-1893.ps.gz
Further improvements of the algorithm are described in: G. Farnebäck & C.-F. Westin, “Improving Deriche-style Recursive Gaussian
Filters”. J
Math Imaging Vis 26, 293–299 (2006). https://doi.org/10.1007/s10851-006-8464-zAs compared to itk::DiscreteGaussianImageFilter, this filter tends to be faster for large kernels, and it can take the derivative of the blurred image in one step. Also, note that we have itk::RecursiveGaussianImageFilter::SetSigma(), but itk::DiscreteGaussianImageFilter::SetVariance().
- See
DiscreteGaussianImageFilter
- ITK Sphinx Examples: