How to tell if random points are in the same feature or not
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
Image Analyst
2022 年 9 月 19 日
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?
回答 (1 件)
Dimitrios Patsatzis
2022 年 9 月 19 日
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
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Voronoi Diagram についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!