[置顶] 【python 图像处理】skimage的子模块介绍
2017-08-29 14:53
435 查看
skimage包的全称是scikit-image SciKit (toolkit for SciPy) ,它对scipy.ndimage进行了扩展,提供了更多的图片处理功能。它是由python语言编写的,由scipy 社区开发和维护。skimage包由许多的子模块组成,各个子模块提供不同的功能。主要子模块如下:
用到一些图片处理的操作函数时,需要导入对应的子模块,如果需要导入多个子模块,则用逗号隔开,如:
io:读取、保存和显示图片或视频 data:提供一些测试图片和样本数据 color:颜色空间变换 filters:图像增强、边缘检测、排序滤波器、自动阈值等 draw:操作于numpy数组上的基本图形绘制,包括线条、矩形、圆和文本等 transform:几何变换或其它变换,如旋转、拉伸和拉东变换等 morphology:形态学操作,如开闭运算、骨架提取等 exposure:图片强度调整,如亮度调整、直方图均衡等 feature:特征检测与提取等 measure:图像属性的测量,如相似性或等高线等 segmentation:图像分割 restoration:图像恢复 util:通用函数
用到一些图片处理的操作函数时,需要导入对应的子模块,如果需要导入多个子模块,则用逗号隔开,如:
from skimage import data, color, io
#-*-coding:utf-8-*- import sys reload(sys) sys.setdefaultencoding('utf-8') from skimage import io,color import numpy as np # 如果想读取灰度图,可以将imread的as_grey参数置为True,as_grey默认值为False。 image=io.imread("E:/ID/5.jpg") io.imshow(image) io.show() # io.imsave("E:/ID/6.jpg",image) #####################################加入噪声(像素点设置成255(白色),0(黑色)######################## def add_noise(image): rows, cols, dim3 = image.shape print rows, cols, dim3 n = rows * cols / 10 print n for i in range(n): x = np.random.randint(0, rows) y = np.random.randint(0, cols) print x,y image[x, y, :] = 255 return image image = add_noise(image) io.imshow(image) io.show() #####################图像裁剪########################## roi=image[12:120, 10:110, :] io.imshow(roi) io.show() #########################二值化处理####################### image1=io.imread("E:/ID/3.jpg") img_gray=color.rgb2gray(image1) rows,cols=img_gray.shape for i in range(rows): for j in range(cols): if (img_gray[i,j]<=0.8): img_gray[i,j]=0 else: img_gray[i,j]=1 # 使用了color模块的rgb2gray()函数,将彩色三通道图片转换成灰度图。转换结果为float64类型的数组,范围为[0,1]之间。 io.imshow(img_gray) io.show()
相关文章推荐
- [置顶] 【python 图像处理】Python 图像处理库 Pillow 入门
- python skimage图像处理
- 『Python』skimage图像处理_旋转图像
- [置顶] 【python 图像处理】各种卷积滤波器的效果--cv2
- 用 python skimage做图像处理
- [置顶] 【python 图像处理】Python图像处理模块pillow子模块Image用法精要
- python图像处理之skimage
- [置顶] Python计算机视觉Learning(一)-- Python图像处理类库--PIL
- 图像处理库python skimage
- Python3.5 图像处理 Pillow 库 CentOS 6.5 安装
- python 调用图像处理类库PIL 时遇到的问题
- 用python简单处理图片(2):图像通道\几何变换\裁剪
- python数字图像处理(10):图像简单滤波
- 用Python做图像处理
- python图像处理之镜像实现方法
- 用Python做图像处理,支持python3
- Python图像处理库:PIL中Image,ImageDraw等基本模块介绍
- [Python] 图像简单处理(PIL or Pillow)
- Python图像处理库:Pillow 初级教程
- Python图像处理库PIL的ImageEnhance模块介绍