Eight. Smooth operation with OPENCV image

Source: Internet
Author: User


1.cvSmooth function

The function Cvsmooth can use simple fuzzy, simple non-scaling transform of fuzzy, median fuzzy, Gaussian blur, bilateral filtering of whatever method smoothing the image. Each method has its own characteristics and limitations. Image smoothing without scaling supports only single-channel images and supports 8-bit to 16-bit conversions ( similar to cvsoble and Cvaplace) and 32-bit floating-point numbers to 32-bit floating-point conversion formats.

simple Blur and the Gaussian Blur supports 1-or 3-channel, 8-bit and 32-bit floating-point images.

These two methods are capable of processing images (in-place).

median and bidirectional filtering works on 1-or 3-channel, 8-bit images, but cannot process images in a in-place manner.

Defining prototypes

void Cvsmooth (const cvarr* src, cvarr* dst,int Smoothtype=cv_gaussian,
int param1, int param2, double param3, double param4);


src: Enter an image.
DST: Output image.
Smoothtype Smoothing Method:
Cv_blur_no_scale (simple blur without scale transformation)-sums the param1xparam2 fields of each pixel. Assuming that the neighborhood size is variable, the integral image can be computed in advance using the function cvintegral.
Cv_blur (Simple BLUR)--sum the param1xparam2 neighborhood of each pixel and do a scale transform 1/(PARAM1XPARAM2).
Cv_gaussian (GAUSSIAN Blur)-A Gaussian convolution with a kernel size of param1xparam2 for the image.


Cv_median (MEDIAN Blur)--The median filter for the image with a kernel size of param1xparam1 (neighborhood is square).
Cv_bilateral (bidirectional filtering)-Application of bi-directional 3x3 filtering, color sigma=param1. Space Sigma=param2.



2. Example


iplimage* captureimg () {iplimage* pImg = NULL; cvcapture* Pcam = Null;pcam = Cvcreatecameracapture (0), if (NULL = = Pcam) {fprintf (stderr, "Can ' t init camera!\n"); return NU LL;} Cvsetcaptureproperty (Pcam, Cv_cap_prop_frame_width, 640); Cvsetcaptureproperty (Pcam, cv_cap_prop_frame_height,480) ;p img = cvqueryframe (PCAM), if (null = = PIMG) {fprintf (stderr, "Can ' t get one frame\n"); return NULL;} Cvsaveimage ("Capture.jpg", PIMG, 0); return pImg;} Image processing iplimage* handleimg (iplimage* pImg) {iplimage* pDst = null;if (NULL = = pImg) {printf ("The pImg you need handle are null! \ n "); return NULL;} PDst = Cvcreateimage (Cvgetsize (PIMG), ipl_depth_8u, 3);//Smooth processing Cvsmooth (PIMG, PDst, Cv_gaussian, 5, 5, 0, 0); Cvsaveimage (" Smooth.jpg ", pDst, 0); return pDst;}

:

after Blur:









Copyright notice: This article blog original articles, blogs, without consent, may not be reproduced.

Eight. Smooth operation with OPENCV image

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.