9.2. コンボリューション行列...

9.2.1. 概観

ここは数学者の独壇場です。 フィルターはほとんどがコンボリューション行列を使用しています。 コンボリューション行列... フィルターと想像力があればどんなフィルターも創れます。

コンボリューション (二次元畳み込み) 行列とは何なのでしょう。 数学の小道具をちょっとばかり知っていただければ大まかな理解が可能です。 コンボリューションとは行列式をカーネル (核)と呼ばれる別の行列式で処理することです。

コンボリューション行列フィルターはを処理する最初の行列を使います。 像とは画素を縦横の座標に並べた 2 次元の集合です。 ほしい効果によって利用されるカーネルは異なります。

GIMP uses 5×5 or 3×3 matrices. We will consider only 3×3 matrices, they are the most used and they are enough for all effects you want. If all border values of a kernel are set to zero, then system will consider it as a 3×3 matrix.

画像でフィルターはそのあらゆる画素についてつぎつぎと検討します。 そのときの画素を端緒画素と呼び毎回この画素とその周りの 8 つの画素の値に対しカーネルの相応する値との積をそれぞれ得ます。 それらの値の合計が端緒画素の最終的な値となります。

つぎに簡単な例をご紹介します。

この図の左にあるのが画像の行列です。 各画素の値が書き込まれています。 端緒画素は赤枠で囲ってあります。 カーネルによる処理が及ぶのは緑の枠で囲ってある画素です。 右にあるのがコンボリューションによる結果です。

この計算で何が起きているかご説明いたしましょう。 フィルターはカーネルの作用領域のすべての画素を左から右へ上から下へ順番に読みとります。 カーネルに相応する部分の値とそれぞれ掛け合わされそれらの和を求めます。 端緒画素は (40×0)+(42×1)+(46×0) + (46×0)+(50×0)+(55×0) + (52×0)+(56×0)+(58×0) = 42 となります。 (このフィルターは元画像に直接作用せずその複製に結果を記録します。) 画像のほうでは端緒画素が 1 ピクセル下に移動しました。

9.2.2. Activating the Filter

This filter is found in the main menu under FiltersGenericConvolution Matrix….

9.2.3. オプション

図17.171 コンボリューション行列のオプション

「コンボリューション行列」のオプション

Presets, Input Type, Clipping, Blending Options, Preview, Split view
[注記] 注記

These options are described in 「Common Features」.

行列

This is the 5×5 kernel matrix: you enter wanted values directly into boxes.

約数

The result of previous calculation will be divided by this divisor. You will hardly use anything else than 1, which leaves results unchanged, and 9 or 25 according to matrix size, which gives the average of pixel values. The divisor can only be changed when Normalize is unchecked.

オフセット

This value is added to the division result. This is useful if result may be negative. This offset may be negative. It can only be changed when Normalize is unchecked.

チャンネル

Here you can select which channels the filter should change.

Normalize

このオプションを有効にすると約数は算出数に応じた値がとられます。 ただしその値が 0 になった場合は (0 では除算できません)、 オフセット値に 128 が設定されます。 負の数となるときは (負の数の色はありません)、 オフセットに 255 が設定され (反転した結果になり) ます。

アルファ加重

このオプションを無効にするとこのフィルターは透明度を考慮しませんが、 ぼかしがかかったときに加工痕が現れるおそれがあります。

境界

When the initial pixel is on a border, a part of the kernel is outside the image. You have to decide what the filter should do:

図17.172 Border examples

Border examples

Source image

Border examples

None border

Border examples

Clamp border

Border examples

Loop border


None

This part of the kernel is not taken into account.

Clamp

画像の縁の画素は変更されず切り抜かれます。

Loop

This part of the kernel will be affected by pixels of the opposite border, so pixels disappearing from one side reappear on the other side.

Black

Pixels on borders are changed to black.

White

Pixels on borders are changed to white.

9.2.4. 使用例

カーネル行列の設計は高度な数学の裏打ちがあります。 出来合いのものがウェブ上で見付かるはずです。 それらの例を少しばかりご覧ください。

図17.173 シャープ化

シャープ化
シャープ化

図17.174 ぼかし

ぼかし
ぼかし

図17.175 輪郭強調

輪郭強調
輪郭強調

図17.176 輪郭抽出

輪郭抽出
輪郭抽出

図17.177 エンボス加工

エンボス加工
エンボス加工