diff --git a/qim3d/features/_common_features_methods.py b/qim3d/features/_common_features_methods.py index b90f0018c34a297e5ed4f124dbde8c586a558c67..b448b1d300b4985231262b0428eee158611cd453 100644 --- a/qim3d/features/_common_features_methods.py +++ b/qim3d/features/_common_features_methods.py @@ -27,8 +27,8 @@ def volume(obj: np.ndarray|trimesh.Trimesh, mesh = qim3d.io.load_mesh('path/to/mesh.obj') # Compute the volume of the mesh - volume = qim3d.features.volume(mesh) - print('Volume:', volume) + vol = qim3d.features.volume(mesh) + print('Volume:', vol) ``` Compute volume from a np.ndarray: @@ -37,9 +37,11 @@ def volume(obj: np.ndarray|trimesh.Trimesh, # Generate a 3D blob synthetic_blob = qim3d.generate.noise_object(noise_scale = 0.015) + synthetic_blob = qim3d.generate.noise_object(noise_scale = 0.015) # Compute the volume of the blob volume = qim3d.features.volume(synthetic_blob, level=0.5) + volume = qim3d.features.volume(synthetic_blob, level=0.5) print('Volume:', volume) ``` @@ -74,6 +76,7 @@ def area(obj: np.ndarray|trimesh.Trimesh, # Compute the surface area of the mesh area = qim3d.features.area(mesh) + area = qim3d.features.area(mesh) print(f"Area: {area}") ``` @@ -83,15 +86,18 @@ def area(obj: np.ndarray|trimesh.Trimesh, # Generate a 3D blob synthetic_blob = qim3d.generate.noise_object(noise_scale = 0.015) + synthetic_blob = qim3d.generate.noise_object(noise_scale = 0.015) # Compute the surface area of the blob volume = qim3d.features.area(synthetic_blob, level=0.5) + volume = qim3d.features.area(synthetic_blob, level=0.5) print('Area:', volume) ``` """ if isinstance(obj, np.ndarray): log.info("Converting volume to mesh.") obj = qim3d.mesh.from_volume(obj, **mesh_kwargs) + obj = qim3d.mesh.from_volume(obj, **mesh_kwargs) return obj.area @@ -123,6 +129,7 @@ def sphericity(obj: np.ndarray|trimesh.Trimesh, # Compute the sphericity of the mesh sphericity = qim3d.features.sphericity(mesh) + sphericity = qim3d.features.sphericity(mesh) ``` Compute sphericity from a np.ndarray: @@ -131,9 +138,11 @@ def sphericity(obj: np.ndarray|trimesh.Trimesh, # Generate a 3D blob synthetic_blob = qim3d.generate.noise_object(noise_scale = 0.015) + synthetic_blob = qim3d.generate.noise_object(noise_scale = 0.015) # Compute the sphericity of the blob sphericity = qim3d.features.sphericity(synthetic_blob, level=0.5) + sphericity = qim3d.features.sphericity(synthetic_blob, level=0.5) ``` !!! info "Limitations due to pixelation" @@ -144,9 +153,12 @@ def sphericity(obj: np.ndarray|trimesh.Trimesh, if isinstance(obj, np.ndarray): log.info("Converting volume to mesh.") obj = qim3d.mesh.from_volume(obj, **mesh_kwargs) + obj = qim3d.mesh.from_volume(obj, **mesh_kwargs) volume = qim3d.features.volume(obj) area = qim3d.features.area(obj) + volume = qim3d.features.volume(obj) + area = qim3d.features.area(obj) if area == 0: log.warning("Surface area is zero, sphericity is undefined.")