Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
SVivdich02 committed Feb 25, 2024
1 parent 968f361 commit 809773a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions src/services/distance/connected_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ def process(self, distance_matrix, points, trace):
break

not_visited_vertices = [
vertex for vertex, is_visited in enumerate(visited_vertices) if not is_visited
vertex
for vertex, is_visited in enumerate(visited_vertices)
if not is_visited
]

#Visualization of the extracted connectivity component against the background of the entire cloud
# Visualization of the extracted connectivity component against the background of the entire cloud
visualize_pcd(color_pcd_by_two_groups(points, not_visited_vertices))

trace_copy = copy.deepcopy(trace)
Expand Down
8 changes: 6 additions & 2 deletions src/services/distance/isolated.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ class RemovingIsolatedPointsProcessor:
def process(self, distance_matrix, points, trace):
"""Removing isolated points that have all 0s in the distance matrix except the diagonal element"""

mask_isolated = np.all(distance_matrix - np.eye(distance_matrix.shape[0]) == 0, axis=1)
mask_isolated = np.all(
distance_matrix - np.eye(distance_matrix.shape[0]) == 0, axis=1
)
isolated_points = np.array([i for i in range(len(points))], dtype=int)[
mask_isolated
]
Expand All @@ -33,7 +35,9 @@ def process(self, distance_matrix, points, trace):
for index in sorted(isolated_points, reverse=True):
del trace_copy[index]

mask_not_isolated = np.any(distance_matrix - np.eye(distance_matrix.shape[0]) != 0, axis=1)
mask_not_isolated = np.any(
distance_matrix - np.eye(distance_matrix.shape[0]) != 0, axis=1
)

return (
distance_matrix[mask_not_isolated][:, mask_not_isolated],
Expand Down
4 changes: 1 addition & 3 deletions src/utils/pcd_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ def color_pcd_by_two_groups(points, indices):

pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(np.asarray(points))
pcd.colors = o3d.utility.Vector3dVector(
np.zeros(np.asarray(pcd.points).shape)
)
pcd.colors = o3d.utility.Vector3dVector(np.zeros(np.asarray(pcd.points).shape))

colors = generate_random_colors(2)
for i in range(len(pcd.points)):
Expand Down

0 comments on commit 809773a

Please sign in to comment.