Closed luelueluelueluelueluelue closed 2 years ago
How about screen = ti.Vector.field(3,dt=ti.f32,shape=(w, h))
? You probably need field
there.
the complete code is as follows:
import numpy as np
import taichi as ti
import time as time
from CVT_Lloyd import cvt_lloyd_solver_2D
ti.init(arch=ti.gpu, kernel_profiler=True)
w = 512
h = 512
step = (int(np.power(2, np.ceil(np.log(w)))),int(np.power(2, np.ceil(np.log(h)))))
screen = ti.Vector(3, dt=ti.f32, shape=(w, h))
seeds = np.array(np.random.rand(100, 2), dtype=np.float32)
seeds_info = np.array(np.random.rand(100, 3), dtype=np.float32)
info = ti.Vector(3, dt=ti.f32, shape=seeds_info.shape[0])
cvt_solver = cvt_lloyd_solver_2D(w, h, seeds)
info.from_numpy(seeds_info)
cvt_solver.solve_cvt()
cvt_solver.jfa.render_color(screen, info)
ti.imwrite(screen.to_numpy(), './outputs/cvt_output.png')
i want use the param of screen
in my programs,but it isn't be allowed,What fields should I add?
@luelueluelueluelueluelue Have you tried the way Yuanming Hu suggested?
import taichi as ti ti.init(arch=ti.gpu) w = 512 h = 512 screen = ti.Vector(3,dt=ti.f32,shape=(w, h))
报错TypeError: Matrix.init() got an unexpected keyword argument 'shape' 求解哇,蟹蟹蟹蟹