Farthest sampling on 3d mesh with mesh kept

3D mesh的farthest sampling与2D 图片的采样原理类似(http://blog.csdn.net/seamanj/article/details/52028904).

随机给个初始点,然后根据初始点,然后算出最远的n-1个点,  n为我们需要采样的个数

最后以这个n个点为初始点,算出mesh上的距离场


主要代码:


% test for farthest point sampling on 3D meshes

n = 300;
name = 'elephant-50kv';
[vertex,faces] = read_mesh(name);
options.name = name;

if size(vertex,1)>size(vertex,2)
    vertex = vertex';
end
if size(faces,1)>size(faces,2)
    faces = faces';
end


save_images = 0;

% plot sampling location
i = 0;
landmark = [];
for nbr_landmarks = [50]% 500 1000 2000 5000 10000]  % 100:50:500
    i = i+1;
    
    disp('Perform farthest point sampling.');
    landmark = perform_farthest_point_sampling_mesh( vertex,faces, landmark, nbr_landmarks-length(landmark) );
    %这步会根据farthest point sampling原则选出nbr_landmarks-length(landmark)个样本点
    % compute the associated triangulation
    [D,Z,Q] = perform_fast_marching_mesh(vertex, faces, landmark);
    %初始点为landmark,然后算距离
    % display
    col = D; col(col==Inf) = 0;
    col = perform_histogram_equalization(col, linspace(0,1,length(col)));
    options.face_vertex_color = col;
    hold on;
    plot_mesh(vertex, faces, options);
    hold off;
    colormap jet(256);
    camlight;
    shading interp;

end


运行结果如下:



完整源代码





版权声明:本文为seamanj原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。