python ndimage_Python图像处理模块ndimage用法实例分析

本文实例讲述了Python图像处理模块ndimage用法。分享给大家供大家参考,具体如下:

一 原始图像

1 代码

from scipy import misc

from scipy import ndimage

import matplotlib.pyplot as plt

face = misc.face()#face是测试图像之一

plt.figure()#创建图形

plt.imshow(face)#绘制测试图像

plt.show()#原始图像

2 运行结果

二 高斯滤波

1 代码

from scipy import misc

from scipy import ndimage

import matplotlib.pyplot as plt

face = misc.face()#face是测试图像之一

plt.figure()#创建图形

blurred_face = ndimage.gaussian_filter(face, sigma=7)#高斯滤波

plt.imshow(blurred_face)

plt.show()

2 运行结果

三 边缘锐化处理

1 代码

from scipy import misc

from scipy import ndimage

import matplotlib.pyplot as plt

face = misc.face()#face是测试图像之一

plt.figure()#创建图形

blurred_face1 = ndimage.gaussian_filter(face, sigma=1)#边缘锐化

blurred_face3 = ndimage.gaussian_filter(face, sigma=3)

sharp_face = blurred_face3 +6*(blurred_face3-blurred_face1)

plt.imshow(sharp_face)

plt.show()

2 运行结果

四 中值滤波

1 代码

from scipy import misc

from scipy import ndimage

import matplotlib.pyplot as plt

face = misc.face()#face是测试图像之一

plt.figure()#创建图形

median_face = ndimage.median_filter(face,7)#中值滤波

plt.imshow(median_face)

plt.show()

2 运行结果

希望本文所述对大家Python程序设计有所帮助。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值