5
creo un'immagine rossa e cercare di salvarlo tramite cv2.imwriteTypeError: tipo di dati img = 17 non è supportato
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)
Ma ottengo l'errore
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
Come risolvere il problema?
Grazie!
Perché si utilizza 'DTYPE = tipo di (RED)' 'per image'? 'type (RED)' è una lista python; usando ciò rende 'image' una matrice di oggetti python (e non una con un tipo numerico). Perché non usare, ad esempio, 'dtype = int'? –
Se uso 'dtype = type (int)' (e 'RED = 200') allora otterrò lo stesso errore – IvanovAndrew
Ue' dtype = int' (non 'type (int)'). Impostando 'dtype' si imposta il tipo di dati degli elementi dell'array che si sta creando. –