Interpolate value at x, y from a Delaunay2D in vtk python - python

I am using python vtk bindings.
I used vtkDelaunay2d() to generate a surface rendering for a terrain. My intention is to view the terrain from a certain position and looking towards a certain focal point. While the location and direction of the camera appear to be correct the elevation values(z) are off. I interpolated these from the original image containing elevation data instead of the delaunay surface. I am thinking that there is a disparity between the two so I am looking for how to interpolate this value directly from the delaunay surface. Is there a way to do this in vtk?

Related

Vertices with normals to simple mesh with faces

Similar to this question: Using just vertices to generate faces in PyMeshLab
I am looking for a function in either PyVista or PyMeshLab which constructs a mesh surface given vertices. However, my vertices already have normals. They were obtained with a laser scanner, so I used the estimate normals function in CloudCompare knowing the sensor locations that the points were obtained from. Therefore, all my point cloud normals are true surface normals. I want to preserve this information.
All I really need is to march through the cloud and connect the vertices with faces of their nearest neighbors. That is, I would like my point cloud to be the mesh vertices. No Delaunay triangulations or anything like that. No ball pivoting algorithm or Poisson reconstruction that skips over some points. My points are already subsampled and sparse.
Are there any functions that can do this? Maybe it is even easy to do manually.
Thank you.
For example, in this code, nbr_sz dictates the neighborhood of points to look around for estimating surface normals.
import pyvista as pv
bunny = pv.read("Stanford_Bunny.ply")
points = pv.wrap(bunny.points)
surf = points.reconstruct_surface(nbr_sz=10)
pl = pv.Plotter(shape=(1, 2))
pl.add_mesh(points)
pl.add_title("Point Cloud of 3D Surface")
pl.subplot(0, 1)
pl.add_mesh(surf, color=True, show_edges=True)
pl.add_title("Reconstructed Surface")
pl.show()
See https://docs.pyvista.org/api/core/_autosummary/pyvista.PolyDataFilters.reconstruct_surface.html#pyvista.PolyDataFilters.reconstruct_surface

Plot Arbitray Slice of 3d points in Python

So I am a bit new to python and having a little trouble.
I am attempting to plot (project) a 3d data set onto an arbitrary plane. I can of course plot xy etc. but since my data has a particular orientation (all the points fall into an arbitrary orientated cylinder) I want project all the points onto a plane that slices that cylinder orthogonally and that plane would have a arbitrary orientation.
I am working with microseismic data if anyone is familiar with that and all the points are located around a wellbore with follows an arbitrary but fairly straight azimuth.
The data is in Cartesian coordinates.

OpenCV Pose Estimation and projectPoints

I'm doing something similar to the tutorial here: http://docs.opencv.org/3.1.0/d7/d53/t... regarding pose estimation. Essentially, I'm creating an axis in the model coordinate system and using ProjectPoints, along with my rvecs, tvecs, and cameraMatrix, to project the axis onto the image plane.
In my case, I'm working in the world coordinate space, and I have an rvec and tvec telling me the pose of an object. I'm creating an axis using world coordinate points (which assumes the object wasn't rotated or translated at all), and then using projectPoints() to draw the axes the object in the image plane.
I was wondering if it is possible to eliminate the projection, and get the world coordinates of those axes once they've been rotated and translated. To test, I've done the rotation and translation on the axis points manually, and then use projectPoints to project them onto the image plane (passing identity matrix and zero matrix for rotation, translation respectively), but the results seem way off. How can I eliminate the projection step to just get the world coordinates of the axes, once they've been rotation and translated? Thanks!

plotting 2D slice of arbitrary orientation through 3D data in matplotlib

I have a 3D regular grid of data. I would like to write a routine allowing the user to specify a plane slicing through the data with arbitrary orientation and returning a contour plot of the data in the plane. Is there a ready-made way in matplotlib to do this? Could find anything in the docs.
You can use roll function of numpy to rotate your plane and make it parallel with a base plane. now you can choose your plane and plot. Only problem is that at close to edges the value from one side will be added to opposite side.

Perform spherical projection of image in python

I am writing a program using PyGTK that displays a gtk.Image. The desktop is projected onto the inside of a spherical dome. If the image displayed is rectangular on the screen, once projected onto a sphere it gets distorted.
To help picture this: The desktop itself is square. The center pixel of the desktop projects to the zenith and a circle inscribed inside the square desktop becomes the horizon (0 degrees elevation in polar coordinates). Everything outside that (in the corners of the desktop) is not displayed.
I would like to somehow modify the gtk.Image such that it still appears rectangular on the spherical surface. I'm sure there are lots of details in how this projection could be done, but very simplistically I have to convert the rectangular image into a curved trapezoid. Converting to a range of polar coordinates (e.g., map this rectangle to the area between two azimuth and two elevation angles) would be a good first approximation, though you can imagine if the elevation angles are 0 and 90, the resulting image will be a wedge of the sphere and not look rectangular at all.
How can I apply transformations like this to a gtk.Image (or its underlying Pixbuf)? Is there a package already that can do this? If not, how should I go about writing it from scratch? Presumably I would have to pull out the pixel values, map them to some new grid, and replace the original image. I just don't want to reinvent something that has already been done.

Categories

Resources