吉澤 信
[email protected], 非常勤講師 大妻女子大学 社会情報学部画像情報処理論及び演習II
第7回講義
水曜日1限
教室6218
情報デザイン専攻-フィルタ処理・エッジ強調-特徴保存フィルタ
Shin Yoshizawa: [email protected]
今日の授業内容
1. 特徴保存フィルタの基礎. 2. 非線形拡散(エッジ保存)、Bilateral(エッジ保存)フィルタ、 Non-Local Means (パターン保存)フィルタ. 3. 演習:エッジ保存フィルタ. www.riken.jp/brict/Yoshizawa/Lectures/index.html www.riken.jp/brict/Yoshizawa/Lectures/Lec18.pdf 今日の演習は第2回のレポートで出すので、 みなさん頑張ってくださいねーp(^^)q復習:拡散方程式の離散計算
) , , ( ) , , ( t y x I t t y x I )
,
(
)
,
(
)
,
(
1i
j
I
i
j
I
i
j
I
n
n
n ) , ( 4 ) 1 , ( ) 1 , ( ) , 1 ( ) , 1 (x y I x y Ixy Ix y I xy I I )) 1 , 1 ( ) 1 , 1 ( ) 1 , 1 ( ) 1 , 1 ( ( 5 . 0 ) , ( 6 ) 1 , ( ) 1 , ( ) , 1 ( ) , 1 ( y x I y x I y x I y x I y x I y x I y x I y x I y x I I 時間は、前進1次差分近似:epsilonは微小時間. 4連結 8連結 空間は(Laplace作用素の)中心2次差分近似:=
} ; ); ( ){ iteration ( tmp I I Filtering tmp for Shin Yoshizawa: [email protected]今日は特徴(エッジ・パターン)保存フィルタ
単純な平滑化 特徴保存平滑化
Shin Yoshizawa: [email protected]
畳み込みと平滑化: 拡散方程式(偏微分方程式)と平滑化: 拡散方程式はフーリエ変換 を用いると(ある境界条件の場合に)形式解が導ける! . 0 ) ( ), ( , ), ( , , ) ( ) ( *
f t gx tdt f g C x f x g x g f Normalized Convolution: . ) ( / ) ( ) (
f t gxtdt g xt dt . ) ( (b/a)2 ab e G ). ( ) 0 , ( , 0 , ))), , ( ( grad ( div hxt x t hx f x h t h 拡散方程式のフーリエ解は基本解と初期値の畳み込み: Convolution Kernel: gまず平滑化(Smoothing)とは何か?
Shin Yoshizawa: [email protected]
y x y y y x y y x f G d t d t g f t h (4 )n ( ) t(| |) 1 ) , ( ) ( ) , ( /2 4 拡散の時間変化=Gaussianフィルタの標準偏差パラメータ変化 変分問題と平滑化:ディリクレエネルギーの最小化: 周波数領域での平滑化: . 0 , h t h t hwith appropriate boundary condition. Dirichletエネルギー最小化問題:
h2min. . ) , ( , , 0 ) , ( ) , 0 ( , 0 ), ( ) 0 , ( , t x u x t l u t u l x x h x u u t u
l k k k ydy l k y h l b x l k t l k b t x u 0 1 2 2 2 . sin ) ( 2 , sin ) exp( ) , ( Fourier解: t 高周波ほど急激に減少.Gaussian フィルタ = Laplacian Smoothing =拡散・熱伝導方程式の 解=Dirichletエネルギーの最小化~高モードFourier係数の0への置き
換え=Low Pass Filter. Shin Yoshizawa: [email protected]
Shin Yoshizawa: [email protected]
標準偏差と時間変化
I
t
t
t
t
I
),
,
(
)
,
(
x
x
) ( ) ( ) , , (x g x y I y dy I 2 2 2 2 2 1 ) ( a r a r e g 拡散度合=時間経過= Gaussianフィルタの標準偏差エッジ保存フィルタ:非線形拡散
GradientのDivergenceはLaplacian:
非線形(異方性)フィルタ(Nonlinear Diffusion): 拡散係数c を異方的に考える+エッジの大きさ(勾配強度)が大きい 方向には平滑化しない.
div
))
,
(
)
)
,
(
(
(
div
c
I
t
I
t
t
,t)
I(
x
x
x
:
div
(c
I)
cは拡散係数(普通は位置(u,v)や 輝度値I(u,v)に依存しない定数). 均一な拡散 適応的拡散 小:たくさん平滑化したい. 大:平滑化したくない (少ない平滑化). 小: Shin Yoshizawa: [email protected]非線形拡散フィルタ2
局所的に異方な拡散→全体で適応的拡散になる:
勾配:小: 大きく平滑化したい. 勾配:大: 平滑化したくない. 勾配:小: ©CG-ARTS協会I
勾配:大: 勾配:小: Shin Yoshizawa: [email protected]非線形拡散フィルタ3
非線形拡散係数(関数)は例えば、
) σ x ( c(x) 2 2 2 exp 2 1 1 αx c(x) や をよく使う.))
,
(
)
)
,
(
(
(
div
c
I
t
I
t
t
,t)
I(
x
x
x
alphaの変化Shin Yoshizawa: [email protected]
非線形拡散フィルタ3
非線形(異方性)フィルタの離散化: 最も簡単な
前進差分の陽解法では…
2 1 1 I clm
1 1 1 1 1(, ) (, ) 1 l ( ( , ) (, )) l m m n n lm n n c I i l j m I i j C j i I j i I ) , ( ) , (i l j m I i j I I 1 lm c もし 又は(輝度 値に依存しない)定数な ら普通の拡散方程式.
1 1 1 1 l l m m lm c C))
,
(
)
)
,
(
(
(
div
c
I
t
I
t
t
,t)
I(
x
x
x
Shin Yoshizawa: [email protected]
非線形拡散フィルタ4
Shin Yoshizawa: [email protected]
入力画像 非線形拡散alpha=0.1 非線形拡散alpha=0.005
非線形拡散フィルタ5
Shin Yoshizawa: [email protected]
t t I t I c t t I )), , ( ) ) , ( ( div( ) , ( x x x 非線形拡散alpha=0.1 非線形拡散alpha=0.005
Anisotropic (Nonlinear) Diffusion: P. Perona and J. Malik, IEEE PAMI, 1990.
)), , ( ) ) , ( ( ( ) , ( 2 t I t I g div t t I x x x ), , ( ) , ( I t t t Ix x 2 2 2 2 2 1 ) ( a r a r e g , ) ( |) (| ) ( new
x y y y x g I d I Total Variation: L. Rudin, S. Osher, and E. Fatemi, Physica D, 1992.
Inew x dx g Inew x I x dx Inew 2 | ) ( ) ( * | 2 1 |) ) ( (| min arg ) ( * )) ( ) ( * ( )) ( ) ( ) ) ( ( div( x x x x x x I g I I g I I new new new new Linear Diffusion (Gaussianフィルタ): Gabor 1960.
画像処理での平滑化
Shin Yoshizawa: [email protected]
Bilateralフィルタとは?
Input Bilateral Filter Gaussian Filter ) ( ) ) ( ) ( ( ) , (xy g Ix Iy g xy Z h , ) , ( / ) ( ) , ( ) ( new
xy y y xy y x Z I d Z d ISpatial-Tonal Normalized Convolution: ) ( ) , (xy g xy Z . ) ( 2 2 a r a r e g Intensity (Tonal)
Kernel Spatial Kernel
エッジ特徴を保存する! Shin Yoshizawa: [email protected]
Edge Intensity Kernelは、エッジの 境界を跨いでの輝度値の平 滑化を抑制する. ) ) ( ) ( ( ) , (xy g I x I y Z h Intensity Kernel ) ( ) ) ( ) ( ( ) , (xy g I x I y g xy Z h Spatial Kernel Intensity Kernel Spatial Kernelは、平 滑化の影響を局所化 する. 1 y x xy2 ) (x I ) (y2 I ) (y1 I ) , ( vu I v u, ) ( ) (xy1 I ) ( ) (xy2 I , ) , ( ) ( ) , ( ) ( new y y x y y y x x d Z d I Z I () 2. 2 a r ar e g
なぜエッジを保存するのか?
Shin Yoshizawa: [email protected]
目的に応じて二つのパラメータを調節: sigmaはGaussianフィルタや 拡散方程式(微小時間×繰り返し回数)と同じ影響. hは保存したい エッジの大きさに依存.
Bilateralフィルタのパラメータ
Intensity parameter Spat ial par amet er ) ( ) ) ( ) ( ( ) , (xy g I xIy g xy Z h h / h
©S. Paris et al. ©ACM.Shin Yoshizawa: [email protected]
Bilateral Gaussian
Input
Bilateralフィルタ
Shin Yoshizawa: [email protected]
©CG-ARTS協会
数回適用が
良い結果:
hは平滑化したい部分 の輝度値の標準偏差 の0.5~2.0倍程度をよ く使う. ) ( ) ) ( ) ( ( ) , (xy g IxIy g xy Z hBilateralフィルタ2
Shin Yoshizawa: [email protected]
Bilateralフィルタ3
Shin Yoshizawa: [email protected]
Color Bleeding
Shin Yoshizawa: [email protected]
多次元(Color)のフィルタで、RGB各色チェンネル毎に異な るパラメータで処理すると、カラーが混ざってしまう. - RGB毎に同じパラメータでフィルタを適用する. - カラーの勾配を用いる=距離をカラー空間で測る. ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( y x y x y x y x B B G G R R I I ) ( ) ( ) ( ) ( x x x x B G R I 入力画像 カラー 非線形拡散 RGBチェンネル毎 非線形拡散 RGBチャンネル毎 Bilateralフィルタ カラー Bilateralフィルタ ↓色が混ざって緑が出現. v u, ) (x I I(y2) ) , ( vu I ) (y1 I )) , ( (Distance ) , ( g X Y Z xy h Similarity Kernel X 1 Y 2 Y Similarity Kernelは、パターンの境界を 跨いでの輝度値の平滑を抑制する. 1 y 2 y 1 y x Pattern Pattern Pattern 1 Y X 2 Y x 1 y 2 y 3 y , ) , ( ) ( ) , ( ) ( new y y x y y y x x d Z d I Z I . ) ( 2 2 a r ar e g Non-Local (NL-) Meansフィルタ: A. Buades, B. Coll, and J.-M. Morel, 2004.
l d I I g D(x,y) (t) (x t) (y t)2 t 相互相関(Gaussian Cross-Correlation) ), ) , ( ( )) , ( (Distance ) , ( 2 1 y x D g Y X g Zxy h h 重みは局所画像の相似度:Similarity Kernelパターン保存フィルタ(NL-Means)
Shin Yoshizawa: [email protected]
相似度?: Bilateral vs. NL-Mean
) (x I ) (y2 I ) (y1 I ) , ( vu I v u, 1 y x xy2 ) ( ) (xy1 I ) ( ) (xy2 I Non-Local Meansフィルタ ), ( )) , ( ( ) , (xy g Dxy g xy Z h Bilateralフィルタ ), ) , ( ( ) , ( 2 1 y x y x g D Z h ) ( ) ( ) , (xy I x Iy D D(x,y)
g (t)I(xt)I(yt)2dt 二つの画素の
輝度値間(距離)
テクスチャーの距離
) (x I ) (y2 I ) , ( vu I v u, t ) (y1 IShin Yoshizawa: [email protected]
E. Bennett and L.McMillan, 2005. Video Enhancement (3D Image): A. Buades et al. 2004~. S. Yoshizawa et al. 2006. 3D Mesh Smoothing: 2D Image Denoising: O. Schall et al. 2006. Time-Varying Range Images Filter:
ビデオや3次元形状(Mesh)への拡張
計測・観察によって得られるデータは通常ノイズを含む. 加算性白色ガウスノイズは自然界の雑音を良く近似する. 最小二乗的に最適なノイズ除去法はWiener Filter. 理想フィルタは原信号のパワースペクトルが必要… 複雑な計測・観察データでは実用上「平滑化法」.
復習:ノイズ
凹凸の曲面上表示 ©wikipedia 実測データにおける装置による雑音の例 Shin Yoshizawa: [email protected]Signal-to-Noise Ratio (SN比)
Shin Yoshizawa: [email protected]
ノイズと元信号の比:
-小さい=ノイズが多い.
-大きい=ノイズが少ない.
©G. Baker, 2005. ) ) ) , max( ( 1 ( log 10 PSNR 1 2 10 N j j j j j I f I f N Peak-SNR (色々な定義あり): e.g.n
f
g
I
*
Statistical Analysis of Signal-to-Noise Ratio
)
(
)
(
x
noisyI
smoothedx
I
Method Noise:入力から出力を引いた画像. 特徴が出て いれば使ったFilterがノイズのみでなく,入力画像の特徴 を消している.Signal-to-Noise Ratioの空間表現.Shin Yoshizawa: [email protected]
Gaussian Median Yaroslavsky Bilateral NL-Means Input
Method Noise
様々なノイズ除去法の比較
Wiener Filters, Wavelet thresholds.
Gaussian, Anisotropic, Total Variations.
NL-Mean
NL-Mean Noisy Input Gaussian Anisotropic TV1 TV2 TV3
Fourier-Wiener
DCT-Wiener Wavelet Hard Wavelet Soft
Translation invariant Wavelet hard Noisy Input
Shin Yoshizawa: [email protected]
©A. Buades et al. 2004.
Method Noise:
I
(
x
)
I
new(
x
)
NL-Mean Original Gaussian Anisotropic TV1 TV2 TV3
Neighborhood Wavelet Soft Wavelet Hard Wiener DCT-Shin Yoshizawa: [email protected]
様々なノイズ除去法の比較2
©A. Buades et al. 2004.
Shin Yoshizawa: [email protected]
演習: エッジ保存フィルタ
www.riken.jp/brict/Yoshizawa/Lectures/index.html www.riken.jp/brict/Yoshizawa/Lectures/Lec18.pdfwww.riken.jp/brict/Yoshizawa/Lectures/Ex12.zip
↑はReport06の内容です。
前回・前々回(Lec16.pdf, Lec17.pdf)の演
習が出来ていない人はそちらを先にやりま
しょう!
演習18-1: 非線形拡散方程式によるエッジ保存フィ ルタの作成. 演習18-2: Bilateralフィルタの作成.演習18-1
Shin Yoshizawa: [email protected]非線形拡散方程式によるエッジ保存平滑化フィルタの作 成: Ex12.zip内のNonlinearDiffusionColor.cxxの中にあるコ メントに従ってフィルタを作成しましょう. 微小時間epsilon=0.25、エッジの重みalphaは0.1と0.01で繰 り返し10,50,100で実行してみましょう(6種類). 2 1 1 c I 非線形拡散alpha=0.1, 100回 非線形拡散alpha=0.01, 100回
演習18-2
Shin Yoshizawa: [email protected]Bilateralフィルタの作成: Ex12.zip内ColorBilateralFilter.cxx の中にあるコメントに従ってフィルタを作成しましょう. Spatial Kernelの標準偏差sigma=10.0、25.0、Intensity Kernelの標準偏差h=1.0×(画像全体のグレースケールの 標準偏差)を0.1、0.2、0.5と、畳み込み半径10で実行してみ ましょう(6種類). sigma=10.0 h=0.15 sigma=10.0 h=0.5
Shin Yoshizawa: [email protected]