Skip to content

Commit

Permalink
wrong package fix and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
meyerls committed Jul 11, 2023
1 parent eaa2088 commit 5c8e01e
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 28 deletions.
20 changes: 10 additions & 10 deletions example_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
down_sample=0.03)
lbc.extract_skeleton()
lbc.extract_topology()
#lbc.visualize()
lbc.visualize()
lbc.show_graph(lbc.skeleton_graph, fig_size=(30, 30))
lbc.show_graph(lbc.topology_graph)
lbc.export_results('./output')
# lbc.animate(init_rot=np.asarray([[1, 0, 0], [0, 0, 1], [0, 1, 0]]), steps=500, output='./output')
# lbc.animate_contracted_pcd(init_rot=np.asarray([[1, 0, 0], [0, 0, 1], [0, 1, 0]]), steps=300, output='./output')
#lbc.animate_topology(init_rot=np.asarray([[1, 0, 0], [0, 0, 1], [0, 1, 0]]), steps=300, output='./output')
lbc.animate(init_rot=np.asarray([[1, 0, 0], [0, 0, 1], [0, 1, 0]]), steps=500, output='./output_lbc')
#lbc.animate_contracted_pcd(init_rot=np.asarray([[1, 0, 0], [0, 0, 1], [0, 1, 0]]), steps=300, output='./output')
lbc.animate_topology(init_rot=np.asarray([[1, 0, 0], [0, 0, 1], [0, 1, 0]]), steps=300, output='./output')

# Semantic Laplacian-based Contraction
s_lbc = SLBC(point_cloud={'trunk': pcd_trunk, 'branches': pcd_branch},
Expand All @@ -35,10 +35,10 @@
down_sample=0.009)
s_lbc.extract_skeleton()
s_lbc.extract_topology()
#s_lbc.visualize()
s_lbc.show_graph(lbc.skeleton_graph, fig_size=(30, 30))
s_lbc.show_graph(lbc.topology_graph)
s_lbc.export_results('./output')
#s_lbc.animate(init_rot=np.asarray([[1, 0, 0], [0, 0, 1], [0, 1, 0]]), steps=500, output='./output')
s_lbc.visualize()
s_lbc.show_graph(s_lbc.skeleton_graph, fig_size=(30, 30))
s_lbc.show_graph(s_lbc.topology_graph)
s_lbc.export_results('./output_slbc')
s_lbc.animate(init_rot=np.asarray([[1, 0, 0], [0, 0, 1], [0, 1, 0]]), steps=500, output='./output')
#s_lbc.animate_contracted_pcd(init_rot=np.asarray([[1, 0, 0], [0, 0, 1], [0, 1, 0]]), steps=300, output='./output')
s_lbc.animate_topology(init_rot=np.asarray([[1, 0, 0], [0, 0, 1], [0, 1, 0]]), steps=300, output='./output')
s_lbc.animate_topology(init_rot=np.asarray([[1, 0, 0], [0, 0, 1], [0, 1, 0]]), steps=300, output='./output_slbc')
31 changes: 28 additions & 3 deletions pc_skeletor/laplacian.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ def __init__(self,
algo_type: str,
point_cloud: Union[str, open3d.geometry.PointCloud, dict],
init_contraction: int,
init_attraction: int,
max_contraction: int,
init_attraction: float,
max_contraction: float,
max_attraction: int,
step_wise_contraction_amplification: Union[float, str],
termination_ratio: float,
Expand Down Expand Up @@ -364,6 +364,18 @@ def __init__(self,
o3d.visualization.draw_geometries([pcd], window_name="Default Point Cloud")

def __least_squares_sparse(self, pcd_points, L, laplacian_weighting, positional_weighting):
"""
Perform least squares sparse solving for the Laplacian-based contraction.
Args:
pcd_points: The input point cloud points.
L: The Laplacian matrix.
laplacian_weighting: The Laplacian weighting matrix.
positional_weighting: The positional weighting matrix.
Returns:
The contracted point cloud.
"""
# Define Weights
WL = sparse.diags(laplacian_weighting) # I * laplacian_weighting
WH = sparse.diags(positional_weighting)
Expand Down Expand Up @@ -414,7 +426,7 @@ class SLBC(LaplacianBasedContractionBase):
Our semantic skeletonization algorithm based on Laplacian-Based Contraction.
Paper: tbd
Paper: https://arxiv.org/abs/2304.04708
"""

Expand Down Expand Up @@ -464,6 +476,18 @@ def __init__(self,
o3d.visualization.draw_geometries([self.pcd], window_name="Default Point Cloud")

def __least_squares_sparse(self, pcd_points, L, laplacian_weighting, positional_weighting):
"""
Perform least squares sparse solving for the Semantic Laplacian-Based Contraction (S-LBC).
Args:
pcd_points: The input point cloud points.
L: The Laplacian matrix.
laplacian_weighting: The Laplacian weighting matrix.
positional_weighting: The positional weighting matrix.
Returns:
The contracted point cloud.
"""
# Define Weights
WL = sparse.diags(laplacian_weighting) # I * laplacian_weighting
WH = sparse.diags(positional_weighting)
Expand All @@ -484,6 +508,7 @@ def __least_squares_sparse(self, pcd_points, L, laplacian_weighting, positional_
num_valid = np.arange(0, pcd_points.shape[0])[mask]
S[rows, cols] = 1

# ToDo: Speed up!
for i in num_valid:
S[i, L[i].nonzero()[1]] = multiplier

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ matplotlib
open3d==0.16
tqdm
imageio
networkx==2.8.8
networkx==2.6.3
charset-normalizer
#mistree==1.2.1
pytest
Expand Down
14 changes: 0 additions & 14 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,3 @@
],
zip_safe=False,
)

#[
# 'mistree @ git+https://github.com/meyerls/mistree.git',# "mistree==1.2.1",
# "numpy",
# "scipy",
# "matplotlib",
# "open3d==0.16",
# "robust_laplacian==0.2.4",
# "dgl",
# "torch",
# "tqdm",
# "imageio",
# "wget",
# "networkx==2.8.8"],

0 comments on commit 5c8e01e

Please sign in to comment.