基于坐标值的点云颜色映射

时间:2016-08-01 09:56:14

标签: matlab interpolation point-clouds colormap

我脸上有一个点云,我的脸部厚度为17点。根据在17点定义的厚度,我需要计算其他点的厚度,并根据厚度得到颜色图。我尝试了不同的方法,但由于我是MATLAB的初学者,因此我失败了。请建议我解决这个问题。

clc;
close all;
fid = fopen('cloud.txt');
pointArray = textscan(fid,'%f');
coord = reshape(pointArray{1}, 3 ,size( pointArray{1}, 1 ) / 3);
%% The fourth column of scalars_erect represent the thickness where as the initial 3 colunms are the coordinates of points on the face.
scalars_erect=[-10.81   -70.79  25.95   3.769230769
    -8.97   -61.18  -49.4   9.307692308
    -7.87   -60.07  -96.19  3.076923077
    -70.3   -45.23  -5.278  5.846153846
    -59.93  -56.14  -40.77  10
    -47.51  -63.61  -46.13  7
    -42.78  -64.82  -50.99  4
    -45.1   -51.71  -81.41  1
    -58.19  -47.7   -69.69  4.692307692
    -75.71  -29.2   -54.05  5.384615385
    32.64   -42.04  -5.64   5.846153846
    22.79   -54.73  -41.55  5.153846154
    22.07   -54.84  -44.82  3.538461538
    15.13   -59.8   -51.6   2.615384615
    13.18   -49.52  -87.39  3.769230769
    28.62   -39.47  -71.34  6.076923077
    39.11   -26.79  -52.06  4.230769231
    ];
interpolatedScalars = interpolateScalars( scalars_erect, coord');
interpolatedScalars(1) = 5.01;
figure, showPointCloud( coord', interpolatedScalars, 'MarkerSize', 60 );
colormap(jet)
colorbar

这是为插值创建的函数:

function [interpolatedScalars] = interpolateScalars( scalars, vertices)
interpolatedScalars = zeros( size(vertices,1),1 );
for vertex_id=1:size(vertices,1)
    dist_squared = sum( ((scalars(:,1:3) - repmat( vertices(vertex_id,:)',...
        1,size(scalars,1))').^2),2 );
    weightedDist = 0.0;
    for i=1:size(scalars,1)
        weightedDist = weightedDist  +  scalars(i,4) *...
        (sum(dist_squared(1:size(scalars,1)))-dist_squared(i)) /...
        ((size(scalars,1)-1)*sum(dist_squared(1:size(scalars,1))));
    end
    interpolatedScalars(vertex_id) = weightedDist;
end
end

这是我得到的输出但颜色变化不够平滑,无法根据颜色来解释皮肤的厚度:

output

0 个答案:

没有答案