Python图像高级滤波之局部梯度法

 时间:2026-02-17 07:52:20

1、打开IDLE:

IDLE是Python shell界面。

Python图像高级滤波之局部梯度法

2、采用工具包:

Python的使用需要导入相关的工具包,这里使用的包如下,如果报错则可能没有安装相关的工具包,

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.gradient(img, disk(5))

Python图像高级滤波之局部梯度法

5、显示效果:

可采用下面代码画出我们滤波的效果,

plt.figure('gradient') 

plt.subplot(121) 

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

plt.subplot(122) 

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

plt.show()

Python图像高级滤波之局部梯度法

6、效果如下。

Python图像高级滤波之局部梯度法

  • 卧室和办公室在一起花盆如何摆放
  • 懂球帝怎么查看设置屏蔽的内容
  • 花生的生长特点有哪些
  • 快手汤--冻豆腐紫菜汤
  • ZDS示波器有几个系列类型?
  • 热门搜索
    什么是细节描写 clock是什么意思 少校是什么级别 男朋友过生日送什么礼物好 弥留之际是什么意思 惟妙惟肖是什么意思 上位是什么意思 送礼送什么好 保鲜膜属于什么垃圾 dc什么意思