オブジェクト画像を条件によって破棄する。
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
HIGUCHI 樋口
el 13 de Oct. de 2021
Comentada: HIGUCHI 樋口
el 6 de Nov. de 2021
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/765911/image.png)
左図のように細胞が複数いる画像を2値化した上で、オブジェクトごとに重心を求めて、その点を中心にトリミングを行いました。
しかし、右図の下のように画像の境界面に別の細胞が写り込んでしまっているため、これらの画像を破棄するプログラムを作りたいと考えています。何か良い案がございますでしょうか。
このページの手順5を参考に出来ないかと考えています。もしこれ以外でも良い案があればよろしくお願いします。
3 comentarios
Respuesta aceptada
Atsushi Ueno
el 16 de Oct. de 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); % 二値化画像の境界に白い画素がない
Más respuestas (0)
Ver también
Categorías
Más información sobre グラフィックス オブジェクトのプログラミング en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!