Comments (6)
Well I have not tested this but you can try with some specific configuration:
from vedo import *
vol1 = Box(size=(35,10, 5)).binarize()
vol2 = Box(size=( 5,10,35)).binarize()
vol = vol1.operation("and", vol2)
dx, dy, dz = vol.spacing() # voxel size
counts = np.unique(vol.pointdata[0], return_counts=True)
n0, n1 = counts[1]
vol_value = dx*dy*dz * n1
vol1.cmap('g')
vol2.cmap('r')
vol.cmap('m')
show(vol1, vol2, vol, f"volume = {vol_value}", axes=1).close()
from vedo.
You can automatize the radius value by histogramming the point relative distances, something like
from vedo import *
from vedo.pyplot import histogram
pcd1 = Points("pcd1.ply").color("blue5")
pcd2 = Points("pcd2.ply").color("red5")
dists1 = []
for p1 in pcd1.coordinates:
q1 = pcd1.closest_point(p1, n=2)[1]
dists1.append(mag(p1 - q1))
histo1 = histogram(dists1, bins=25).clone2d()
radius = histo1.mean * 10
tetm1 = pcd1.generate_delaunay3d(radius=radius)
surf1 = tetm1.tomesh().compute_normals()
surf1.color("blue5").alpha(0.1)
tetm2 = pcd2.generate_delaunay3d(radius=radius)
surf2 = tetm2.tomesh().compute_normals()
surf2.color("red5").alpha(0.1)
s12 = surf1.boolean("intersect", surf2)
s12.color("green5").lw(1)
print(s12.volume())
show(pcd1, pcd2, surf1, surf2, s12, histo1, axes=1)
from vedo.
Thanks @marcomusy, as always really helpful 👍
For the moment, it seems to do the job so I will be closing this issue.
from vedo.
Hi @marcomusy,
Lovely, this works fine. The point is now I want to apply this on two point clouds.
However, the issue that I face now is that when I try to extract the volume from the point clouds directly I get nothing. I tried the different parameters to the .tovolume()
function but it doesn't seem to give me something that I can use:
pcd1.tovolume(kernel='shepard', n=4)
<vedo.volume.Volume object at 0x7fc247ea2800>
pcd1.pointdata
Point Data is empty.
The same with pcd2. Then I tried first to make them as meshes by using the .reconstruct_surface()
method and use .binarize()
on them and then extract overlap but the reconstructed meshes are really bad.
Any idea how to handle this.
Thanks.
pcds.zip
from vedo.
Hi, what about this alternative solution
from vedo import *
pcd1 = Points("pcd1.ply").color("blue5")
pcd2 = Points("pcd2.ply").color("red5")
ug1 = pcd1.generate_delaunay3d(radius=0.01)
surf1 = ug1.tomesh().compute_normals()
surf1.color("blue5").alpha(0.1)
ug2 = pcd2.generate_delaunay3d(radius=0.01)
surf2 = ug2.tomesh().compute_normals()
surf2.color("red5").alpha(0.1)
s12 = surf1.boolean("intersect", surf2)
s12.color("green5").lw(1)
vol = s12.volume()
show(pcd1, pcd2, surf1, surf2, s12, f"volume = {vol}", axes=1)
PS : creating a volume from a pointcloud is not possible because there is no face normal which defines the "inside" from the "outside".
from vedo.
Using the meshes is good as alternative the only issue that I have though with this approach is that radius needs to change each time because I am loading different point clouds each time so using 0.01
as a fixed number it doesn't always work, e.g.:
that's why I wanted to go volumes instead.
Do you have any idea how I can dynamically specify the radius value for the triangulation, depending on the point cloud that I have each time... 🤔
from vedo.
Related Issues (20)
- Arrow object's top point HOT 2
- Group objects HOT 1
- Help ! Legosurface Error HOT 2
- version 2024.5.2 `show()` function returns error HOT 4
- quality and resolution of the video HOT 3
- Make load functions compatible with pathlib.Path HOT 1
- Creating a plot with objects out of scene, seems to break calls to render HOT 1
- Mesh.volume() and Mesh.is_closed() don't work with Boxes and Cylinders HOT 1
- compute_normals() unexpectedly changes the appearance of a Mesh HOT 2
- Cut volume with volume HOT 1
- seg fault on vertex normal and texture indices in obj format to off conversion HOT 2
- Issues with boolean operation HOT 4
- Touching objects handling in isosurface_discrete HOT 10
- Problems with boolean operations on concave polyhedrons HOT 4
- Problem with mesh formation
- mesh.cells datatype HOT 2
- Axes order of numpy array HOT 2
- computing volume of intersecting concave polyhedra HOT 1
- 2D images become non-pickable after changing cmap HOT 2
- Docs cannot be accessed due to certificate expiration HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vedo.