Avatar ·

How to generate an image in Python?

📁 Advanced Python Topics, example, AI

I can load the image and display it as follows:

import cv2
img = cv2.imread("1.jpg")
cv2.imshow("Original", img)

For example, I can load any image, draw a white rectangle on it, and display it on the screen.

However, what if I want to get a white image without preliminary loading? How to replace the loading operation with generating an image object?