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

5 visualizzazioni (ultimi 30 giorni)
萌香
萌香 il 9 Giu 2022
Modificato: Atsushi Ueno il 9 Giu 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)

Risposte (0)

Community Treasure Hunt

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

Start Hunting!