question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trimesh aggregation approach

See original GitHub issue

This issue proposes a methodology for how the “aggregation” feature could work, in the context of triangle mesh rasterization (as of PR #525, the agg keyword-argument to Canvas.trimesh()).

Background

While rasterizing a mesh, we interpolate the value of each pixel based on its position in each triangle, along with the “weight” (e.g. elevation) at each vertex. In this way, each pixel can be assigned a “sample” which serves as an approximation for what the measurement is likely to have been between three measured (vertex) locations. When the user zooms out of an image, some triangles may become too small to see - smaller than a pixel, for example. Although we can’t see them, however, their values should somehow still contribute to the pixel coloring. This is where the concept of “aggregation” comes in: when downsampling the image, we must decide how the “unseen measurements” get incorporated into each pixel’s final value, which ultimately determines the color during shading.

Aggregation methodology

Conceptually, datashader treats a triangle mesh as a continuous function: given a location - and perhaps sometime soon, a moment in time - as input, the function yields a single-valued output. For example, in the context of a digital elevation model, the function’s output represents the elevation at a particular location. “Aggregation” is analogous to taking a sliding calculation over this function; a “sum” aggregation is akin to taking the integral. However, when it comes to deciding on which values we should aggregate, we have a decision to make. Below I’ve attempted to illustrate this in a way that is easy to visualize:

number line data

Here every blue dot represents a measurement sample, and each integer between two ticks represents a “bin” (pixel). Each blue dot is connected by a line, representing the interpolation between measurements. If we are to decide what a “minimum” aggregation should look like, there are two obvious ways that we can choose: either we can select among only the measured values in a bin, or we can select among any of the measured values and interpolated values of the bin:

“min” aggregation, by only the measured values: min_agg_0

In the above approach, we’re technically “more accurate” because the aggregations are based on the raw data, however there’s an ambiguity when it comes to bin 2, where there is no data available: do we introduce a “hole” in the mesh, or do we extend the previous value?

“min” aggregation, by both measured values, and interpolated values: min_agg_1

In the second approach, we’re coloring each pixel based on a linearly-interpolated value, potentially overriding the existing measurements in that bin. However, for a sufficiently-dense mesh, interpolated results will be very close to the actual measurements, with neighboring measurements being factored into the calculation. Also, there is no ambiguity in the cases of a lack of measured data available. For these reasons, this second approach is the one I intend to implement - barring any unforeseen complications, or more logical approaches, of course.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jbednarcommented, Dec 1, 2017

I think this captures the results of our discussion, thanks!

0reactions
apiszczcommented, Dec 1, 2017

Understand, thank you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trimesh aggregation approach · Issue #533 · holoviz/datashader
This issue proposes a methodology for how the "aggregation" feature could work, in the context of triangle mesh rasterization (as of PR #525 ......
Read more >
Trimesh — Datashader v0.14.3
Aggregation functions#. Like other datashader methods, the trimesh() method accepts an agg argument (defaulting to mean() ) for a reduction function that ...
Read more >
trimesh 3.17.1 documentation
Computes stable orientations of a mesh and their quasi-static probabilities. This method samples the location of the center of mass from a multivariate...
Read more >
https://raw.githubusercontent.com/holoviz/datashad...
n", "\n", "The specific algorithm used to do so is based on the approach of ... trimesh aggregation with Dask\n", "The trimesh aggregation...
Read more >
Plyable: A Python Mesh Manipulation Library - Squarespace
Code for makeFaceGrid. The vertex and face lists (both 2D NumPy arrays) are passed to the Trimesh.trimesh method to create a new mesh....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found