Learning Task breakdown:
Task:
1. Learn to open an image with opencv
2. Learn how to use opencv to perform Gaussian filtering, see what the Gaussian filtering effect is, and learn the theory of Gaussian filtering.
3. Find a C Language Program for Gaussian filtering, and combine it with the theory of Gaussian filtering.
Gaussian filter:
Gaussian filter is a linear smoothing filter that is suitable for eliminating Gaussian noise and is widely used in image processing noise reduction. In layman's terms, Gaussian filtering is a process of weighted average for the entire image. The value of each pixel is obtained by the weighted average of its own and other pixel values in the neighborhood. The specific operation of Gaussian filter is to use a template (or convolution or mask) to scan each pixel in the image, use the weighted average gray value of pixels in the neighborhood determined by the template to replace the value of the central pixel in the template. 3*3 templates 5*5 templates
G (x, y) = {f (x-1, Y-1) + f (x-1, Y + 1) + f (x + 1, Y-1) + f (x + 1, Y + 1) + [F (x-1, Y) + f (x, Y-1) + f (x + 1, Y) + f (x, y + 1)] * 2 + f (x, y) * 4}/16;
F (x, y) is the gray value of the (x, y) Point in the image, and g (x, y) is the value of the vertex after Gaussian filtering.
Opencv implementation:
# Include "stdafx. H "# include" highgui. H "# include" CV. H "// Gaussian filter function, cvsmooth void gaussianfilter (uchar * data, int width, int height) can be used in opencv {int I, j, index, sum; int templates [9] = {1, 2, 1, 2, 4, 2, 1, 2, 1 }; // template value sum = height * width * sizeof (uchar); // size of memory occupied by the image uchar * tmpdata = (uchar *) malloc (SUM ); memcpy (char *) tmpdata, (char *) data, sum); for (I = 1; I
Comparison of results: