2014-04-08 18 views
2

我需要生成随机分叶状轮廓如如何做到这一点下面enter image description here思路生成随机分叶状肺结节的轮廓

任何想法或算法? 我将要使用的软件是MATLAB,但我有没有问题,如果你发布在其他语言中也解决方案...

PS我只需要画出类似于上述的随机轮廓......

+0

投票重新开放。为格式提供足够短的答案很简单,尽管可能会有多种变化,但只有一个基本答案。答案是狭隘的,这个问题可以在几段中回答。 –

+0

发布的两个答案都令人满意......我还编辑了题目以使问题更加具体化...... – obelix

回答

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 lobotcious作为你的例子。

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

+0

我想再提一个问题......我如何在您生成的轮廓上引入更小的嘈杂变体?? – obelix

+0

可否请您提供一些关于您发布的代码如何工作的简短解释? – obelix

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

+0

我想提出一个更多的问题...我怎么能在你生成的轮廓上引入一个额外的小嘈杂变化? – obelix

+0

@obelix我编辑了我的答案,添加了一个可以用作噪声量值的参数'N'。如果你不想要噪声,你可以设置N = 0.0或注释掉代码中的相关行。希望有所帮助。 – Drake

+0

谢谢!!!真的有用! – obelix