I create red image and try to save it via cv2.imwrite
import numpy as np
import cv2
RED = [0, 0, 255]
IMAGE_SIZE = 100
image = np.empty([IMAGE_SIZE, IMAGE_SIZE], dtype=type(RED))
for i in range(IMAGE_SIZE):
for j in range(IMAGE_SIZE):
image[i, j] = RED
cv2.imwrite("red.png", image)
But I get error
File "C:/Users/Andrew/Desktop/Programms/image-processing-cource/Tracks.py", line 11, in save_image
cv2.imwrite(name, image)
TypeError: img data type = 17 is not supported
How to fix it?
Thanks!
dtype = type(RED)
gives you type list
and not type int
.
you need:
image = np.empty([IMAGE_SIZE, IMAGE_SIZE, 3], dtype=type(RED[0]))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With