/**

\page tutorial-image-filtering Tutorial: Image filtering
\tableofcontents

This tutorial supposes that you have followed the \ref tutorial-getting-started.

\section intro_img_filtering Introduction

In this tutorial you will learn how to use ViSP filtering functions implemented in vpImageFilter class.

All the material (source code and images) described in this tutorial is part of ViSP source code and could be downloaded using the following command:

\code
$ svn export https://github.com/lagadic/visp.git/trunk/tutorial/image
\endcode

Let us consider the following source code that comes from tutorial-image-filter.cpp.

\include tutorial-image-filter.cpp

Once build, you should have \c tutorial-image-filter binary. It shows how to apply different filters on an input image. Here we will consider monkey.pgm as input image.

\image html img-monkey-gray.png

To see the resulting filtered images, just run:

\code
./tutorial-image-filter monkey.pgm
\endcode

The following sections give a line by line explanation of the source code dedicated to image filtering capabilities.

\section blur Gaussian blur

Monkey input image is read from disk and is stored in  \c I which is a gray level image declared as

\snippet tutorial-image-filter.cpp vpImage construction

To apply a Gaussian blur to this image we first have to declare a resulting floating-point image \c F. Then the blurred image could be obtained using the default Gaussian filter:

\snippet tutorial-image-filter.cpp Gaussian blur

The resulting image is the following:

\image html img-monkey-blured-default.png

It is also possible to specify the Gaussian filter kernel size and the Gaussian standard deviation (sigma) using:

\code
vpImageFilter::gaussianBlur(I, F, 7, 2); // Kernel size: 7, sigma: 2
\endcode

We thus obtain the following image:

\image html img-monkey-blured-var2.png

\section gradient Gradients computation

To compute the gradients or the spatial derivative along X use:

\snippet tutorial-image-filter.cpp Gradients x

Gradients along Y could be obtained using:

\snippet tutorial-image-filter.cpp Gradients y

The resulting floating-point images \c dIx, \c dIy are the following:

\image html img-monkey-dIxy.png

\section canny Canny edge detector

Canny edge detector function relies on OpenCV if ViSP was build with OpenCV 2.1 or higher. Otherwise,
it relies on the ViSP implementation in vpCannyEdgeDetector class.

After the declaration of a new image container \c C, Canny edge detector is applied using:
\snippet tutorial-image-filter.cpp Canny

Where:
- 5: is the size of the Gaussian kernel used to blur the image before applying the Canny edge detector.
- -1.: is the upper threshold set in the program. Setting it to a negative value asks ViSP to compute automatically the lower and upper thresholds. Otherwise,
the lower threshold is set to be equal to one third of the upper threshold, following Canny’s recommendation.
- 3: is the size of the Sobel kernel used internally.

The resulting image \c C is the following:

\image html img-monkey-canny.png

\section convolution Convolution

To apply a convolution to an image, we first have to define a kernel.
For example, let us consider the 3x3 Sobel kernel defined in \c K.

\f[
{\bf K} = \left[ \begin{matrix}
1 & 0 & -1 \\
2 & 0 & -2 \\
1 & 0 & -1 \\
\end{matrix} \right]
\f]

\snippet tutorial-image-filter.cpp Convolution kernel

After the declaration of a new floating-point image \c Gx, the convolution is obtained using:
\snippet tutorial-image-filter.cpp Convolution

The content of the filtered image \c Gx is the following.

\image html img-monkey-sobel.png

\section pyramid Gaussian image pyramid

To construct a pyramid of Gaussian filtered images as a vector of images implemented in \c pyr[] you may use:
\snippet tutorial-image-filter.cpp Gaussian pyramid

The content of \c pyr[0], \c pyr[1], \c pyr[2] is the following:
\image html img-monkey-pyr.png

\section img_filtering_next Next tutorial
You are now ready to see the next \ref tutorial-tracking-blob.

*/
