python3-scikit-image图像读取,保存,显示

发布时间:2021-07-26 14:53:39编辑:run阅读(2679)

    scikit-image是一种开源的用于图像处理的 Python 包。它包括分割,几何变换,色彩操作,分析,过滤等算法,

    安装:

    pip install scikit-image

    pip install scikit-learn

    pip install simpleITK



    from skimage.io import imread, imsave, imshow, show, imread_collection, imshow_collection

    from skimage import color


    读取图片

    im = imread(r'D:\image_processing\image_material\77.jpg')

    print(im.shape, im.dtype, type(im))

    用rgb2hsv()函数从image.color模块将彩色RGB图像转换为hsv图像(更改图像类型或模式)

    将所有像素点的饱和度(色彩)更改为常量值,但色调和值通道保持不变,这样图像就被rgb2hsv

    函数转换成了RGB模式

    hsv = color.rgb2hsv(im)

    hsv[:, :, 1] = 1

    im1 = color.hsv2rgb(hsv)

    保存图片

    imsave(r'D:\image_processing\image_material\77_code.jpg', im1)

    im = imread(r'D:\image_processing\image_material\77_code.jpg')

    imshow(im)

    show()

    原图:

    image.png

    饱和度发生改变后的图

    image.png


    一次性读取文件夹下的所有图

    img_path = 'D:/image_processing/jpgs/' + '*.jpg'

    如有多种类型图片

    img_path ='D:/image_processing/jpgs/*.jpg:D:/image_processing/jpgs/*.png'

    coll = imread_collection(img_path)

    imshow_collection(coll)

    show()

    image.png

关键字