-2

I have x,y,z 3D points in the array size of N x 3 dimensions. As they are scattered data points, I need to match into equally spaced grid data. The implementation in Matlab used TriScatteredInterp as shown in the link. I need to implement it in C++ and plot the data and save as png file. So I searched and found out that I should implement in PCL library. As I am not familiar with PCL, how can I approach that problem using PCL? Can I have any sample program? Thanks

batuman
  • 7,066
  • 26
  • 107
  • 229
  • Have you looked for [implementations](https://github.com/Itseez/opencv/blob/master/samples/cpp/delaunay2.cpp) of the [Delaunay triangulation in c++](http://stackoverflow.com/questions/1446987/lightweight-delaunay-trianguation-library-for-c)? – Schorsch Sep 05 '13 at 13:52
  • Delaunay triangulation I know. How to do interpolation. – batuman Sep 06 '13 at 00:22

2 Answers2

1

I don't understand your exact needs for the equaly spaced grid data. When looking at the matlab function I believe you would like to do the following:

1) Perform surface reconstruction on the scattered data points
In PCL you should be able to do this according to example: Greedy Triangulation tutorial

2) Show the surface in a viewer
This step could be realized by using the VTK viewer. An example is shonw in: VTK mesh viewing

3) Save the image of the viewer as a PNG file.
The last step could be realized using the VTKviewer also. An example can be found: VTKviewer save as PNG example

Deepfreeze
  • 1,755
  • 1
  • 13
  • 18
0

Now I understand how TriScatteredInterp works in Matlab.

We have x,y,z points for N X 3 dimensions. All these points, we need to implement Delaunay triangles in C++. That is easy.

Then, for all your desired grid points x', y', please search the triangle in which your x',y' is located. Then do Barycentric interpolation in a triangle as shown in the link. You will get z' for these x',y'.

That is all what we need to do in C++ for TriScatteredInterp.

You will get a matrix of x',y',z', then I follow @Deepfreeze's idea for plotting using PCL. We can also use OpenGl for plotting.

It doesn't stop at Delaunay triangulation, still need to do interpolation.

Brad Larson
  • 170,088
  • 45
  • 397
  • 571
batuman
  • 7,066
  • 26
  • 107
  • 229