fill inside a specific boundary in bw image using poly2mask is not accurate

1 回表示 (過去 30 日間)
adi
adi 2014 年 8 月 20 日
コメント済み: Guillaume 2014 年 8 月 20 日
I have written the following code to delete a specific boundary using poly2mask:
function newBW = fillBoundery(B,bounderyNum,bw)
newBW = bw;
[m,n] = size(bw);
x = B{bounderyNum,1}(:,2);
y = B{bounderyNum,1}(:,1);
reg2del = poly2mask(x, y, m, n);
a = newBW(reg2del);
newBW(reg2del) = deal( ~a(1,1) );
end
where bw is the bw image, B is a boundary cell produced with bwboundaries, and bounderyNum is the index of the boundary in B that we want to fill.
this code works with one problem: the boundary is not fully filled. for example I have this bw:
and when I run
newBW = fillBoundery2(B,2,BW);
( 2 is the boundary of the smaller object) I get this:
how do I get a more accurate selection of the region inside a boundary, using this method or a different one?
  1 件のコメント
Guillaume
Guillaume 2014 年 8 月 20 日
Are you trying to remove the boundary around the object or do you want to remove the whole object?

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

回答 (0 件)

カテゴリ

Help Center および File ExchangeAgriculture についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by