gpt4 book ai didi

algorithm - Matlab:椭圆voronoi图的算法

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:45:40 25 4
gpt4 key购买 nike

是否有任何算法可以实现以椭圆为界的 Voronoi 图?该图看起来像这里的图片 voronoi diagram of ellipses

http://www.loria.fr/~tzoumas/vorell/vorell01.png

谁能分享一些相关的链接、教程、代码等?

提前致谢。

最佳答案

这是一个使用 distance transform 的算法连同 watershed绘制椭圆 Voronoi 图的算法。

%# first, define some ellipses (for simplicity, I use 0/90 orientation)
ellipses = [10,20,5,10;30,10,10,7;40,40,8,3];

%# put the ellipses into an image (few pixels, therefore pixelated)
img = false(50);
[xx,yy]=ndgrid(1:50,1:50);
for e = 1:size(ellipses,1),img = img | (xx-ellipses(e,1)).^2/ellipses(e,3)^2 + (yy-ellipses(e,2)).^2/ellipses(e,4)^2 <= 1;end

enter image description here

%# perform the distance transform
dt = bwdist(img);

enter image description here

%# apply the watershed algorithm. 
%# ws==0 are the lines for the Voronoi diagram
ws = watershed(dt);

%# create a RGB image and display
%# note: for yellow lines, replace the last
%# "ws==0" by "zeros(size(ws))", so that you
%# only put ws into the red and green channel (=yellow)
rgb = cat(3,ws==0,ws==0,ws==0));
%# add the ellipses into the red channel
rgb(:,:,1) = rgb(:,:,1) | img;
imshow(rgb)

enter image description here

关于algorithm - Matlab:椭圆voronoi图的算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7872968/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com