Use of sliders in OpenCV

Source: Internet
Author: User

There are two different kinds of smoothing types in the image. One is color image, and the other is grayscale image. It has been proved that both types can


#include <cv.h>
#include #include <cxcore.h>


int param1=1;
int param2=1;
Iplimage *img;
Iplimage *image;
Iplimage *DST;


void Switch_callback (int position)
{
int m_param1=param1*2+1;
int m_param2=param2*2+1; Mask size must be an odd number greater than or equal to 1


Cvsmooth (IMAGE,DST,CV_GAUSSIAN,M_PARAM1,M_PARAM2);

Cvsmooth (IMG,DST,CV_GAUSSIAN,M_PARAM1,M_PARAM2);

Cvshowimage ("Smooth Demo", DST);
}


void Main ()
{img=cvloadimage ("2.bmp", 1);


Image=cvcreateimage (Cvgetsize (IMG), ipl_depth_8u,1); Here is the conversion of grayscale images. Then Gaussian smoothing for grayscale images
Dst=cvcreateimage (Cvgetsize (IMG), ipl_depth_8u,1);
Cvcvtcolor (Img,image,cv_bgr2gray);



Dst=cvcreateimage (Cvgetsize (IMG), ipl_depth_8u,3); Gaussian smoothing of images directly for color images



Cvnamedwindow ("Smooth Demo", 1);

Cvcreatetrackbar ("Param1", "Smooth Demo", &param1,99,switch_callback);
Cvcreatetrackbar ("Param2", "Smooth Demo", &param2,99,switch_callback);


while (1)
{
if (Cvwaitkey (15) ==27)
Break
}
Cvreleaseimage (&AMP;IMG);
Cvreleaseimage (&image);
Cvreleaseimage (&AMP;DST);


Cvdestroywindow ("Smooth Demo");
}

Use of sliders in OpenCV

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.