This example illustrates the use of the otb::FrostImageFilter. This filter belongs to the family of the edge-preserving smoothing filters which are usually used for speckle reduction in radar images.

This filter uses a negative exponential convolution kernel. The output of the filter for pixel p is:

\hat I_{s}=\sum_{p\in\eta_{p}} m_{p}I_{p}

m_{p}=\frac{KC_{s}^{2}\exp(-KC_{s}^{2}d_{s, p})}{\sum_{p\in\eta_{p}} KC_{s}^{2}\exp(-KC_{s}^{2}d_{s, p})}

d_{s, p}=\sqrt{(i-i_{p})^2+(j-j_{p})^2}


  • K: the decrease coefficient
  • (i, j): the coordinates of the pixel inside the region defined by \eta_{s}
  • (i_{p}, j_{p}): the coordinates of the pixels belonging to \eta_{p} \subset \eta_{s}
  • C_{s}: the variation coefficient computed over \eta_{p}
image1 image2
Result of applying the FrostImageFilter to a SAR image.

Example usage:

./FrostImageFilter Input/GomaSmall.png Output/GomaSmallFrostFiltered.png 5 0.1

Example source code (FrostImageFilter.cxx):

#include "otbFrostImageFilter.h"

#include "otbImage.h"
#include "otbImageFileReader.h"
#include "otbImageFileWriter.h"

int main(int argc, char* argv[])

  if (argc != 5)
    std::cerr << "Usage: " << argv[0] << " inputImageFile ";
    std::cerr << " outputImageFile radius deramp" << std::endl;
    return EXIT_FAILURE;

  using PixelType       = unsigned char;
  using InputImageType  = otb::Image<PixelType, 2>;
  using OutputImageType = otb::Image<PixelType, 2>;

  // The filter can be instantiated using the image types defined previously.
  using FilterType = otb::FrostImageFilter<InputImageType, OutputImageType>;
  using ReaderType = otb::ImageFileReader<InputImageType>;
  using WriterType = otb::ImageFileWriter<OutputImageType>;

  ReaderType::Pointer reader = ReaderType::New();
  FilterType::Pointer filter = FilterType::New();

  WriterType::Pointer writer = WriterType::New();

  // The image obtained with the reader is passed as input to the FrostImageFilter

  // The method SetRadius() defines the size of the window to
  // be used for the computation of the local statistics. The method
  // SetDeramp() sets the K coefficient.
  FilterType::SizeType Radius;
  Radius[0] = atoi(argv[3]);
  Radius[1] = atoi(argv[3]);