Once build, you should have tutorial-image-filter binary. It shows how to apply different filters on an input image. Here we will consider monkey.pgm as input image.
To see the resulting filtered images, just run:
./tutorial-image-filter monkey.pgm
The following sections give a line by line explanation of the source code dedicated to image filtering capabilities.
Gaussian blur
Monkey input image is read from disk and is stored in I which is a gray level image declared as
To apply a Gaussian blur to this image we first have to declare a resulting floating-point image F. Then the blurred image could be obtained using the default Gaussian filter:
The resulting floating-point images dIx, dIy are the following:
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, Canny edge detector is applied using:
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 is the following:
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 K.