finding covered regions created by intersecting random lines

1 回表示 (過去 30 日間)
Mustafa Codur
Mustafa Codur 2021 年 3 月 14 日
編集済み: Mustafa Codur 2021 年 3 月 14 日
hey, i am trying to find covered areas by random lines as seen in the figure (i need to produce much complex structures). The intersects (or node points) are kept in a Sparse matrix. (I manually added a red dot as an example)
  2 件のコメント
John D'Errico
John D'Errico 2021 年 3 月 14 日
Are you looking only for regions that are entirely enclosed in 2-d by some set of line segments?
Mustafa Codur
Mustafa Codur 2021 年 3 月 14 日
編集済み: Mustafa Codur 2021 年 3 月 14 日
it is right. I have intersects and i want to have the intersect nodes numbers which are covering the region. not with image processing. For example, Region1 consists of 34th,25th,42th nodes.
although there is a paper mentions about an algorithm i could not get that;
https://www.inesc-id.pt/ficheiros/publicacoes/936.pdf

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

回答 (1 件)

darova
darova 2021 年 3 月 14 日
Here is the method using bwlabel
clear
clc
I = zeros(100);
% random coordinates of lines
x = rand(20,2)*98+1;
y = rand(20,2)*98+1;
% horizontal and vertical lenghts
dx = abs(diff(x,[],2));
dy = abs(diff(y,[],2));
for i = 1:size(x,1)
n = max(dx(i),dy(i)); % max length
n = round(n);
x1 = linspace(x(i,1),x(i,2),n);
y1 = linspace(y(i,1),y(i,2),n);
ind = sub2ind(size(I),round(y1),round(x1));
I(ind) = 1; % burn line
end
[I1,m] = bwlabel(~I,4); % separate each region
imshow(I1,rand(n,3))

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by