Angus McMorland | 5 Sep 22:39
Picon

[mv2] Just display image with its LUT

Hi mv devs / vtk gurus,

I'm trying to add an image to an mv2 scene, including its colourmap. A while back, Prabhu sent me this script to do that _and_ warp the image on to some arbitrary bump map, but I can't work out which bits of this are needed to just display a flat image, with its colours. Can someone point me in the correct direction please.

def render_img():
    r = tvtk.JPEGReader(file_name=img.jpg')
    r.update()
    img = r.output
    depth = np.asarray(Image.open('other_img.png'))
    scalar = np.ravel(depth)
    # print scalar.shape
    da = tvtk.DoubleArray()
    da.name = 'bump'
    da.from_array(scalar)
    img.point_data.add_array(da)
    pd = convert_to_poly_data(img)
    ws = tvtk.WarpScalar()
    ws.input = pd
    ws.set_input_array_to_process(0, 0, 0, 0, 'bump')
    ws.scale_factor = 0.2
    ws.update()
    o = ws.output
    d = VTKDataSource(data=o)
    s0 = Surface()
    d.add_child(s0)
    fig = mlab.figure()
    fig.add_child(d)

An alternative solution would be if I could do mlab.imshow on a 2D array and then assign it an LUT in the module manager, but that doesn't seem to be working. Is that expected?

Many thanks, as always,

Angus.
--
AJC McMorland
Post-doctoral research fellow
Neurobiology, University of Pittsburgh
_______________________________________________
Enthought-dev mailing list
Enthought-dev@...
https://mail.enthought.com/mailman/listinfo/enthought-dev

Gmane