Exercise 5.2 uses a picture with a center of 255 to compare the smoothing effect of a Gaussian filter

Source: Internet
Author: User

"Study OpenCV" Chinese version 5th Chapter 2nd question

Outline
Topic Requirements
Program code
Result picture

Title Requirements:

Create a 100x100 single-channel image, place all pixels in the image zero, and set the center pixel value equal to 255.

C, the original with a 5x5 filter smoothing two times, and with the results of the 9x9 filter to see if similar, why

Program code:

1 //OpenCVExerciseTesting.cpp: Defines the entry point of the console application. 2 //3 //d:\\work\\work_programming\\source\\image\\lena.jpg4 5 6#include"stdafx.h"7#include <cv.h>8#include 9#include <iostream>Ten using namespaceCV; One using namespacestd; A //function declaration---->-->--->-->--->-->--->// -  -  the  - //<--<--<--<--<--<--<--<--<--Function Declaration// -  - int_tmain (intARGC, _tchar*argv[]) + { -Iplimage * img = cvcreateimage (cvsize ( -, -), ipl_depth_8u,1); + assert (IMG); A Cvzero (IMG); atCvsetreal2d (IMG, the, the,255); -  -Cvnamedwindow ("Exercisewindow",0); -Cvnamedwindow ("Gaussian Blur 5x5",0); -Cvnamedwindow ("Gaussian fuzzy 9x9",0); -Cvnamedwindow ("Gaussian Blur 5x5 two times",0); in  -Cvshowimage ("Exercisewindow", IMG); to  +  -     //---------------------------A: Start--------------------------------// the  *Iplimage * Image_gauss =cvcloneimage (IMG); $ Cvzero (Image_gauss);Panax Notoginseng  -Cvsmooth (IMG, Image_gauss, Cv_gaussian,5,5); the  +Cvshowimage ("Gaussian Blur 5x5", Image_gauss); A  the     //---------------------------A: End--------------------------------//     +  -  $     //---------------------------B: Start--------------------------------// $  -Iplimage * Image_gauss_9 =cvcloneimage (IMG); - Cvzero (image_gauss_9); the  -Cvsmooth (IMG, Image_gauss_9, Cv_gaussian,9,9);Wuyi  theCvshowimage ("Gaussian fuzzy 9x9", image_gauss_9); -  Wu     //---------------------------B: End--------------------------------//     -  About     //---------------------------C: Start--------------------------------// $  -     //5x5 two times for the original -Iplimage * Image_gauss_5_2 =cvcloneimage (IMG); - Cvzero (image_gauss_5_2); A  +Cvsmooth (IMG, Image_gauss_5_2, Cv_gaussian,5,5); theCvsmooth (Image_gauss_5_2, Image_gauss_5_2, Cv_gaussian,5,5); -  $Cvshowimage ("Gaussian Blur 5x5 two times", image_gauss_5_2); the  the  the     //---------------------------C: End--------------------------------//     the  -  inCvwaitkey (0); the  theCvreleaseimage (&img); AboutCvreleaseimage (&Image_gauss); theCvreleaseimage (&image_gauss_9); theCvreleaseimage (&image_gauss_5_2); the  +Cvdestroywindow ("Exercisewindow"); -Cvdestroywindow ("Gaussian Blur 5x5"); theCvdestroywindow ("Gaussian fuzzy 9x9");BayiCvdestroywindow ("Gaussian Blur 5x5 two times"); the  the     return 0; -}

Local Amplification :

Smoothing two times with the 5x5 filter, smoothing with the 9x9 filter, smoothing affects the number of pixels and the pixel values of each pixel are close.

Exercise 5.2 uses a picture with a center of 255 to compare the smoothing effect of a Gaussian filter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.