オブジェクト画像を条件によって破棄する。
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
HIGUCHI 樋口
am 13 Okt. 2021
Kommentiert: HIGUCHI 樋口
am 6 Nov. 2021
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/765911/image.png)
左図のように細胞が複数いる画像を2値化した上で、オブジェクトごとに重心を求めて、その点を中心にトリミングを行いました。
しかし、右図の下のように画像の境界面に別の細胞が写り込んでしまっているため、これらの画像を破棄するプログラムを作りたいと考えています。何か良い案がございますでしょうか。
このページの手順5を参考に出来ないかと考えています。もしこれ以外でも良い案があればよろしくお願いします。
3 Kommentare
Akzeptierte Antwort
Atsushi Ueno
am 16 Okt. 2021
画像の上下左右端の画素値のORを取れば「二値化画像の境界に白い画素があるかどうか」判定できます。
any([BW(1,:) BW(end,:) BW(:,1)' BW(:,end)'])
I = imread('rice.png');
BW = imbinarize(I);
any([BW(1,:) BW(end,:) BW(:,1)' BW(:,end)'])
imshow(BW); % 二値化画像の境界に白い画素がある
BW = imclearborder(BW); % イメージ境界と連結している明るい構造を非表示にする
any([BW(1,:) BW(end,:) BW(:,1)' BW(:,end)'])
imshow(BW); % 二値化画像の境界に白い画素がない
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu グラフィックス オブジェクトのプログラミング finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!