如何将点云数据`(x,y,z)转换为深度图,其中`(x,y)`具有深度`z`?

发布于 2025-02-01 10:23:50 字数 337 浏览 4 评论 0原文

我以的形式获得了点云数据[(x,y,z),(norm_x,norm_y,norm_z)]在文本文件中。我正在尝试将其转换为PNG或JPG图像文件,其中任何点强度都对应于其深度(Z)

这是STL 3D文件的外观(左)。右边是我要制作的。

谢谢大家抽出宝贵的时间阅读此书。

I got point cloud data in the form of [(x, y, z) , (norm_x, norm_y, norm_z)] in a text file. I am trying to convert this into a png or jpg image file where any points intensity corresponds to its depth (z).

here is how an stl 3d file looks like (left). On the right is what i am trying to make.
enter image description here

Thank you all for taking time to read this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乄_柒ぐ汐 2025-02-08 10:23:50
x_min = -2
x_max = 2
y_min = -1
y_max = 1
z_min = 0
z_max = 1

dx = x_max - x_min
dy = y_max - y_min
dz = z_max - z_min

Ps = []
for (i = 0; i < 1000; ++i) Ps.push([x_min + Math.random()*dx, y_min + Math.random()*dy, z_min + Math.random()*dz])

width = canvas.width
height = canvas.height
context = canvas.getContext('2d')
context.setFillColor('#000000')
context.fillRect(0, 0, width, height)
imagedata = context.getImageData(0, 0, width, height)
data = imagedata.data
w = width - 1
h = height - 1
for (P of Ps) {
  col = Math.round(((P[0] - x_min)/dx)*w)
  row = Math.round(((y_max - P[1])/dy)*h)
  val = ((P[2] - z_min)/dz)*255
  i = 4*(width*row + col)
  if (data[i] < val) data[i] = data[i + 1] = data[i + 2] = val
}
context.putImageData(imagedata, 0, 0)
a.href = canvas.toDataURL()
<canvas id=canvas>HTML5</canvas><br><a id=a>Download</a>

x_min = -2
x_max = 2
y_min = -1
y_max = 1
z_min = 0
z_max = 1

dx = x_max - x_min
dy = y_max - y_min
dz = z_max - z_min

Ps = []
for (i = 0; i < 1000; ++i) Ps.push([x_min + Math.random()*dx, y_min + Math.random()*dy, z_min + Math.random()*dz])

width = canvas.width
height = canvas.height
context = canvas.getContext('2d')
context.setFillColor('#000000')
context.fillRect(0, 0, width, height)
imagedata = context.getImageData(0, 0, width, height)
data = imagedata.data
w = width - 1
h = height - 1
for (P of Ps) {
  col = Math.round(((P[0] - x_min)/dx)*w)
  row = Math.round(((y_max - P[1])/dy)*h)
  val = ((P[2] - z_min)/dz)*255
  i = 4*(width*row + col)
  if (data[i] < val) data[i] = data[i + 1] = data[i + 2] = val
}
context.putImageData(imagedata, 0, 0)
a.href = canvas.toDataURL()
<canvas id=canvas>HTML5</canvas><br><a id=a>Download</a>

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文