python均值滤波代码

博客介绍了使用Python进行均值滤波的代码实现,具体内容待补充。
摘要由CSDN通过智能技术生成

文章目录


一、代码

代码如下(有空就来补一下过程):

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2020/11/16 11:16
# @Author  : Xilun Wu
# @email   : nnuwxl@gmail.com
# @File    : sumPass.py.py

"""
此程序用来实现均值滤波
用的模块是opencv
"""

import cv2
import numpy as np

# 读取图像,解决imread不能读取中文路径的问题, 返回RGB图像
def cv_imread(filePath):
    cv_img = cv2.imdecode(np.fromfile(filePath, dtype=np.uint8), -1)  # BGR
    ## imdecode读取的是rgb,如果后续需要opencv处理的话,需要转换成bgr,转换后图片颜色会变化
    # cv_img=cv2.cvtColor(cv_img,cv2.COLOR_RGB2BGR)  # RGB
    return cv_img


# 读取图像,解决imwrite不能读取中文路径的问题
def cv_imwrite(filePath, inputimg):
    cv_img = cv2.imencode(".jpg", inputimg)[1].tofile(filePath)
    return cv_img

if __name__ == "__main__":
    # 主函数
    picfile = input()
    picfile = r"{}".format(picfile)
    # 用来读取图片所在的地址(转utf-8)
    img = cv_imread(picfile)
    img = np.array(img,dtype=float
  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值