Skip to content

Latest commit

 

History

History

read_img

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Difference Between Pillow and CV2

pre-requisite

$ pip install opencv-python
$ pip install Pillow
$ pip install matplotlib

Contents

Read Image by CV2

import matplotlib.pyplot as plt
import cv2
img_path = ...
img = cv2.imread(img_path) # h, w, 3
# print(img.shape)
# reverse the last channel
# img = img[:, :, ::-1]
plt.imshow(img)
  • if not reverse the last channel:

  • if reversed:

Read Image by Pillow

import matplotlib.pyplot as plt
import PIL.Image as Image
img_path = ...
img = Image.open(img_path)
# print(img.size)
plt.imshow(img)
  • You don't need to do other operations