《python+opencv3.3视频教学 基础入门》边缘保留滤波(EPF) 笔记

源码:

import cv2 as cv
import numpy as np


# 高斯双边模糊
def bi_demo(image, sigmacolor, sigmaspace):
    # Parameter:
    #     1. src : Source 8-bit or floating-point, 1-channel or 3-channel image.
    #     2. d : Diameter of each pixel neighborhood that is used during filtering.
    #     If it is non-positive, it is computed from sigmaSpace .
    #     3. sigmaColor : Filter sigma in the color space. A larger value of the
    #     parameter means that farther colors within the pixel neighborhood (see
    #     sigmaSpace ) will be mixed together, resulting in larger areas of
    #     semi-equal color.
    #     4. sigmaSpace : Filter sigma in the coordinate space. A larger value of
    #     the parameter means that farther pixels will influence each other as
    #     long as their colors are close enough (see sigmaColor ). When d>0 ,
    #     it specifies the neighborhood size regardless of sigmaSpace . Otherwise,
    #     d is proportional to sigmaSpace .
    dst = cv.bilateralFilter(image, 0, sigmacolor, sigmaspace)
    return dst


# 均值迁移
def shift_demo(image, sp, sr):
    # Parameters:
    #     src: 操作图像。
    #     sp: 漂移物理空间半径大小。
    #     sr: 漂移色彩空间半径大小。
    dst = cv.pyrMeanShiftFiltering(image, sp, sr)
    return dst


print("-----------Hello Python------------")
src = cv.imread("C:/cvtest/woman1.jpg")
cv.namedWindow("input image", cv.WINDOW_AUTOSIZE)
cv.imshow("input image", src)

# dst = bi_demo(src, 50, 15)
# cv.imshow("bi_demo1", dst)
# dst = bi_demo(src, 100, 15)
# cv.imshow("bi_demo2", dst)

dst = shift_demo(src, 10, 20)
cv.imshow("shift_demo1", dst)
dst = shift_demo(src, 10, 80)
cv.imshow("shift_demo2", dst)


cv.waitKey(0)

cv.destroyAllWindows()

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值