Changing color mapping when rotating a point cloud visualization

5 次查看(过去 30 天)
Hi.
I am facing an issue of the changing color mapping when rotating a point cloud visualization in MATLAB. The below codes are a part of my system, which is showing the color maping for visualization. Please help me how to fix this one.
numLevels = 5;
cmap = jet(numLevels);
normalizedY = (distance-min(distance)) / (max(distance)-min(distance));
colorIndices = ceil(numLevels * normalizedY);
colorIndices(colorIndices < 1) = 1;
colorIndices(colorIndices > numLevels) = numLevels;
colors = cmap(colorIndices, :);

回答(1 个)

Diwakar Diwakar
Diwakar Diwakar 2023-7-8
The issue you're facing with changing color mapping when rotating a point cloud visualization in MATLAB is likely due to the fact that the color mapping is based on the distance values, which may change as the point cloud rotates. This can cause the colors to appear different or inconsistent.
To address this issue, you can consider mapping the colors directly to the point cloud vertices instead of relying on the distance values. This way, the colors will remain fixed to the vertices regardless of their position or orientation.
May be this code will help you:
numLevels = 5;
cmap = jet(numLevels);
normalizedY = (distance - min(distance)) / (max(distance) - min(distance));
colorIndices = ceil(numLevels * normalizedY);
colorIndices(colorIndices < 1) = 1;
colorIndices(colorIndices > numLevels) = numLevels;
colors = cmap(colorIndices, :);
% Assuming you have a point cloud represented by vertices
% Assign colors to the vertices
verticesColor = colors;
% Plot the point cloud with colored vertices
scatter3(vertices(:, 1), vertices(:, 2), vertices(:, 3), 10, verticesColor, 'filled');

类别

Help CenterFile Exchange 中查找有关 Point Cloud Processing 的更多信息

标签

产品


版本

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by