Reading bmp files in Python

前端 未结 7 1300
北荒
北荒 2021-02-19 01:41

Is there a way to read in a bmp file in Python that does not involve using PIL? PIL doesn\'t work with version 3, which is the one I have. I tried to use the Image object from g

7条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-19 02:05

    In Python it can simply be read as:

    import os
    from scipy import misc
    path = 'your_file_path'
    image= misc.imread(os.path.join(path,'image.bmp'), flatten= 0)
    
    ## flatten=0 if image is required as it is 
    ## flatten=1 to flatten the color layers into a single gray-scale layer
    

提交回复
热议问题