【python学习笔记】27:scipy中ndimage模块作图像滤波
来源:互联网 发布:c语言中调用文本文件 编辑:程序博客网 时间:2024/05/26 22:06
scipy的ndimage可以用于做n维图像的处理。
*高斯滤波
>>> from scipy import misc>>> from scipy import ndimage>>> import matplotlib.pyplot as plt>>> test=misc.ascent() #用于测试的图像>>> plt.figure() #创建画布<matplotlib.figure.Figure object at 0x000000000687D860>>>> plt.imshow(test) #绘制测试图像<matplotlib.image.AxesImage object at 0x0000000006F4AB00>>>> plt.show() #显示原始图像
>>> gaus_test=ndimage.gaussian_filter(test,sigma=7) #高斯滤波>>> plt.imshow(gaus_test) #绘制新产生的图像(数组)<matplotlib.image.AxesImage object at 0x0000000007492588>>>> plt.show() #显示更新后的画布
*图像边缘化
因为图像是用数组表示的,可以先作高斯滤波让它们一定程度上变模糊,然后相减,那些相似的值就变小了,再进行一定倍数的放大(让小的值和大的值相差更多),然后加到某个基准值上,就可以实现边缘锐化了。
>>> gaus1=ndimage.gaussian_filter(test,sigma=1)>>> gaus3=ndimage.gaussian_filter(test,sigma=3)>>> sharp=gaus3+6*(gaus3-gaus1) #作差放大并加到基准值上>>> plt.imshow(sharp)<matplotlib.image.AxesImage object at 0x0000000007709CF8>>>> plt.show()
*用ndimage中值滤波
>>> mid_test=ndimage.median_filter(test,7) #直接作中值滤波>>> plt.imshow(mid_test)<matplotlib.image.AxesImage object at 0x0000000007884EB8>>>> plt.show()
这里用ndimage.median_filter()可以直接作二维图像的中值滤波,在参数中指定邻域(滤波窗口的像素长)。
该模块的更多方法,可以在导入后用dir查看。
阅读全文
0 0
- 【python学习笔记】27:scipy中ndimage模块作图像滤波
- 【python学习笔记】28:scipy的ndimage模块中有关数学形态学
- 【python学习笔记】25:scipy中值滤波
- Python SciPy Sparse模块学习笔记
- Python SciPy Sparse模块学习笔记
- python中scipy模块学习(假设检验)
- python的scipy学习笔记
- python中如何安装SciPY模块
- 图像处理模块ndimage
- Python模块之SciPy
- python Scipy模块
- python学习笔记:ipython,scipy,pandas,flask
- 【python学习笔记】26:scipy卷积运算
- 机器学习笔记--python之scipy
- No module named 'scipy'问题 与 python中 scipy模块的安装
- python SciPy模块的使用
- python 安装 numpy,scipy模块
- Python numpy scipy模块安装
- 机器学习基础
- k8s被minerd入侵处理
- 关闭授权=测试
- 用C语言判断1000年~2000年之间的闰年
- Hadoop工程师面试题:使用linux命令完成文本处理
- 【python学习笔记】27:scipy中ndimage模块作图像滤波
- Python 字符串
- 堆(优先队列,最大堆的基本操作,堆的例题)
- office重装之旅(激活失败,被迫重装)
- 判断两个区间有无交集
- android:如何获取root权限
- Java中final修饰参数的作用
- UDP协议服务器、客户端使用实例Demo
- superset安装部署