kylebarron / pydelatin

Python bindings to `hmm` for fast terrain mesh generation
https://kylebarron.dev/quantized-mesh-encoder
MIT License
64 stars 6 forks source link

test data mapbox_st_helens.png and terrarium.png result is not expected #33

Open sugizo opened 2 months ago

sugizo commented 2 months ago

env google colab

steps

pip install -U pydelatin meshio
!wget -c https://raw.githubusercontent.com/kylebarron/pymartini/master/test/data/mapbox_st_helens.png
!wget -c https://raw.githubusercontent.com/kylebarron/pymartini/master/test/data/terrarium.png

code

import imageio.v2 as imageio
import meshio
from pydelatin import Delatin
from pydelatin.util import decode_ele, rescale_positions

path = './terrarium.png'
terrarium = imageio.imread(path)
terrain = decode_ele(terrarium, 'mapbox')
tin = Delatin(terrain, max_error = 30)
vertices, triangles = tin.vertices, tin.triangles
cells = [("triangle", triangles) ]
mesh = meshio.Mesh(vertices, cells)
mesh.write('terrarium.stl')

result Screenshot 2024-05-10 095505 Screenshot 2024-05-10 095533

expected result elevation is show accurately like mt_fuji.png in your github test data image

best regards

kylebarron commented 2 months ago
terrain = decode_ele(terrarium, 'mapbox')

Well this is wrong. You're decoding a terrarium-encoded file as if it were encoded with mapbox encoding

sugizo commented 2 months ago

terrarium.png result is expected when set decode to terrarrium

first post st_helens is decode using 'mapbox'

this are try to decode st_helens using 'terrarium'

image

still not expected for st_helens.png

best regards

kylebarron commented 2 months ago

The St Helens file came from Mapbox, and so that should be loaded with "mapbox" decoding.

From your screenshot, the mesh from St Helens looks flat. You should be able to easily get the elevations of each vertex in the mesh and use numpy to get min/max values. Can you do that and verify that those min/max values are in the range of Mt. St. Helens?

I would not be surprised if the error is in the conversion to meshio, not in my code. I never had an issue like this with pydelatin or with pymartini in production.

sugizo commented 2 months ago

how to get the elevations of each vertex in the mesh and use numpy to get min/max values ?

thanks and best regards