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


Posted in Python onSeptember 05, 2019

本文实例讲述了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 运行结果

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

二 高斯滤波

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 运行结果

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

三 边缘锐化处理

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 运行结果

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

四 中值滤波

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图像处理模块ndimage用法实例分析

更多关于Python相关内容可查看本站专题:《Python图片操作技巧总结》、《Python数据结构与算法教程》、《Python函数使用技巧总结》、《Python字符串操作技巧汇总》及《Python入门与进阶经典教程》

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

Python 相关文章推荐
python自动化测试实例解析
Sep 28 Python
Python自动重试HTTP连接装饰器
Apr 28 Python
Python实现屏幕截图的代码及函数详解
Oct 01 Python
Python正则表达式非贪婪、多行匹配功能示例
Aug 08 Python
Python实现检测文件MD5值的方法示例
Apr 11 Python
Python3非对称加密算法RSA实例详解
Dec 06 Python
Python 多线程不加锁分块读取文件的方法
Dec 11 Python
python按比例随机切分数据的实现
Jul 11 Python
django中上传图片分页三级联动效果的实现代码
Aug 30 Python
TensorBoard 计算图的查看方式
Feb 15 Python
jupyter notebook 的工作空间设置操作
Apr 20 Python
Python with语句用法原理详解
Jul 03 Python
Pycharm+django2.2+python3.6+MySQL实现简单的考试报名系统
Sep 05 #Python
PyCharm搭建Spark开发环境的实现步骤
Sep 05 #Python
浅谈Python_Openpyxl使用(最全总结)
Sep 05 #Python
python实现人工智能Ai抠图功能
Sep 05 #Python
深入了解Python在HDA中的应用
Sep 05 #Python
python urllib爬虫模块使用解析
Sep 05 #Python
详解Python3 pandas.merge用法
Sep 05 #Python
You might like
PHP中Session的概念
2006/10/09 PHP
PHP 中的批处理的实现
2007/06/14 PHP
定义php常量的详解
2013/06/09 PHP
PHP按行读取、处理较大CSV文件的代码实例
2014/04/09 PHP
Linux+Nginx+MySQL下配置论坛程序Discuz的基本教程
2015/12/23 PHP
PHP中strpos、strstr和stripos、stristr函数分析
2016/06/11 PHP
yii2简单使用less代替css示例
2017/03/10 PHP
Laravel网站打开速度优化的方法汇总
2017/07/16 PHP
php+mysql开发的最简单在线题库(在线做题系统)完整案例
2019/03/30 PHP
漂亮的提示信息(带箭头)
2007/03/21 Javascript
js从10种颜色中随机取色实现每次取出不同的颜色
2013/10/23 Javascript
jQuery控制cookie过期时间的方法
2015/04/07 Javascript
JS实现商品筛选功能
2020/08/19 Javascript
nodejs使用http模块发送get与post请求的方法示例
2018/01/08 NodeJs
jquery实现的分页显示功能示例
2019/08/23 jQuery
基于JavaScript获取base64图片大小
2019/10/18 Javascript
python实现dict版图遍历示例
2014/02/19 Python
Python采用raw_input读取输入值的方法
2014/08/18 Python
Python解析excel文件存入sqlite数据库的方法
2016/11/15 Python
详解Python自建logging模块
2018/01/29 Python
Python搭建代理IP池实现接口设置与整体调度
2019/10/27 Python
flask框架json数据的拿取和返回操作示例
2019/11/28 Python
pytorch cuda上tensor的定义 以及减少cpu的操作详解
2020/06/23 Python
Django中和时区相关的安全问题详解
2020/10/12 Python
英国豪华家具和经典家居饰品购物网站:OKA
2020/06/05 全球购物
什么是JNDI的上下文?如何初始化JNDI上下文
2012/03/10 面试题
银行员工职业规划范文
2014/01/21 职场文书
求职信需要的五点内容
2014/02/01 职场文书
大学生就业意向书范文
2014/04/01 职场文书
中华魂放飞梦想演讲稿
2014/08/26 职场文书
民警群众路线教育实践活动对照检查材料
2014/10/04 职场文书
2014年护理部工作总结
2014/11/14 职场文书
2015年求职自荐信范文
2015/03/04 职场文书
反腐倡廉影片观后感
2015/06/08 职场文书
[有人@你]你有一封绿色倡议书,请查收!
2019/07/18 职场文书
深入理解go slice结构
2021/09/15 Golang