We’re going to understand today how do computers see images. I’m going to explain that using python with opencv.

Here below the python code used in the video tutorial:

import cv2
import numpy as np

# Black square
img = np.zeros((10, 10, 3), np.uint8)
img[0, 0] = (255, 0, 0)  # Blue
img[0, 1] = (0, 255, 0)  # Green
img[0, 2] = (0, 0, 255)  # Red
img[1, 0] = (0, 150, 150)  # Yellow (green + red)
img[1, 1] = (150, 0, 180)  # Magenta (blue + red)


# Resizing the image x100 to see each pixel big
img = cv2.resize(img, (1000, 1000), interpolation=cv2.INTER_AREA)

# Show the image
cv2.imshow("Image", img)
cv2.waitKey(0)