python图像高级滤波之减均值滤波

 时间:2026-02-17 10:15:34

1、打开idle:

界面如下图所示,也就是大家所说的Python shell界面。

python图像高级滤波之减均值滤波

2、载入库:

这里主要用到skimage库,具体代码如下,如果报错则说明没有安装相关的库。

from skimage import data,color

import matplotlib.pyplot as plt

from skimage.morphology import disk

import skimage.filters.rank as sfr

python图像高级滤波之减均值滤波

3、读取灰度图:

这里读取skimage库内的一张图片,并且将其进行灰度化处理。

img=color.rgb2gray(data.coffee())

python图像高级滤波之减均值滤波

4、减均值滤波处理:

减均值滤波的一种简单的实现方法就是,采用下面的一条指令进行处理,同时也可以采用原图减去均值滤波得到的图像的方法。

dst =sfr.subtract_mean(img, disk(5))

python图像高级滤波之减均值滤波

5、显示结果:

plt.figure('filter')

plt.subplot(121)

plt.imshow(img,plt.cm.gray)

plt.subplot(122)

plt.imshow(dst,plt.cm.gray)

plt.show()

python图像高级滤波之减均值滤波

6、结果如下。

python图像高级滤波之减均值滤波

  • Python图像高级滤波之均值滤波
  • Python图像高级滤波之均衡化滤波
  • Python图像高级滤波之最大值滤波
  • Python图像高级滤波之局部梯度法
  • 用scipy进行图像滤波处理(python3.6)
  • 热门搜索
    成百上千的意思 影影绰绰的意思 童心未泯是什么意思 spa是什么意思 邂逅是什么意思 彩排的意思 随遇而安的意思是什么 什么是负面清单 读书破万卷下笔如有神是什么意思 青汁的作用