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

1 view (last 30 days)
萌香
萌香 on 9 Jun 2022
Edited: Atsushi Ueno on 9 Jun 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)

Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!