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!