Opencv-python (9)--Image smoothing and filtering

Source: Internet
Author: User
Tags function prototype

I. Introduction to Functions 1, blur-image mean smoothing filter function prototype: Blur (SRC, ksize, Dst=none, Anchor=none, bordertype=none) src: Image Matrix Ksize: Filter window size 2, gaussianblur-Image Gaussian smoothing filter function prototype: Gaussianblur (SRC, ksize, Sigmax, Dst=none, Sigmay=none, Bordertype=none) SRC: Image Matrix Ksize: Filter window size Sigmax: Standard deviation 3, medianblur-image median filter function prototype: Medianblur (SRC, ksize, dst=none) src: Image Matrix Ksize: Filter window size 4, bilateralfilter-Image Bilateral filter function prototypes: Bilateralfilter (SRC, D, Sigmacolor, Sigmaspace, Dst=none, Bordertype=none) SRC: Image matrix D: Neighborhood diameter sigmacolor: color standard deviation sigmaspace: space standard deviation Two, example walkthrough 1, image mean smoothing filter code is as follows:
#encoding: Utf-8Import NumPy as Npimport cv2image = Cv2. Imread("H:\\img\\lena.jpg") Cv2. Imshow("Original", image) Cv2. Waitkey(0)#领域均值滤波Blurred = NP. Hstack([Cv2. Blur(Image, (3,3)), Cv2. Blur(Image, (5,5)), Cv2. Blur(Image, (7,7)]) Cv2. Imshow("averaged", blurred) Cv2. Waitkey(0)
The results are as follows: Original image:

Image after drawing (from left to right window width: 3, 5, 7)

2, the image Gaussian smoothing filter code is as follows:
#encoding: Utf-8Import NumPy as Npimport cv2image = Cv2. Imread("H:\\img\\lena.jpg") Cv2. Imshow("Original", image) Cv2. Waitkey(0)#高斯滤波Blurred = NP. Hstack([Cv2. Gaussianblur(Image, (3,3),0), Cv2. Gaussianblur(Image, (5,5),0), Cv2. Gaussianblur(Image, (7,7),0)]) Cv2. Imshow("Gaussian", blurred) Cv2. Waitkey(0)
The results are as follows: Original image:

Image after drawing (from left to right window width: 3, 5, 7, standard deviation is: 0)

3, the image median filter code is as follows:
#encoding: Utf-8Import NumPy as Npimport cv2image = Cv2. Imread("H:\\img\\lena.jpg") Cv2. Imshow("Original", image) Cv2. Waitkey(0)#中值滤波Blurred = NP. Hstack([Cv2. Medianblur(Image,3), Cv2. Medianblur(Image,5), Cv2. Medianblur(Image,7)]) Cv2. Imshow("Median", blurred) Cv2. Waitkey(0)
The results are as follows: Original image:

Image after drawing (from left to right window width: 3, 5, 7)

4. The Image bilateral filter code is as follows:
#encoding: Utf-8Import NumPy as Npimport cv2image = Cv2. Imread("H:\\img\\lena.jpg") Cv2. Imshow("Original", image) Cv2. Waitkey(0)#双边滤波Blurred = NP. Hstack([Cv2. Bilateralfilter(Image,5, +, +), Cv2. Bilateralfilter(Image,7, to, to), Cv2. Bilateralfilter(Image,9, A, A)]) Cv2. Imshow("Bilateral", blurred) Cv2. Waitkey(0)
The results are as follows: Original image:

Image after drawing (refer to the explanation in the above function prototype for the relevant parameter meaning)

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Opencv-python (9)--Image smoothing and filtering

Related Article

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.