s194649 commited on
Commit
ea11ea1
·
1 Parent(s): 15045a2

outlier filtering

Browse files
Files changed (1) hide show
  1. inference.py +18 -0
inference.py CHANGED
@@ -11,6 +11,23 @@ import pandas as pd
11
  import plotly.express as px
12
  import matplotlib.pyplot as plt
13
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
  def map_image_range(depth, min_value, max_value):
16
  """
@@ -239,6 +256,7 @@ class DepthPredictor:
239
  points, _ = PCL(mask, depth)
240
  idxs = np.random.choice(len(points), int(n_samples))
241
  points = points[idxs]
 
242
  for point in points:
243
  cube = o3d.geometry.TriangleMesh.create_box(
244
  width=cube_size, height=cube_size, depth=cube_size
 
11
  import plotly.express as px
12
  import matplotlib.pyplot as plt
13
 
14
+ def remove_outliers(point_cloud, threshold=3.0):
15
+ # Calculate mean and standard deviation along each dimension
16
+ mean = np.mean(point_cloud, axis=0)
17
+ std = np.std(point_cloud, axis=0)
18
+
19
+ # Define lower and upper bounds for each dimension
20
+ lower_bounds = mean - threshold * std
21
+ upper_bounds = mean + threshold * std
22
+
23
+ # Create a boolean mask for points within the bounds
24
+ mask = np.all((point_cloud >= lower_bounds) & (point_cloud <= upper_bounds), axis=1)
25
+
26
+ # Filter out outlier points
27
+ filtered_point_cloud = point_cloud[mask]
28
+
29
+ return filtered_point_cloud
30
+
31
 
32
  def map_image_range(depth, min_value, max_value):
33
  """
 
256
  points, _ = PCL(mask, depth)
257
  idxs = np.random.choice(len(points), int(n_samples))
258
  points = points[idxs]
259
+ points = remove_outliers(points)
260
  for point in points:
261
  cube = o3d.geometry.TriangleMesh.create_box(
262
  width=cube_size, height=cube_size, depth=cube_size