前提・実現したいこと
上記の点群から以下に示す通りのノードとエッジを使ったグラフ(?)を作成したいと考えております.
これらの青の点群は以下のソースコードに示すcentroidsです.
該当のソースコード
rgb = imread('./images/rotate/r_mi.png'); gray = rgb2gray(rgb); bw = imbinarize(gray); % remove all object containing fewer than 30 pixels bw = bwareaopen(bw,30); SE = strel('disk', 2); bw1 = imopen(bw, SE); % fill any holes, so that regionprops can be used to estimate % the area enclosed by each of the boundaries % bw1 = imfill(bw1,'holes'); [B,L] = bwboundaries(bw1,'noholes'); % Display the label matrix and draw each boundary %imshow(label2rgb(L, @jet, [.5 .5 .5])) hold on for k1 = 1:length(B) boundary = B{k1}; plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 2) end s = regionprops(bw1,'centroid'); centroids = cat(1, s.Centroid); imshow(bw1) hold on plot(centroids(:,1), centroids(:,2), 'b*') hold off
URLはこちら↓
グラフのノードとエッジをプロット
上に示した画像の点群を表す行列から,写真の通りのことをしたいです.
ご教授いただけると嬉しいです.
補足情報(FW/ツールのバージョンなど)
MATLAB 2019a
あなたの回答
tips
プレビュー