フェレ径(イメージ領域)の可視化

7 vues (au cours des 30 derniers jours)
彩華 伊佐
彩華 伊佐 le 3 Nov 2022
Commenté : 彩華 伊佐 le 4 Nov 2022
二値化画像から取得したフェレ径について、どの部分を計算しているのか確認したいです。
二値化画像に重ね合わせる形で、フェレ径の線分を表示させる方法を教えていただきたいです。
コードは以下の通りです。
I = imread("image.jpg");
% 2値化
level = graythresh (I);
BW = imbinarize(I,level);
BW1 = imfill(BW,'holes'); % オブジェクトの塗り潰し
Label = bwlabel(BW1,4); % ラベリング処理
prop = regionprops(Label,'MaxferetProperties'); % フェレ径情報の取得

Réponse acceptée

Kojiro Saito
Kojiro Saito le 4 Nov 2022
bwferetのドキュメントが役立つと思います。
フェレ径を求めた後、imshowで画像を表示した後、imdistlinelineを使って線を重ね書きできます。
同じ画像ファイルがないので、ここではtoyobjects.pngを使った例を提示します。
imdistlineの場合:線と距離が表示されます
I = imread("toyobjects.png");
bw = imbinarize(I,'adaptive');
bw = bwareafilt(bw,4);
bw = imfill(bw,'holes');
prop = regionprops('table', bw,'MaxferetProperties'); % フェレ径情報の取得
feretMax = prop.MaxFeretCoordinates;
feretMaxDiameter = prop.MaxFeretDiameter;
% フェレ径の線分の表示 (imdistlineの場合)
imshow(I);
axis = gca;
for n = 1:height(feretMax)
xmin = [feretMax{n}(1,1) feretMax{n}(2,1)];
ymin = [feretMax{n}(1,2) feretMax{n}(2,2)];
imdistline(axis,xmin,ymin);
end
lineの場合:線のみ表示されます
I = imread("toyobjects.png");
bw = imbinarize(I,'adaptive');
bw = bwareafilt(bw,4);
bw = imfill(bw,'holes');
prop = regionprops('table', bw,'MaxferetProperties'); % フェレ径情報の取得
feretMax = prop.MaxFeretCoordinates;
feretMaxDiameter = prop.MaxFeretDiameter;
% フェレ径の線分の表示 (lineの場合)
imshow(I);
axis = gca;
for n = 1:height(feretMax)
xmin = [feretMax{n}(1,1) feretMax{n}(2,1)];
ymin = [feretMax{n}(1,2) feretMax{n}(2,2)];
line(axis, xmin, ymin)
end
  1 commentaire
彩華 伊佐
彩華 伊佐 le 4 Nov 2022
表示させることができました。ありがとうございます。

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur イメージ dans Help Center et File Exchange

Produits


Version

R2022b

Community Treasure Hunt

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

Start Hunting!