I want to do something similar to:3D terrain visualization with python and Mayavi2
As input I have an image (map) with a defined width and height in pixel. For this image / map I get the digital elevation model of the surface the image / map represents (extent). The extent consists of the min / max longitude and latitude values. For the elevation model I interpolate a grid with the same amount of values as the pixel of the image.
im # PIL Image object
pixel_x, pixel_y = im.size
ext = [lon_min, lon_max, lat_min, lat_max]
xstep = float(ext[1] - ext[0]) / float(pixel_x)
ystep = float(ext[3] - ext[2]) / float(pixel_y)
X, Y = np.mgrid[ext[0]:ext[1]:xstep,ext[2]:ext[3]:ystep]
Z = griddata(coords, elevations, (X, Y), method='cubic', fill_value=-1)
From the X,Y,Z I plot the surface
surf = mlab.surf(X,Y,Z, color=(1.0,1.0,1.0))
Now I want to overlay the image over the surface:
img = image_from_array(np.array(im))
texture_img = tvtk.Texture(interpolate = 1)
texture_img.input = img
surf.actor.enable_texture = True
surf.actor.tcoord_generator_mode = 'plane'
surf.actor.actor.texture = texture_img
This gives me a result as in

At the border the texture is repeated and not stretched over the whole surface area (as I would like). I would like to achieve that no pixel of the image is "repeated".
What can I do to prevent that the texture "overlaps" at the border?
I tried to normalize the X and Y values to be between 0 and 1, but this did not help.
来源:https://stackoverflow.com/questions/24107084/mayavi-texture-to-span-over-full-surface