nlfilter
一般的なスライディング近傍演算
説明
例
イメージへのメディアン フィルターの適用
この例では、nlfilter
を使用してメディアン フィルターをイメージに適用する方法を説明します。この例では、3 行 3 列の近傍で medfilt2
を呼び出したのと同じ結果が得られます。
イメージをワークスペースに読み取ります。
A = imread('cameraman.tif');
イメージを double
に変換します。
A = im2double(A);
イメージに適用する関数 (メディアン フィルター) を作成します。
fun = @(x) median(x(:));
フィルターをイメージに適用します。
B = nlfilter(A,[3 3],fun);
元のイメージとフィルター処理されたイメージを並べて表示します。
montage({A,B})
title('Original Image (Left) and Median Filtered Image (Right)')
入力引数
A
— フィルター処理されるイメージ
数値配列
フィルター処理されるイメージ。fun
によってサポートされる任意のクラスの数値配列として指定します。A
がグレースケールの場合、任意の数値型または logical
にすることができます。A
にインデックスが付いている場合は、logical
、uint8
、uint16
、single
または double
を使用できます。
データ型: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
[m n]
— ブロック サイズ
正の整数の 2 要素ベクトル
ブロック サイズ。正の整数の 2 要素ベクトルとして指定します。m
はブロックの行数で、n
は列数です。
例: B = nlfilter(A,[3 3],fun);
データ型: single
| double
| logical
fun
— 関数ハンドル
ハンドル
関数ハンドル。ハンドルとして指定されます。この関数は、m
行 n
列の行列を入力として受け入れ、スカラーの結果を返さなければなりません。
c = fun(x)
c
は、m
行 n
列のブロック x
の中央ピクセルの出力値です。nlfilter
は、A
のピクセルごとに fun
を呼び出します。nlfilter
は必要に応じて、エッジにある m
行 n
列のブロックをゼロ パディングします。
データ型: function_handle
出力引数
B
— フィルター処理されたイメージ
数値配列
フィルター処理されたイメージ。数値配列として返されます。B
のクラスは fun
からの出力のクラスに依存します。
バージョン履歴
R2006a より前に導入
MATLAB コマンド
次の MATLAB コマンドに対応するリンクがクリックされました。
コマンドを MATLAB コマンド ウィンドウに入力して実行してください。Web ブラウザーは MATLAB コマンドをサポートしていません。
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)