$ pip install opencv-python
$ pip install Pillow
$ pip install matplotlib
- Relative Code is here show_img.py
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:
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