zoukankan      html  css  js  c++  java
  • opencv 图像平滑 图像模糊

    图像平滑(图像模糊):

        一幅图像和一个低通滤波器进行卷积,能够实现图像平滑效果,也就是图像模糊效果。平滑操作通常会从图像中移除高频信息(噪音、边缘)。所以图像平滑后,图像边缘往往会被模糊(本文介绍的最后一种双边模糊技术基本不会模糊图像边缘)。Opencv 提供了多种图像平滑技术,也叫图像模糊技术。


    1. 平均模糊

    # kernel size is 5*5

    blur = cv.blur(img,(5,5))


    2. 高斯模糊

    # kernel size is 5*5,0:标准差根据核大小得出

    blur = cv.GaussianBlur(img,(5,5),0)


    3. 中值模糊

    # kernel size is 5*5

    median = cv.medianBlur(img,5)


    4. 双边模糊

    # cv.bilateralFilter is highly effective in noise removal while keeping edges sharp

    blur = cv.bilateralFilter(img,9,75,75)


    实验代码:

     1 import cv2 as cv
     2 
     3 import numpy as np
     4 
     5 from matplotlib import pyplot as plt
     6 
     7 image1 = cv.imread('../paojie_sp2.jpg')
     8 
     9 avg_img = cv.blur(image1,(5,5))
    10 
    11 gau_img = cv.GaussianBlur(image1,(5,5),0)
    12 
    13 med_img = cv.medianBlur(image1,5)
    14 
    15 bil_img = cv.bilateralFilter(image1,9,75,75)
    16 
    17 plt.figure(1)
    18 
    19 plt.subplot(231),plt.imshow(image1),plt.title('Original'),plt.axis('off')
    20 
    21 plt.subplot(232),plt.imshow(avg_img),plt.title('Average Blur'),plt.axis('off')
    22 
    23 plt.subplot(233),plt.imshow(gau_img),plt.title('Gaussian Blur'),plt.axis('off')
    24 
    25 plt.subplot(234),plt.imshow(med_img),plt.title('Median Blur'),plt.axis('off')
    26 
    27 plt.subplot(235),plt.imshow(bil_img),plt.title('Bilateral Blur'),plt.axis('off')
    28 
    29 plt.show()

    实验结果:


    各种图像平滑方法的输出结果 ↑
  • 相关阅读:
    STP-5-STP配置及分析
    PostgreSQL-10-数据运算与函数
    PostgreSQL-9-别名与动态表复制
    PostgreSQL-8-数据合并
    PostgreSQL-7-数据连接
    PostgreSQL-6-数据分组
    STP-4-每VLAN生成树和Trunk上的STP
    VLAN-6-VLAN Trunk协议(VTP)
    STP-3-收敛到新的STP拓扑
    STP-2-三个选择
  • 原文地址:https://www.cnblogs.com/wojianxin/p/12548624.html
Copyright © 2011-2022 走看看