‘mat’ is a 1000000*16 Boole Matrix, and I want to convert the matrix to a photo.(1 is white, 0 is black)
There is something wrong when I utilise ‘@ti.kernel’, however, ‘@ti.pyfunc’ is fine. Could u plz tell me the reason? And how to fix it if I want to use ‘@ti.kernel’? Thank you in advance.
import taichi as ti import tomatrix ti.init(arch=ti.gpu) mat=tomatrix.mat shape = (16, len(mat)) type = ti.u8 pixels = ti.var(dt=type, shape=shape) #print(mat) @ti.kernel def draw(): for i in range(len(mat)): for j in range (16): if mat[i,j] == 1: pixels[j,i] = 255 # integars between [0, 255] for ti.u8 else: pixels[j,i] = 0 draw() ti.imwrite(pixels, f"export.png")