Hi all,
The following code solves the problem.
clc; close all; clearvars;
lambda = 10;
npoints = poissrnd(lambda);
pproc = rand(npoints,2);
x = pproc(:,1);
y = pproc(:,2);
[vx,vy] = voronoi(x,y);
plot(vx,vy,'k-'); hold on; axis([0 2 0 2]);
% Perform DT on original x and y
DT = delaunayTriangulation(x,y);
% V contains vertices
% R contains regions
[V,R] = voronoiDiagram(DT);
% Obtain vertices enclosing region 1
coord = V(R{1},:);
% for while loop
i = 2;
% Exclude infinite vertices
% Loop until no region has infinite vertices
while ismember(Inf,coord)
coord = V(R{i},:);
i = i + 1;
end
% Append the first vertex just to plot a complete polygon
coord = [coord;coord(1,:)];
% Plot the polygon
plot(coord(:,1),coord(:,2),'b-','linewidth',2);
The following image is an example output of the above code.