Effacer les filtres
Effacer les filtres

Changing color mapping when rotating a point cloud visualization

3 vues (au cours des 30 derniers jours)
Yar Pyae Aung
Yar Pyae Aung le 8 Juil 2023
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, :);

Réponses (1)

Diwakar Diwakar
Diwakar Diwakar le 8 Juil 2023
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');

Tags

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by