Linear Interpolation of Scattered 2D Data

2019-06-28 01:28发布

So I have some irregularly spaced data that I want to interpolate onto a regular grid. (I want to do exactly this but in Java) Here's a picture:

Scattered Data for Interpolation

Basically I have the x and y coordinates of each point and a z value associated with each point and I want to interpolate between them and fill in the center of my image.

What is the best way to do this using Java? Is there a built in 2D interpolation library I can use or should I try a "roll my own" approach?

This post and this one also seem to be trying to do about what I am but their answers don't quite apply.

Someone else with the same problem but no solution.

Note: I am using JavaFX-2 so if I could somehow use their Interpolator class that'd be great.

.
.
EDIT: If anyone stumbles upon this and wants to know what I ended up using, it was a Delaunay Triangulation implementation from BGU:
Main Site
Code API

1条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-06-28 02:04

If linear interpolation is sufficient, I suggest you to use a 3d mesh with Gouraud Shading for drawing:

  1. Convert the 2d point cloud to a mesh (you can google for existing algorithms)
  2. Mapping the z value of each point to the vertex' color
  3. Using Gouraud Shading to enable linear interpolation between the vertex colors
  4. Creating a camera on top to the mesh and using a othonormal projection (to avoid perspective)

You say that you can use JavaFX. JavaFX supports 3d scenes and you can build your own meshes. But looking into the JavaDoc of TriangleMesh, I can't find any method to set the vertex color I found only a method to set the (x,y,z) and (u,v) (texture coordinates) coordinates.

查看更多
登录 后发表回答