3D point to UnstructuredGrid - point

Can we obtain an UnstructuredGrid from 3D point array with values that exceed a threshold? I want to apply mesh to 3D point array. Is it possible? What kind of filters/functions do we need to do this process?
Best regards.

Related

VTK - create 3D model

I'm trying to create a 3D mask model from the 3D coordinate points that are stored in the txt file. I use the Marching cubes algorithm. It looks like it´s not able to link individual points, and therefore holes are created in the model.
Steps: (by https://lorensen.github.io/VTKExamples/site/Cxx/Modelling/MarchingCubes/)
First, load 3D points from file as vtkPolyData.
Then, use vtkVoxelModeller
Put voxelModeller output to MC algorithm and finally visualize
visualization
Any ideas?
Thanks
The example takes a spherical mesh (a.k.a. a set of triangles forming a sealed 3D shape), converts it to a voxel representation (a 3D image where the voxels outside the mesh are black and those inside are not) then converts it back to a mesh using Marching Cubes algorithm. In practice the input and output of the example are very similar meshes.
In your case, you load the points and try to create a voxel representation of them. The problem is that your set of points is not sufficient to define a volume, they are not a sealed mesh, just a list of points.
In order to replicate the example you should do the following:
1) building a 3D mesh from your points (you gave no information of what the points are/represent so I can't help you much with this task). In other words you need to tell how these points are connected between then to form a 3D shape (vtkPolyData). VTK can't guess how your points are connected, you have to tell it.
2) once you have a mesh, if you need a voxel representation (vtkImageData) of it you can use vtkVoxelModeller or vtkImplicitModeller. At this point you can use vtk filters that need a vtkImageData as input.
3) finally in order to convert voxels back to a mesh (vtkPolyData) you can use vtkMarchingCubes (or better vtkFlyingEdges3D that is a very similar algorithm but much faster).
Edit:
It is not clear what the shape you want should be, but you can try to use vtkImageOpenClose3D so the steps are:
First, load 3D points from file as vtkPolyData.
Then, use vtkVoxelModeller
Put voxelModeller output to vtkImageOpenClose3D algorithm, then vtkImageOpenClose3D algorithm output to MC (change to vtkFlyingEdges3D) algorithm and finally visualize
Example for vtkImageOpenClose3D:
https://www.vtk.org/Wiki/VTK/Examples/Cxx/Images/ImageOpenClose3D

skimage project an image's 3D plane to fronto-parallel view

I'm working on implementing Akush Gupta's synthetic data generation dataset (http://www.robots.ox.ac.uk/~vgg/data/scenetext/gupta16.pdf). In his work. he used a convolutional neural network to extract a point cloud from a 2-dimensional scenery image, segmented the point clouds to isolate different planes, used RANSAC to fit a 3d plane to the point cloud segments, and then warped the pixels for the segment, given the 3D plane, to a fronto-parallel view.
I'm stuck in this last part- warping my extracted 3D plane to a fronto-parallel view. I have X, Y, and Z vectors as well as a normal vector. I'm thinking what I need to do is perform some type of perspective transform or rotation that would bring all the pixels on the plane to a complete 0 Z-axis while the X and Y would remain the same. I could be wrong about this, it's been a long time since I've had any formal training in geometry or linear algebra.
It looks like skimage's Perspective Transform requires me to know the dimensions of the final segment coordinates in 2d space. It looks like AffineTransform requires me to know the rotation. All I have at this point is my X,Y,Z and normal vector and the suspicion that I may know my destination plane by just setting the Z axis to all zeros. I'm not sure if my assumption is correct but I need to be able to warp all the pixels in the segment of interest to fronto-parallel, fit a bounding box, place text inside of it, then warp the final segment back to the original perspective in 3d space.
Any help with how to think about this or implement it would be massively useful.

Rendering 3D shapes on a voxel

I have a 3D shape (primitive shapes like cuboid, sphere, pyramid etc.). The shape is described by a set of necessary geometric parameters. For example, for a cube, I have information about the vertices, dimensions and orientation of the cube. Now, I have a voxel (kind of 3D grid of pixels). How can I determine which cells of the voxel needs to be filled and which will remain empty for "rendering" the cube in 3D?
Are there existing libraries for the same? Or, can someone point out the approach/algorithm that would help in this task? Also, what is this process exactly called, so that I can search on the Internet in the right direction?
It is called "Mesh to Voxel conversion" or "Mesh voxelization" or to be a bit more general "Volume Visualization".
If you are interested in math here is some good articles about it:
cs.swansea.ac.uk/~csmark/PDFS/cgfvoxel.pdf
Complete Polygonal Scene Voxelization
Ray Cast Methods

how can 3d shape data project onto your 2d screen in computer graphics?

So correct me if i'm wrong, but I think all elements in 3d graphics are meshes.
So the question is really, how do you take mesh data and create a 2d projection based on the mesh data, the camera location, rotations of camera & mesh, etc.
I realize this is fairly complicated and I would be satisfied by just knowing what the technical term for this is called so I may search and research it.
You can read about 3D projection on Wikipedia.

Rotation & OpenGL Matrices

I have a class that holds a 4x4 matrix for scaling and translations. How would I implement rotation methods to this class? And should I implement the rotation as a separate matrix?
You can multiply Your current matrix with a rotation matrix. Take a look at http://en.wikipedia.org/wiki/Rotation_matrix
There's a site which I use every time when I need to look up the details of a 3D transformation, called http://www.euclideanspace.com. The particular page on matrix rotations can be found here.
Edit: Rotation around a given axis, look at the axis & angle representation. This page also links to a description on how to translate one representation to another.
If you need to rotate around mutiple axes, simply multiply the corresponding matrices.
Answering the second half of the question, a single 4x4 matrix is perfectly capable of holding a scaling, a translation, and a rotation. So unless you've put special limitations on what sort of 4x4 matrices you can handle, a single 4x4 is a fine for what you want.
As for rotation about an arbitrary vector (as you are asking in comments), look at the "Rotation about an arbitrary vector" section in the Wikipedia article yabcok links to. You will want to extend that to a 4x4 matrix by padding it out with zeros except for the 4,4 (scaling) position, which should be one. Then use matrix multiplication with your scaling/translation 4x4 to generate a new 4x4 matrix.
You want to make sure you find a reference which talks about the right kind of matrix that's used for computer graphics (namely 3D homogeneous coordinates using a 4x4 transformation matrix for rotation/translation/skewing).
See a computer graphics "bible" such as Foley and Van Dam (pg. 213), or one of these:
The Mathematics of the 3D Rotation Matrix
Mathematics of 3D Graphics
MSDN 3D graphics tutorial
SIGGRAPH article about 3D rotation
other page from CProgramming.com
This page has quite a bit of useful information:
http://knol.google.com/k/matrices-for-3d-applications-translation-rotation

Resources