python skimage模块处理图片

pip 安装skimage模块

图片裁剪:

img_file2 = io.imread('./waveform/my.jpg')#导入图片数据


size=img_file2.shape#读图片后数据的大小:高,宽,每个像素点的rgb数值个数
print(size)
img_file3=img_file2[92:691, 165:1189]

 

源码:

 1 import matplotlib.pyplot as plt
 2 import matplotlib.image as mpimg
 3 
 4 from skimage import io,transform
 5 
 6 img_file2 = io.imread('E:/caiya for job/python/IT6302/waveform/20200619_104954.bmp')#导入图片数据
 7 
 8 size=img_file2.shape#读图片后数据的大小:高,宽,每个像素点的rgb数值个数
 9 print(size)
10 for i in range(0,size[0]):
11     for j in range(0,size[1]):
12         for k in range(0,3):
13             data=img_file2[i][j][k]#获取每个像素点相应的rgb值
14             img_file2[i][j][k]=255-data#修改每个像素点的相应的rgb值
15 
16 io.imshow(img_file2)
17 plt.show()
18 io.imsave('E:/caiya for job/python/IT6302/waveform/img.bmp',img_file2)#保存图片

 

posted @ 2020-06-19 11:32  菜芽caiya  阅读(385)  评论(0编辑  收藏  举报