if i have this binary image, and i would like to distributed nodes in
the white area, which is the best way can distributed nodes to cover all the environments equally?
unifor.png

4 件のコメント

Walter Roberson
Walter Roberson 2019 年 7 月 28 日
How is "covering" the environment "equally" defined ? Is it just pure line of sight, so a node carefully placed along the bottom a bit left of the right edge, could just "nick" the black part on line of sight to get at least 20% of the way up along the right-hand edge? Is it defined by distance, and if so does the black part block signals? Is it okay if there are points that are not covered? Is the task to find the mininum number of locations that somehow cover the white part? -- which is something that could fall apart if the black changed just a little?
mohammed alany
mohammed alany 2019 年 7 月 28 日
let us assume we have 50 nodes, i would like to distributed them with equal distance
So, the distance between each pairs almost equal
Walter Roberson
Walter Roberson 2019 年 7 月 28 日
As a first attempt, you could find() the row, column positions of all of the white pixels. Arrange as row column pairs as rows [r1 c1; r2 c2; ...]. Now kmeans requesting 50 clusters.
mohammed alany
mohammed alany 2019 年 7 月 28 日
i am new in matlab
i perform this, how i can use kmeans now please?
map = imread('C:\Users\mrh\Desktop\a1.jpg');
BW = im2bw(map)
[y, x] = find(map)
c = [x, y]

サインインしてコメントする。

 採用された回答

Walter Roberson
Walter Roberson 2019 年 7 月 30 日

0 投票

NC = 50;
map = imread('unifor.png');
BW = im2bw(map);
[y, x] = find(BW);
c = [x, y];
initpos = c(randperm(size(c,1),NC),:);
[idx,cents] = kmeans(c, NC, 'maxiter', 500, 'start', initpos);
ddd = squareform(pdist(cents));
ddd(1:(NC+1):end) = inf;
image(BW);
colormap(gray(2));
N = string(1 : NC);
hold on
scatter(cents(:,1), cents(:,2));
text(cents(:,1), cents(:,2), N);
hold off
You might notice some points at the bottom of the image. That white stripe along the bottom is part of the original image, and so distributing equally in the white portion requires placing some points in that white stripe.

1 件のコメント

mohammed alany
mohammed alany 2019 年 7 月 30 日
Many thanks, all the time you are giving me the best solutions

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Image Processing Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by