文章目录
一、代码
代码如下(有空就来补一下过程):
#!/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)
nowarray=

博客介绍了使用Python进行均值滤波的代码实现,具体内容待补充。
最低0.47元/天 解锁文章
4594

被折叠的 条评论
为什么被折叠?



