Skip to content
← All articles
Project introduction

TrueMapData: from measured height maps to usable assets

Listen to the audio story

From a measured surface to a usable asset · 2:05 · AI-written script, synthetic voices

Transcript

Ava: A scanner measures a tiny surface, and the result is a grid of heights. What do you do with that grid?

Andrew: Make a pretty picture?

Ava: That's one thing, but the post is about going further. TrueMapData is Antoine's Python library for reading captures from TrueMap and GelSight. It exposes the heights as NumPy arrays and gives you tools for analysis and graphics export.

Andrew: What's inside a capture file?

Ava: A header, spatial metadata, and the grid itself, stored as float32 samples. The metadata matters, because a game texture can stretch over any range, but a measured surface needs its sample spacing to keep its real physical scale.

Andrew: So size stays attached to the data.

Ava: Yes. And before exporting anything, he inspects the surface: a heatmap, a three-D view, profiles along a row or column, contours. Then you can derive a normal map for shading, a displacement map that carries height, or even a mesh in formats like STL, OBJ or glTF.

Andrew: And the scale still matters when you tile a texture on a mesh?

Ava: Right. The apply-on-mesh path uses the template's bounds, the millimeters-per-pixel value and the capture's dimensions to set the tiling, so the scan's size connects to the surface receiving it.

Andrew: Where does wear come in?

Ava: Roughness describes a surface at one moment, using ISO 25178 parameters through a separate package called Surfalize. Wear compares captures over time. Before subtracting heights, the frames must share the same grid and region, so the library aligns them first.

Andrew: How's loss defined?

Ava: Reference height minus current height. A positive loss means the current surface is lower. To get a physical volume, you also need the pixel spacing in both directions, and registration errors or mixed units would change the answer.

Andrew: So the figures in the post are examples, not thesis data.

Ava: Correct, they come from the repository README. The full write-up has the diagrams and commands.

TrueMapData: from measured height maps to usable assets
Surface visualization from the TrueMapData README. Heights are normalized in this example.
Table of contents

TrueMapData reads surface captures from TrueMap and GelSight, exposes their heights as NumPy arrays, and provides tools for analysis and graphics export. The same surface representation supports metrology work and assets such as displacement maps or meshes.

1. What a capture contains

A .tmd file contains a header, spatial metadata and a grid of heights. The library supports the legacy v1 format and the TrueMap v6-style v2 format. Both store float32 samples in row-major order: height_map[row, column], with shape (height, width). Scan lengths and offsets describe the capture’s physical extent.

That metadata matters when a grid leaves the file reader. A texture can stretch over any UV range; a measured surface needs its sample spacing to retain physical scale. The binary format guide[1] documents the byte layout and the reader’s checks for alternate v2 headers.

from tmd import TMD

capture = TMD.load("path/to/capture.tmd")
heights = capture.height_map
metadata = capture.metadata

The path above is a placeholder for a capture. The code reads the raster and metadata together.

2. Inspect the surface before exporting it

The visualization commands offer a 2D heatmap, a 3D surface, row and column profiles, contours, and comparisons between files. Matplotlib produces static plots; Plotly can save an interactive HTML view. Optional Polyscope support provides a 3D inspection window.

X profile from the TrueMapData README

A profile shows how height varies across one section of a surface. Source: TrueMapData README visual examples.

pip install "truemapdata[viz]"
tmd-process visualize basic path/to/capture.tmd
tmd-process visualize 3d path/to/capture.tmd --plotter plotly --output surface.html

I check the height field and its scale before choosing a derived map. A normal map describes local orientation for shading. A displacement map carries height information. Mesh export creates geometry in formats including STL, OBJ, PLY, glTF and USD, with the optional mesh dependencies installed.

flowchart TB
  Capture["TrueMap or GelSight capture"] --> Read["Height grid and spatial metadata"]
  Read --> Inspect["Heatmap, profile or 3D surface"]
  Inspect --> Metrics["Roughness and surface metrics"]
  Inspect --> Maps["Normal and displacement maps"]
  Inspect --> Mesh["Mesh export and template texturing"]

The apply-on-mesh path bundles derived textures with a template OBJ/MTL. It uses template bounds, mm_per_pixel and capture dimensions to set tiling. This connects the size of the scan to the surface receiving the texture.

3. Roughness and wear answer different questions

Roughness analysis describes a surface at a particular capture. The optional truemapdata[roughness] extra uses Surfalize for ISO 25178 areal parameters. Surfalize is GPL-3.0 and is installed separately from the MIT-licensed core package.

Wear analysis compares captures over time. Before subtracting heights, the frames need the same grid and the same in-plane region. The sequence guide[2] describes translation alignment and OpenCV/SIFT registration, including registration driven by normals.

The loss convention is reference height − current height. Positive loss means the current surface is lower than the reference. Computing a physical volume also needs the pixel spacing in both directions. Registration errors or inconsistent height units would change that result.

The tmd-wear commands cover volume series, scratch evolution, slip-axis heuristics and roughness trajectories. Those outputs complement the filters, defect detection, sequence export and compression tools in tmd-process.

4. Source and examples

The surface and profile figures here are original examples from the repository README, not measurements from my thesis. The surface figure uses normalized heights.

The TrueMapData project note links the repository and its code overview.

References

  1. ETSim. (). binary format guide. [Source file or documentation] github.com.
  2. ETSim. (). sequence guide. [Source file or documentation] github.com.
  3. ETSim. (). TrueMapData. [Software repository] github.com.
  4. Documentation. (). [Web page] etstribology.github.io.
  5. ETSim. (). Visualization guide. [Source file or documentation] github.com.

References use this article’s publication date.