我想做类似的事情:使用 python 和 Mayavi2 进行 3D 地形可视化
作为输入,我有一个图像(地图),其宽度和高度以像素为单位定义。对于此图像/地图,我获得了图像/地图所代表的表面(范围)的数字高程模型。范围由最小/最大经度和纬度值组成。对于高程模型,我使用与图像像素相同数量的值插入网格。
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)
从 X、Y、Z 绘制曲面
surf = mlab.surf(X,Y,Z, color=(1.0,1.0,1.0))
现在我想将图像覆盖在表面上:
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 Here I used the matplotlib lena version: lena.png
在边界处,纹理是重复的,并且没有拉伸到整个表面区域(如我所愿)。我想实现图像的任何像素都不会“重复”。
我该如何防止纹理在边界处“重叠”?
我尝试将 X 和 Y 值标准化为 0 到 1 之间,但这没有帮助。