Main Content

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

ordfilt2

2 次元の次数統計フィルター処理

説明

B = ordfilt2(A,order,domain) は、A の各要素を、domain の非ゼロの要素で指定される近傍集合を並べ替えたときの order 番目の要素と置き換えます。

B = ordfilt2(A,order,domain,S)A をフィルター処理します。ここで、ordfilt2domain の非ゼロ値に対応する S の値を加算オフセットとして使用します。この構文を使用して、グレースケールの膨張と収縮など、グレースケールのモルフォロジー演算を実装できます。

B = ordfilt2(___,padopt)A をフィルター処理します。ここで、padoptordfilt2 による行列の境界のパディング方法を指定します。

すべて折りたたむ

イメージをワークスペースに読み取って表示します。

A = imread('snowflakes.png');
figure
imshow(A)

Figure contains an axes object. The axes object contains an object of type image.

イメージをフィルター処理して、結果を表示します。

B = ordfilt2(A,25,true(5));
figure
imshow(B)

Figure contains an axes object. The axes object contains an object of type image.

入力引数

すべて折りたたむ

フィルター処理するデータ。2 次元数値行列または 2 次元 logical 行列として指定します。

データ型: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | logical

ターゲット ピクセルを置き換えるための要素。実数スカラー整数として指定します。

データ型: double

近傍。10 を格納した数値行列または logical 行列として指定します。domain はバイナリ イメージ演算で使用する構造化要素と等価です。1 の値をもつ要素はフィルター処理の近傍を定義します。次の表に、いくつかの一般的なフィルターの例を示します。

フィルター処理のタイプMATLAB コード近傍選択した要素を示すサンプル イメージ データ
メディアン フィルターB = ordfilt2(A,5,ones(3,3))3-by-3 matrix of ones3-by-3 matrix of numbers. The element with the fifth highest value in the neighborhood is circled.
最小値フィルターB = ordfilt2(A,1,ones(3,3))3-by-3 matrix of ones3-by-3 matrix of numbers. The element with the lowest value in the neighborhood is circled.
最大値フィルターB = ordfilt2(A,9,ones(3,3))3-by-3 matrix of ones3-by-3 matrix of numbers. The element with the highest value in the neighborhood is circled.
北近傍、東近傍、南近傍、西近傍の最小値B = ordfilt2(A,1,[0 1 0; 1 0 1; 0 1 0])3-by-3 neightborhood in which the north, south, east, and west pixels are true (1) and the center and corner pixels are false (0)3-by-3 matrix of numbers. The element with the lowest value in the specified neighborhood is circled. Elements excluded from the neighborhood are grayed out.

データ型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

加算オフセット。domain と同じサイズの数値行列として指定します。

データ型: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

パディング オプション。以下のいずれかの値に指定します。

オプション説明
'zeros'配列の境界を 0 でパディングします。
'symmetric'

配列自体の鏡像で配列をパディングします。

データ型: char | string

出力引数

すべて折りたたむ

フィルター処理されたデータ。入力データ A と同じクラスの 2 次元数値行列または 2 次元 logical 行列として返されます。

ヒント

  • ゼロ値要素を含まない大きな領域行列を扱う際、A が整数データ形式 (uint8int8uint16int16) の場合は、ordfilt2 で高いパフォーマンスが得られます。uint8int8 の速度のゲインは、16 ビット データ型より大きくなります。8 ビット データ形式の場合、領域行列には 7 行以上の行が含まれていなければなりません。16 ビット データ形式の場合、領域行列には 3 行以上の行と 520 以上の要素が含まれていなければなりません。

参照

[1] Haralick, Robert M., and Linda G. Shapiro, Computer and Robot Vision, Volume I, Addison-Wesley, 1992.

[2] Huang, T.S., G.J.Yang, and G.Y.Tang. "A fast two-dimensional median filtering algorithm.", IEEE transactions on Acoustics, Speech and Signal Processing, Vol ASSP 27, No. 1, February 1979

拡張機能

バージョン履歴

R2006a より前に導入

すべて展開する

参考