1

m x n次のような白い領域の論理画像がある場合:

地域の論理イメージ

白と黒の領域の境界線のインデックスを取得するにはどうすればよいですか?

4

2 に答える 2

2

これは単に、与えられた画像のエッジを検出することになります。MATLABには、edgeコマンドにそのための実装がすでに組み込まれています。Iキャニーフィルターを使用して画像の境界を検出する例を次に示します。

A = edge(I, 'canny');

結果の画像のゼロ以外の要素は、Aあなたが求めているものです。次に、を使用findしてそれらのインデックスを取得できます。

于 2013-01-13T15:01:32.523 に答える
1

edge入力はクリアなバイナリイメージであるため、@EitanTで提案されているように使用する必要はありません。

モルフォロジー演算を使用して周囲長を取得するimdilateimerodeおよびregionprops

% let input image be bw
we = bw & ~imerode( bw, strel('disk', 1) ); % get a binary image with only the boundary pixels set
st = regionprops(we, 'PixelIdxList'); % get the linear indices of the boundary

% get a binary image with pixels on the outer side of the shape set
be = ~bw & imdilate( bw, strel('disk', 1) );
st = regionprops(be, 'PixelList'); % get the row-col indices of the boundary
于 2013-01-13T18:52:38.670 に答える