面積を画像に表示させる方法

24 vues (au cours des 30 derniers jours)
萌香
萌香 le 9 Juin 2022
Modifié(e) : Atsushi Ueno le 9 Juin 2022
画像を読み込み、下記のような処理をしています。
画像は結晶が複数写っているようなもので、セグメント化して面積や長径を求めたいです。
①画像に重心を表示することはできるのですが、面積や長径を表示させる方法はありますか?
②regionpropsの後、Centroid等の並びにBoundingBoxを入れるとエラーが出るのですが、何故でしょうか。
初心者のため拙い説明とコードで申し訳ありませんが、ご助言頂けますと幸いです。
figure; imshow(I);
I2=rgb2gray(I);
figure; imshow(I2);
figure; imhist(I2);
%%
BW=I2<75;
figure; imshow(BW);
%%
BW=imopen(BW,strel('disk',3));
figure; imshow(BW);
%%
Iclr=imclearborder(BW);
figure; imshow(Iclr);
%%
stats=regionprops('table',Iclr,'Centroid','Area','MajorAxisLength')
idx=stats.Area>5000;
stats(idx,:)=[];
%%
figure; imshow(Iclr); hold on;
plot(stats.Centroid(:,1),stats.Centroid(:,2),'r*');
hold off;
%%
AREA=[stats.Area];
h=histogram(AREA,'BinWidth',100)

Réponses (0)

Catégories

En savoir plus sur Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!