From ecaa6feac8a1b969fbaa39840a909261bcdf08d5 Mon Sep 17 00:00:00 2001 From: Victor Poughon <victor.poughon@cnes.fr> Date: Wed, 24 Apr 2019 16:04:18 +0200 Subject: [PATCH] DOC: review FrostImageFilter --- Data/Output/GomaSmallFrostFiltered.png | 3 + Examples/BasicFilters/FrostImageFilter.cxx | 70 ++-------------------- Examples/BasicFilters/FrostImageFilter.rst | 34 +++++++++++ 3 files changed, 42 insertions(+), 65 deletions(-) create mode 100644 Data/Output/GomaSmallFrostFiltered.png create mode 100644 Examples/BasicFilters/FrostImageFilter.rst diff --git a/Data/Output/GomaSmallFrostFiltered.png b/Data/Output/GomaSmallFrostFiltered.png new file mode 100644 index 0000000000..4bb8d0aff2 --- /dev/null +++ b/Data/Output/GomaSmallFrostFiltered.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8469a05c42dbe0468daa7f9355fa6af0d79fa81793c93d001eb6310bf5c0ade6 +size 26542 diff --git a/Examples/BasicFilters/FrostImageFilter.cxx b/Examples/BasicFilters/FrostImageFilter.cxx index 13d1267485..913ac71a27 100644 --- a/Examples/BasicFilters/FrostImageFilter.cxx +++ b/Examples/BasicFilters/FrostImageFilter.cxx @@ -23,34 +23,6 @@ ./FrostImageFilter Input/GomaSmall.png Output/GomaSmallFrostFiltered.png 5 0.1 */ - -// This example illustrates the use of the \doxygen{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} $ -// -// where : $ 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})} $ -// and $ d_{s, p}=\sqrt{(i-i_{p})^2+(j-j_{p})^2} $ -// -// \begin{itemize} -// \item $ K $ : the decrease coefficient -// \item $ (i, j)$ : the coordinates of the pixel inside the region -// defined by $ \eta_{s} $ -// \item $ (i_{p}, j_{p})$ : the coordinates of the pixels belonging to $ \eta_{p} \subset \eta_{s} $ -// \item $ C_{s}$ : the variation coefficient computed over $ \eta_{p}$ -// \end{itemize} -// -// -// -// Most of this example is similar to the previous one and only the differences -// will be highlighted. -// -// First, we need to include the header: - #include "otbFrostImageFilter.h" #include "otbImage.h" @@ -68,16 +40,12 @@ int main(int argc, char* argv[]) } typedef unsigned char PixelType; - typedef otb::Image<PixelType, 2> InputImageType; typedef otb::Image<PixelType, 2> OutputImageType; - // The filter can be instantiated using the image types defined previously. - + // The filter can be instantiated using the image types defined previously. typedef otb::FrostImageFilter<InputImageType, OutputImageType> FilterType; - typedef otb::ImageFileReader<InputImageType> ReaderType; - typedef otb::ImageFileWriter<OutputImageType> WriterType; ReaderType::Pointer reader = ReaderType::New(); @@ -87,22 +55,12 @@ int main(int argc, char* argv[]) writer->SetInput(filter->GetOutput()); reader->SetFileName(argv[1]); - // The image obtained with the reader is passed as input to the - // \doxygen{otb}{FrostImageFilter}. - // - // \index{otb::FrostImageFilter!SetInput()} - // \index{otb::FileImageReader!GetOutput()} - + // The image obtained with the reader is passed as input to the FrostImageFilter filter->SetInput(reader->GetOutput()); - // The method \code{SetRadius()} defines the size of the window to - // be used for the computation of the local statistics. The method - // \code{SetDeramp()} sets the $K$ coefficient. - // - // \index{otb::FrostImageFilter!SetRadius()} - // \index{otb::FrostImageFilter!SetDeramp()} - // \index{SetDeramp()!otb::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]); @@ -112,22 +70,4 @@ int main(int argc, char* argv[]) writer->SetFileName(argv[2]); writer->Update(); - - // Figure~\ref{fig:FROST_FILTER} shows the result of applying the Frost - // filter to a SAR image. - // \begin{figure} - // \center - // \includegraphics[width=0.44\textwidth]{GomaSmall.eps} - // \includegraphics[width=0.44\textwidth]{GomaSmallFrostFiltered.eps} - // \itkcaption[Frost Filter Application]{Result of applying the - // \doxygen{otb}{FrostImageFilter} to a SAR image.} - // \label{fig:FROST_FILTER} - // \end{figure} - // - // \relatedClasses - // \begin{itemize} - // \item \doxygen{otb}{LeeImageFilter} - // \end{itemize} - - return EXIT_SUCCESS; } diff --git a/Examples/BasicFilters/FrostImageFilter.rst b/Examples/BasicFilters/FrostImageFilter.rst new file mode 100644 index 0000000000..2951e334e7 --- /dev/null +++ b/Examples/BasicFilters/FrostImageFilter.rst @@ -0,0 +1,34 @@ +This example illustrates the use of the :doxygen:`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: + +.. math:: + + \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} + +where: + +* :math:`K`: the decrease coefficient +* :math:`(i, j)`: the coordinates of the pixel inside the region defined by :math:`\eta_{s}` +* :math:`(i_{p}, j_{p})`: the coordinates of the pixels belonging to :math:`\eta_{p} \subset \eta_{s}` +* :math:`C_{s}`: the variation coefficient computed over :math:`\eta_{p}` + +.. |image1| image:: /Input/GomaSmall.png + +.. |image2| image:: /Output/GomaSmallFrostFiltered.png + +.. _Figure1: + ++--------------------------+-------------------------+ +| |image1| | |image2| | ++--------------------------+-------------------------+ + + Result of applying the FrostImageFilter to a SAR image. -- GitLab