I have a 3D model as mesh structure or in .stl/.obj format which I converted to voxels using binvox voxelization tool. Using a Java program, I have done some processing on the voxel grid thus obtained. Now, I wish to covert this voxelized model back into a "smooth" mesh structure (or any other format), which can later be exported to .stl or .obj format.
Can someone suggest how can I achieve the last part, i.e. converting the voxel grid into some format for retrieving back the "smooth" surfaces ? Any help, including pointing to existing tools, or relevant theory in this direction will be appreciated.
Give a try to Marching Cubes algorithm. See http://paulbourke.net/geometry/polygonise/ for more details.
Related
how to convert the image into object file like as .obj or .ply . I need some code written in visualization toolkit and c++.
Thanks
Image data is pixel data and .obj/ .ply or for that matter .stl is 3D geometry data with Point and Cell (for .obj Cell is Triangle) information.
Your question is not clear, but to give you some steps -
First, you need to identify how would you convert the pixels into points? vtkImageDataGeometryFilter might be of help here. Although it might not be sufficient as you will also need triangles data.
Once you get vtkPolyData from image data, you can write this data to STL or OBJ or PLY format. You can use following VTK classes for that
vtkSTLWriter, vtkOBJWriter and vtkPLYWriter.
I am learning to manipulate a model in Assimp in Visual Studio Express 2019 . So I load a model and it has 0 animations. And I want to apply some transformation to its bone maybe hand and see its effect in the obj format I export. Now to see the effect in obj format I have to apply changes to its vertices, so I have to apply transformation in bone hierarchically. But I don't get the idea , how to implement all this.
I have seen oglDev tutorial 38 but can't understand it. So any help will be appreciated.
Here are the thinks I need help in->
1. How to apply some transformation to a bone and to all its child (consider a simple human model).
2. How to get the final location of vertex affected by the particular bone as for bone we have just transformation matrices , so how do I convert them to X,Y,Z coordinate to tell vertex position .
I am not using OpenGL.
I want to use simple C++ code in Assimp for all this.
Please refer here for additional progress and difficulties details :
Wrong Bone Rotation in Assimp
.obj format does not have support for skeletal animation (or any form of animation). You cannot rotate the bones that do not exist. You need to use a model format that supports skeletal animation and use a model that contains that data. Example formats include .fbx, .gltf, .dae (COLLADA).
I converted nifti file to vtk using python-implemented vtk. The main function was vtkMarchingCubes.
contour=vtk.vtkMarchingCubes()
The result vtk meshes have proper shape but their locations seem changed.
For example, when I load them with the pial surface made from exactly the same nifti image using different pipelines (freesurfer) in the same scene, the result is like below.
Does vtk converting of nifti changes the coordinate of vertices or somehow 'reset' them?
VTK's MarchingCubes filter should produce triangles in the same coordinate system as the volume. The only issue is that the Nifti image also includes a coordinate system of the image, and VTK is probably not correctly using it. I'd guess there's a transform in the Nifti that VTK isn't properly using.
Try using either Slicer (slicer.org) or ITK-Snap (itksnap.org). They do better at maintaining coordinate systems for medical images.
Yes, VTK changes the coordinate when read nifti.
-get Q-matrix using GetQFormMatrix()
-transform coordinate using vtkTransform()
is reqiured.
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
I would like to do some odd geometric/odd shape recognition. But I'm not sure how to do it.
Here's what I have so far:
Convert RGB image to Monochrome.
Otsu Threshold
Hough Transform.
I'm not sure what to do next.
For geometric information, you could do a raster to vector conversion to convert your image into coordinated vectors (lines and points) and finite element analysis to look for known shapes. Not easy but libraries should be available for both.
Edit: Note that there are sometimes easier practical solutions, but they depend on the image and types of errors. For example, removing perspective, identifying a 3d object from a 2d image, significance of colour, etc... You often see registration markers added to the real world object to overcome
this and allow much easier identification. Looking up articles on feature extraction techniques might help.