产生随机分叶肺结节轮廓的想法

时间:2014-04-08 09:20:33

标签: matlab geometry computational-geometry shape shapes

我需要生成随机分叶轮廓,例如以下enter image description here

关于如何做到这一点的任何想法或算法? 我将使用的软件是matlab,但是如果你用其他语言发布解决方案我也没有问题......

p.s我只需要绘制一个类似于上面的随机轮廓......

2 个答案:

答案 0 :(得分:5)

这个怎么样?

degree = 5;
numPoints = 1000;
blobWidth = 5;    

theta = 0:(2*pi)/(numPoints-1):2*pi;

coeffs = rand(degree,1);
rho = zeros(size(theta));
for i = 1:degree
    rho = rho + coeffs(i)*sin(i*theta);
end

phase = rand*2*pi;

[x,y] = pol2cart(theta+phase, rho+blobWidth);
plot(x,y)
axis equal 
set(gca,'Visible','off')

Blob

您可以通过修改degree来控制 wiggliness lobulacrity。我认为5给出了一些关于 wiggly lobulacious作为你的例子。

这很有趣 - 希望它有所帮助!

答案 1 :(得分:4)

这是一个想法。

step = 0.1;
r_min = 0.5;
r_max = 1.0;
ir = 35;
tt = linspace(0, 2*pi, ir);
t = linspace(0, 2*pi, 5*ir);

rr = r_min + (r_max - r_min)*rand(1, length(tt));
rr(end) = rr(1);
r = interp1(tt, rr, t, 'spline');
// add some noise of magnitude N
N = 0.1;
noise = -N + 2*N*rand(1, length(r));
noise(1:2:end) = 0.0;
r = r + noise;
// 
hp = polar(t, r);
set(hp, 'LineWidth', 2)

h = findall(gca,'type','line');
h(h == hp) = [];
delete(h);
t = findall(gca,'type','text');
delete(t);
delete(findall(gca, 'FaceColor', [1 1 1]))

典型输出如下(ir = 10,没有噪声)

randomly generated planar closed curve

或者这个(ir = 35,有无噪音)

randomly generated planar closed curve perturbed by noise