Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/HEAD'
Browse files Browse the repository at this point in the history
  • Loading branch information
chunibyo-wly committed Sep 25, 2024
2 parents fc11f9e + cbf3c7d commit 21697b3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
29 changes: 18 additions & 11 deletions A_preprocess.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import csv
from flask.cli import F
#from flask.cli import F
import numpy as np
import open3d as o3d
from tqdm import tqdm
Expand All @@ -13,7 +13,6 @@ def interpolate_color(value, low, high, color1, color2):
b = int(color1[2] + ratio * (color2[2] - color1[2]))
return r, g, b


def intensity_to_rgb(intensity):
"""Map normalized intensity to an RGB color based on the gradient."""
if intensity <= 0.333:
Expand Down Expand Up @@ -42,26 +41,34 @@ def process_csv_to_ply(csv_filename, ply_filename):
points.append((x, y, z))
intensities.append(intensity)

# Normalize intensity values to the range [0, 1]
min_intensity = min(intensities)
max_intensity = max(intensities)

points = np.array(points)
intensities = (
((np.array(intensities) - min_intensity) / (max_intensity - min_intensity))

# Deal with values equaling 0
intensities = np.array(intensities) + 1e-10

# Apply log_transformed
log_transformed = np.log(intensities)

# Normalize intensity values to the range [0, 1]
min_intensity = min(log_transformed)
max_intensity = max(log_transformed)
log_transformed = (
((np.array(log_transformed) - min_intensity) / (max_intensity - min_intensity))
.reshape(-1, 1)
.repeat(3, axis=1)
)

pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(points)
pcd.colors = o3d.utility.Vector3dVector(intensities)
pcd.colors = o3d.utility.Vector3dVector(log_transformed)
o3d.io.write_point_cloud(
ply_filename, pcd.voxel_down_sample(voxel_size=0.006), write_ascii=False
)


# Example usage:
'''
process_csv_to_ply("data/01_column.csv", "data/01_column.ply")
process_csv_to_ply("data/02_ground.csv", "data/02_ground.ply")
process_csv_to_ply("data/03_ground.csv", "data/03_ground.ply")
process_csv_to_ply("data/03_ground.csv", "data/03_ground.ply")
'''
process_csv_to_ply("public/data/04_groundKB526.csv", "public/data/04_groundKB526.ply")
Binary file added public/data/04_groundKB526.ply
Binary file not shown.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const guiMode = gui
}
});
const guiItem = gui
.add(guiHelper, "name", ["01_column", "02_ground", "03_ground"])
.add(guiHelper, "name", ["01_column", "02_ground", "03_ground", "04_groundKB526"])
.name("GPR Example")
.onChange((value) => load(value));
let folderArray = [];
Expand Down

0 comments on commit 21697b3

Please sign in to comment.