* octave で画像処理 - 画像の縮小 bilinear 法 [#kfe225b2]

アンチエイリアジングフィルタとして bilinear 法を使って画像を縮小してみます.
フィルタが bilinear 法に変わっただけで,考え方や手順は[[前回>日記/2010-04-24/octave で画像処理 - 画像の縮小 nearest neighbor 法]]と一緒です.

** bilinear フィルタの重み付け係数 [#kf5a34f1]

係数の比率としては[[画像の拡大>日記/2010-04-13/octave で画像処理 - bilinear 法]]と全く一緒です.
が,今回は黒画素が水増しされてるわけではないので,係数の総和が 1 になるよう正規化します.

|1/16|1/8|1/16|
|1/8|1/4|1/8|
|1/16|1/8|1/16|

** フィルタリング [#q600c10e]

それでは octave 上で実際にやってみます.

 octave:1> [ x m a ] = imread ( 'gaishi.jpg' );
 octave:2> x = double ( x ) / 255;
 octave:3> h = [ .25 .5 .25; .5 1 .5; .25 .5 .25 ]/4;
 octave:4> xf(:,:,1) = conv2 ( x(:,:,1), h );
 octave:5> xf(:,:,2) = conv2 ( x(:,:,2), h );
 octave:6> xf(:,:,3) = conv2 ( x(:,:,3), h );
 octave:7> imshow ( xf );

#ref(gaishi_bl.jpg,center)

octave:8> x2 = resample( xf, 2 );
octave:9> imshow ( x2 );
octave:10> imwrite ( xf, 'gaishi_bl.jpg', 'jpg' );
octave:11> imwrite ( x2, 'gaishih_bl.jpg', 'jpg' );



トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS