最佳答案
这是一个使用 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
%# perform the distance transform
dt = bwdist(img);
%# 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)
关于algorithm - Matlab:椭圆voronoi图的算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7872968/