Remove objects from binary image

2 ビュー (過去 30 日間)
Gytis Raudonius
Gytis Raudonius 2016 年 4 月 9 日
回答済み: Torkan 2019 年 10 月 18 日
Hi, i removed objects who are small, but i need also remove objets who is by formula height > width, so i need remove objects who have biggest height than width, i set bounding box but i stop.
CC = bwconncomp(BW1, 8);
S = regionprops(CC, 'Area');
L = labelmatrix(CC);
P = 1500;
BW2 = ismember(L, find([S.Area] >= P));
figure, imshow(BW2);
st = regionprops(BW2, 'BoundingBox', 'Orientation' );
L = labelmatrix(CC);
for k = 1 : length(st)
thisBB = st(k).BoundingBox;
rectangle('Position', [thisBB(1),thisBB(2),thisBB(3),thisBB(4)],...
'EdgeColor','r','LineWidth',2 )
end
Thanks for your answers

回答 (2 件)

Walter Roberson
Walter Roberson 2016 年 4 月 9 日
BB = vertcat(st.BoundingBox);
BB_W = BB(:,3);
BB_H = BB(::4);
wrong_shape = BB_H > BB_W;
st(wrong_shape) = []; %get rid of them
  1 件のコメント
Torkan
Torkan 2019 年 10 月 18 日
Hi Walter,
How can now we show those objects?

サインインしてコメントする。


Torkan
Torkan 2019 年 10 月 18 日
We should remove the last line from the BW2 , right? How can we do that?

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by