How to tell if random points are in the same feature or not

1 visualización (últimos 30 días)
David Harra
David Harra el 18 de Sept. de 2022
Respondida: Dimitrios Patsatzis el 19 de Sept. de 2022
I have a vornoi diagram populated with random points of 2 arrays. From each of the points I can calculate the distance between Array1 and Array 2. Since the voroin is treated like a grain structure . How can I tell if the distance between each of the 2 points are in the same Voronoi or not?
For example is x(1) and y(1) in the same voronoi or is x(555) and y(555) in the same Vornoi ?
Not entirely sure how I can achieve this or how to format the code. Any help would be appreciated.
X=rand([1 1000]); % points for Voronoi
Y=rand([1 1000]); % points for Voronoi
x = rand(1, 2000); % Random Points Array 1
y = rand(1, 2000); % Random Points Array 2
%% Distance between Random points Method 1
Distance = zeros(length(x) , length(y));
for i = 1:length(x)
for j = 1:length(y)
if i ~= j
Distance(i,j) = sqrt((x(i)-x(j))^2 + (y(i)-y(j))^2);
end
end
end
%% Distance between Random points Method 2
D = hypot(x-x.', y-y.'); % without using for loop
%% Plot Voronoi and scatter points onto plot
figure(1)
scatter(x, y ,'*')
hold on
voronoi(X,Y)
  2 comentarios
Image Analyst
Image Analyst el 19 de Sept. de 2022
You need to label your regions. We talked about this before in your last post. And I think I gave you some things to consider. Isn't your actual situation an image of metallic grains, not a voronoi diagram? If someone answers this question, it will not be applicable, adaptable, or appropriate to your actual situation. I know you're thinking you're making it simpler but I think you'd just get an answer that won't work in your actual real world situation. Can you post your actual image?
David Harra
David Harra el 19 de Sept. de 2022
Hey
I was using this Voronoi as an example before atually applying it to my real grain data, which I believe would be more complicated and I find coding really challenging, so aplogies. My actual grain structure you can see below where the grains are in sizes of microns.

Iniciar sesión para comentar.

Respuestas (1)

Dimitrios Patsatzis
Dimitrios Patsatzis el 19 de Sept. de 2022
Hi David,
You could use the knnsearch built-in function to find the neigbhooring points
and then check if any of these in the same Voronoi cell with the reference one.
I haven't cross checked, but I hope it helps.
Dimitris

Categorías

Más información sobre Voronoi Diagram en Help Center y File Exchange.

Productos


Versión

R2022b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by