座標と面積を対応させたい

Voronoi図形の面積とその領域の座標を対応させてワークスペースに格納したいです。しかし、以下のコードを打つと図上では面積は表示されますが座標がわかりません。どうコードを書けば良いでしょうか?
figure, imshow(rgb2);
hold on
A = zeros(length(C),1);
for i = 1:length(C)
if all(C{i}~=1)
pat = patch(V(C{i},1),V(C{i},2),i);
A(i) = polyarea(V(C{i},1),V(C{i},2));
center = mean([V(C{i},1),V(C{i},2)]);
text(center(1),center(2),num2str(A(i)));
plot(center(1),center(2),'b x')
end
end
disp(A);
hold off

1 Kommentar

Rena Berman
Rena Berman am 11 Okt. 2018
(Answers Dev) Restored edit

Melden Sie sich an, um zu kommentieren.

Antworten (1)

KSSV
KSSV am 11 Okt. 2018

2 Stimmen

clear all ;clc
figure, imshow(rgb2);
hold on
A = zeros(length(C),1);
coor = cell(length(C),1) ;
for i = 1:length(C)
if all(C{i}~=1)
pat = patch(V(C{i},1),V(C{i},2),i);
A(i) = polyarea(V(C{i},1),V(C{i},2));
coor{i} = [V(C{i},1) V(C{i},2)] ;
center = mean([V(C{i},1),V(C{i},2)]);
text(center(1),center(2),num2str(A(i)));
plot(center(1),center(2),'b x')
end
end
disp(A);
hold off
coor gives you the required coordinates.

3 Kommentare

Senka Okamoto
Senka Okamoto am 11 Okt. 2018
Bearbeitet: Senka Okamoto am 11 Okt. 2018
1つのcellにdoubleが入っています。これは何ですか?
KSSV
KSSV am 11 Okt. 2018
If any error, show the error...the coordinates are stored in coor variable.
coor{i} = [V(C{i},1) V(C{i},2)] ;
If any error, you have to change the way the are joined.
KSSV
KSSV am 11 Okt. 2018
Yes..those are the coordinates you need. As the region has different sides..you cannot store all coordinates into a matrix. So every regions coordinates are stored in a respective cell.
region i'th coordinates are C{i}

Melden Sie sich an, um zu kommentieren.

Tags

Gefragt:

am 11 Okt. 2018

Bearbeitet:

am 12 Okt. 2018

Community Treasure Hunt

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

Start Hunting!

Translated by