如何在大型点云中有效地将RGB值转换为HSV

2024-10-02 00:22:59 发布

您现在位置:Python中文网/ 问答频道 /正文

因此,我使用的点云结构如下:

cloud1 = PyntCloud.from_ply('/home/david/Escritorio/CloudCompareGarden1 - Cloud.ply')

cloud1.vertex
Out[3]: 
array([ (-3.6057682037353516, -0.18922901153564453, 150.49591064453125, 206, 205, 208, 2033.0),
       (-3.605868101119995, -0.18912899494171143, 150.4914093017578, 187, 186, 188, 2033.0),
       (-3.3447682857513428, -1.1726289987564087, 149.6341094970703, 115, 81, 65, 1313.0),
       ...,
       (-1.169768214225769, -0.8984289765357971, 147.5572967529297, 43, 22, 11, -1631.0),
       (-1.1530683040618896, -0.8945289850234985, 147.5579071044922, 46, 26, 19, -1375.0),
       (-1.151968240737915, -0.8948289752006531, 147.55889892578125, 52, 33, 27, -1055.0)], 
      dtype=[('x', '<f4'), ('y', '<f4'), ('z', '<f4'), ('red', 'u1'), ('green', 'u1'), ('blue', 'u1'), ('scalar_Scalar_field', '<f4')])

cloud1.vertex['red']
Out[4]: array([206, 187, 115, ...,  43,  46,  52], dtype=uint8)

我想把每个点的RGB值转换成HSV,然后将HSV值作为3个独立的标量字段“追加”到每个点。在

我已经尝试过colorsys模块和scikit-image color module。在

我以这个函数结束,wich有效:

^{pr2}$

结果:

cloud1.add_hsv()

cloud1.vertex
Out[6]: 
array([ (-3.6057682037353516, -0.18922901153564453, 150.49591064453125, 206, 205, 208, 2033.0, 0.7222222222222222, 0.014423076923076872, 0.8156862745098039),
       (-3.605868101119995, -0.18912899494171143, 150.4914093017578, 187, 186, 188, 2033.0, 0.7499999999999988, 0.010638297872340538, 0.7372549019607844),
       (-3.3447682857513428, -1.1726289987564087, 149.6341094970703, 115, 81, 65, 1313.0, 0.05333333333333332, 0.4347826086956522, 0.45098039215686275),
       ...,
       (-1.169768214225769, -0.8984289765357971, 147.5572967529297, 43, 22, 11, -1631.0, 0.057291666666666664, 0.7441860465116279, 0.16862745098039217),
       (-1.1530683040618896, -0.8945289850234985, 147.5579071044922, 46, 26, 19, -1375.0, 0.043209876543209874, 0.5869565217391305, 0.1803921568627451),
       (-1.151968240737915, -0.8948289752006531, 147.55889892578125, 52, 33, 27, -1055.0, 0.04000000000000002, 0.4807692307692308, 0.20392156862745098)], 
      dtype=[('x', '<f4'), ('y', '<f4'), ('z', '<f4'), ('red', 'u1'), ('green', 'u1'), ('blue', 'u1'), ('scalar_Scalar_field', '<f4'), ('Hue', '<f8'), ('Saturation', '<f8'), ('Value', '<f8')])

但我不喜欢这样一个事实:我必须生成一个'假'图像,以便能够使用skimage rgb2hsv function,然后撤销假图像。在

所以我的问题是:

  1. 考虑到我的数据结构,有没有一种方法可以更有效地使用skimage转换函数?在
  2. 有没有其他的RGB-HSV转换函数可以简化我的功能(保持我原来的PyntCloud结构)?在
  3. 我是否应该编写自己的RGB-HSV转换函数,优化以处理我的特定数据结构?在

非常感谢


Tags: 函数rgbredout结构arrayhsvvertex

热门问题