File: demo_label_sizing.m

package info (click to toggle)
octave-iso2mesh 1.9.8%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,128 kB
  • sloc: cpp: 11,982; ansic: 10,158; sh: 365; makefile: 59
file content (49 lines) | stat: -rw-r--r-- 1,464 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% specify maximum cell sizes for different labels
% (this is only valid when using 'cgalmesh' with v2m or vol2mesh)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% create a dummy image

rad = 10:10:50;
maxRad = max(rad);
box = zeros(maxRad + 1, maxRad + 1, maxRad + 1);
image = box;
box(1, 1, 1) = 1;
% DT = bwdist(box,'euclidean');
[ix, iy, iz] = meshgrid(1:maxRad + 1, 1:maxRad + 1, 1:maxRad + 1);
DT = sqrt((ix - 1) .* (ix - 1) + (iy - 1) .* (iy - 1) + (iz - 1) .* (iz - 1));

for i = 1:size(rad, 2)
    ball = DT <= rad(i);
    image(ball ~= 0) = image(ball ~= 0) + ball(ball ~= 0);
end

image = uint8(image);

% mesh the domain with different sizing options

figure;
maxvol = '1';
[no, el] = v2m(image, [], 5, maxvol, 'cgalmesh');
subplot(221);
plotmesh(no(:, 1:3), el, 'x-y<0');
title('a single scalar sets cell size for all labels');

maxvol = '1=2:2=1:3=2:4=1';
[no, el] = v2m(image, [], 5, maxvol, 'cgalmesh');
subplot(222);
plotmesh(no(:, 1:3), el, 'x-y<0');
title(sprintf('maxvol is "%s"', maxvol));

maxvol = '2:1:2:1';
[no, el] = v2m(image, [], 5, maxvol, 'cgalmesh');
subplot(224);
plotmesh(no(:, 1:3), el, 'x-y<0');
title(sprintf('maxvol is "%s", same as above', maxvol));

maxvol = '3=2:1:0.5';
[no, el] = v2m(image, [], 5, maxvol, 'cgalmesh');
subplot(223);
plotmesh(no(:, 1:3), el, 'x-y<0');
title(sprintf('maxvol is "%s", same to 3=2:4=1:5=0.5', maxvol));