3×3 または 5×5 のカーネルが指定できる convolution
の使い方。数学的な話やマトリクスはここでは説明しない。
基本コマンド
3×3 のカーネル。基本コマンドは何も変化しない
ffplay -i input -vf convolution="0 0 0 0 1 0 0 0 0:0 0 0 0 1 0 0 0 0:0 0 0 0 1 0 0 0 0:0 0 0 0 1 0 0 0 0:1:1:1:1:0:0:0:0"
公式ドキュメント:FFmpeg Filters Documentation :: convolution
関連記事
- たたみ込み演算による画像処理
- Convolution Matrix
- Kernel (image processing) – Wikipedia, the free encyclopedia
- Sobel operator – Wikipedia, the free encyclopedia
オプション
カーネルが 3×3 または 5×5 で指定値の数が 9 または 25 と変わる。:
で区切ってチャンネル毎に指定する。
- 0m, 1m, 2m, 3m
最初の指定値。チャンネル毎にカーネルを指定する。3×3 なら 9。5×5 なら 25 の値を指定する。基本的には YUV 映像なら YUVA の順番。RGB 映像なら GBRP にフォーマット変換して GBRA の順番になる
3×3 の規定値:0 0 0 0 1 0 0 0 0
5×5 の規定値:0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 - 0rdiv, 1rdiv, 2rdiv, 3rdiv
チャンネル毎の指定カーネルに倍率をかける
規定値:1[float] - 0bias, 1bias, 2bias, 3bias
チャンネル毎の指定カーネルに加算。明るくしたり暗くしたりするのに便利
規定値:0[float]
コマンド例
- 先鋭化
ffplay -i input -vf convolution="0 -1 0 -1 5 -1 0 -1 0:0 -1 0 -1 5 -1 0 -1 0:0 -1 0 -1 5 -1 0 -1 0:0 -1 0 -1 5 -1 0 -1 0"
- ボックスブラー
ffplay -i input -vf convolution="1 1 1 1 1 1 1 1 1:1 1 1 1 1 1 1 1 1:1 1 1 1 1 1 1 1 1:1 1 1 1 1 1 1 1 1:1/9:1/9:1/9:1/9"
- 5×5 ガウスブラー
ffplay -i input -vf convolution="2 4 5 4 2 4 9 12 9 4 5 12 15 12 5 4 9 12 9 4 2 4 5 4 2:2 4 5 4 2 4 9 12 9 4 5 12 15 12 5 4 9 12 9 4 2 4 5 4 2:2 4 5 4 2 4 9 12 9 4 5 12 15 12 5 4 9 12 9 4 2 4 5 4 2:2 4 5 4 2 4 9 12 9 4 5 12 15 12 5 4 9 12 9 4 2 4 5 4 2:1/159:1/159:1/159:0"
- エッジ検出
ffplay -i input -vf convolution="0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:0 0 0 -1 1 0 0 0 0:5:1:1:1:0:128:128:128"
ffplay -i input -vf convolution="0 1 0 1 -4 1 0 1 0:0 1 0 1 -4 1 0 1 0:0 1 0 1 -4 1 0 1 0:0 1 0 1 -4 1 0 1 0:5:5:5:1:0:128:128:128" - エンボス
ffplay -i input -vf convolution="-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2:-2 -1 0 -1 1 1 0 1 2"
- ソベル
ffplay -i input -vf convolution="-1 -2 -1 0 0 0 1 2 1:-1 -2 -1 0 0 0 1 2 1:-1 -2 -1 0 0 0 1 2 1:-1 -2 -1 0 0 0 1 2 1:1:1:1:0:0:128:128:0"
ffplay -i input -vf convolution="-1 0 1 -2 0 2 -1 0 1:-1 0 1 -2 0 2 -1 0 1:-1 0 1 -2 0 2 -1 0 1:-1 0 1 -2 0 2 -1 0 1:1:1:1:0:0:128:128:0"
ffplay -i input -vf convolution="3 10 3 0 0 0 -3 -10 -3:3 10 3 0 0 0 -3 -10 -3:3 10 3 0 0 0 -3 -10 -3:3 10 3 0 0 0 -3 -10 -3:1:1:1:0:0:128:128:0"
ffplay -i input -vf convolution="3 0 -3 10 0 -10 3 0 -3:3 0 -3 10 0 -10 3 0 -3:3 0 -3 10 0 -10 3 0 -3:3 0 -3 10 0 -10 3 0 -3:1:1:1:0:0:128:128:0"