python图像处理常用方法

在线标注网站
https://gitlab.com/vgg/via
http://www.robots.ox.ac.uk/~vgg/software/via/via.html

数组与图像互转

from matplotlib import image
image.imsave('/xxx/%d.jpg'%d,  array, cmap='gray')   #数组转灰度图,jpg为三个通道数值一样
arr = image.imread("")

灰度图增强对比度

from PIL import Image
from PIL import ImageEnhance

img = Image.open('/xxx/xx.jpg')
img.show()
enh_con = ImageEnhance.Contrast(img)  
contrast = 1.5  #增强的倍数
img_contrasted = enh_con.enhance(contrast)  
img_contrasted.show()

读CSV

with open('/xxx.csv')as f:
    csv_reader = csv.reader(f)
    for row in csv_reader:
        print(row)

相关推荐