⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test_farthest_sampling_shape.m.svn-base

📁 fast marching method
💻 SVN-BASE
字号:
% test for meshing the inside of an objectpath(path,'toolbox/');path(path,'data/');name = 'mm';n = 400;Ma = load_image(name,n-10);Ma = rescale(abs(Ma));% to avoid that the shape touches the boundaryM = zeros(n,n,3);M(6:n-5,6:n-5,:) = Ma;repimg = 'results/meshing-shape/';if ~exist(repimg)    mkdir(repimg);endM1 = mean(M,3);mask = 1-(M1==M1(1));boundary = compute_shape_boundary(mask)';Ibound = boundary(1,:) + (boundary(2,:)-1)*n;for k=1:size(M,3)    Ma = M(:,:,k);     Ma(M1<=0) = 1;     Ma(Ibound) = 1;    M(:,:,k) = Ma;end% number of samples for the meshif not(exist('p'))    p = 400;end% use an adaptive distance fieldif not(exist('use_adaptive'))    use_adaptive = 1;endif use_adaptive    % compute boundary points    boundary = compute_shape_boundary(mask)';    % compute distance to boundary    [D,Z,Q] = perform_fast_marching(ones(n), boundary);    % set up a distancing field    R = 0.8;    D1 = min(rescale(D),R);    H = sqrt( R^2 - (D1-R).^2 ) * n;    W = rescale( D, 0.1,1 );else    W = ones(n);end%% perform sampling using farthest pointL = zeros(n) - Inf;I = find(mask); L(I) = Inf;vertex = [n/2;n/2];options.constraint_map = L;vertex = perform_farthest_point_sampling(W, vertex, p, options );%% compute the associated triangulation[D,Z,Q] = perform_fast_marching(W, vertex, options);faces = compute_voronoi_triangulation(Q, vertex);%% displayclf;hold on;imagesc(rescale(M)); axis image; axis off;plot_edges(compute_edges(faces), vertex(2:-1:1,:), 'r');plot(vertex(2,:), vertex(1,:), 'b.', 'MarkerSize', 8);hold off;axis tight; axis image; axis off;colormap gray(256);axis ij;str = [name '-mesh-' num2str(p)];if use_adaptive    str = [str '-adaptive'];endsaveas(gcf, [repimg str '.png'], 'png');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -