Skip to content

OpenCV

import cv2 as cv
improt numpy as np
import matplotlib.pyplot as plt

Read Image

img = cv.imread(
  "/fruits.jpg",
  cv.IMREAD_GRAYSCALE # COLOR, GRAYSCALE, UNCHANGED
) # numpy array
# x, y, channel
img[:, :, 0] # particular channel only

Show

plt.axis("off")
plt.imshow(img)
plt.show()

Filters

img = cv.cvtColor(
  img,
  cv.COLOR_BGR2RGB
)

Export

cv.imwrite(
    "output.png",
  img
)
Last Updated: 2024-05-12 ; Contributors: AhmedThahir

Comments