# Loss function for Image Restoration With Neural Networks
o Paper: [Link](https://arxiv.org/pdf/1511.08861.pdf)
o Author: NVIDIA and MIT Media Lab, Hang Zhao
o Conference: 2018.04
o More material: [Link](https://github.com/NVlabs/PL4NN/blob/master/src/loss.py)
o Application: **Deep Learning for image processing**.
## Background and purpose
1. The set of all the **image processing** algorithms whose **goal is to output an image that is appealing to a human observer**.
3. 照理來說,損失函數值(loss function value)基於Mix訓練要比基於L1 norm訓練高才對,事實上卻比較低,顯然挑選一個較好的loss function作訓練是值得關注的問題。
5. 針對不同的主題,採用適合的loss function。
## Argument
- **L2 norm loss function**
1. 任務涉及觀看品質,L2 norm與人類感知相關性不高。
3. 使用L2 norm的前提,假設雜訊的影像與圖像局部特徵無關。然而,人類視覺系統(HVS)對雜訊的敏感度取決於局部的luminance, contrast, and structure. L2 norm可以實現在高斯模糊雜訊的前提上,但是此前提一般來說不成立。PSNR and L2 norm 不適合捕捉在人類視覺系統中複雜的特徵。實驗結果表明SSIM-based index效果較好。
5. 收斂性質很好:convexity , differentiable.能快速收斂,但也容易陷入local minima.
7. 應用領域: Regression, pattern recognition, signal and image processing.
9. L2 norm provides the maximum likelihood estimate in case of independent and identically distributed Gaussian noise(i.i.d), to the fact that it is additive for independent noise sources. There is longer list of reasons for which we refer the reader to the work of Wang and Bovik [16].
11. L2 norm 對big error會有較大的懲罰(error>1,loss=error^2),能容忍small error(error<1,loss=error^2),無關乎影像結構。在平坦區會抑制雜訊,但會產生偽影splotchy artifacts.
13. 邊緣的解析度會被L2 norm保留,因為模糊邊緣會導致loss function值過大。
- **L1 norm loss function**
1. L1 norm 不會過度懲罰big error(error>1) 。
3. Sub-optimal命題,得出總是次優解。收斂性質不比L2 norm好。
3. $\frac{\partial L^{l1}(p)}{\partial x(p)}=sign(x(p)-y(p))$ 當Error=0時,我們不需要更新網路權重,所以設定sign(0)=0。
5. L1 norm 可以保留color和luminance,無關乎影像結構。
- **L2→L1 and L1→L2 (訓練過程中切換不同的loss function)**
1. L2→L1: 視覺效果相較於L1→L2以及L1好,與L1效果類似。
3. L1→L2: 偽影效果,與L2效果類似。
5. 設計此實驗,主要探討收斂性質與視覺效果之間的平衡。
7. L2 norm收斂速度快,容易陷入局部最小值;L1 norm收斂速度慢,但容易找到較好的局部最小值。
<center>
<img width=65%
src=https://i.imgur.com/0N3IRno.png>
</center>
- **SSIM and MS-SSIM loss function**
<center>
$SSIM(p)=\frac{2\mu_x\mu_y+C_1}{\mu_x^2+\mu_y^2+C_1}\cdot\frac{2\sigma_{xy}+C_2}{\sigma_x^2+\sigma_y^2+C_2}=l(p)\cdot cs(p)$
$MS-SSIM(p)=l^\alpha_M(p)\cdot\prod_{j=1}^M cs^{\beta_j}_{j}(p)$
</center>
<ul>
1. 皆可微分,皆為了灰階影像的品質作設計。
2. 如果網路的目標在於學習視覺品質好的影像,應該使用感知loss function像是SSIM。
3. σ越低,在edge,有助於減少halo effect. σ越高,在平坦區,有助於減少偽影(splotchy artifacts)。
4. σ越低,網絡失去保留局部結構的能力,並且在平坦區域中重新引入斑點偽影。σ越高,網絡傾向於保留邊緣附近的噪聲。
5. SSIM和MS-SSIM對uniform biases(luminance mean)不敏感,這可能會造成亮度偏移(change of brightness)或者色度偏移(shift of colors)。
6. $l(p)$項次可測量對比度的誤差,有效降低對比度的影響當背景是亮的時候。也就是因為如此,MS-SSIM可解決edge附近的雜訊問題,但依舊無法解決偏移問題。
7. MS-SSIM保留高頻區段的特性相較於其他loss function有較好的結果。
</ul>
- **Mix : MS-SSIM +L1 norm**
<ul>
$L^{Mix}=\alpha \cdot L^{MS-SSIM}+(1-\alpha) \cdot G_{\sigma^{M}_{G}} \cdot L^{l_1}$
</ul>
1. α set to 0.84.
2. 提出方法的優勢遠大於L2 norm的收斂優勢。
3. **作者提出的方法,勝於其他損失函數。**
## Resultant
採用MSE(左下圖)以及SSIM(右下圖)之差異圖[16],**MSE比SSIM機制還差**。
<center>
<img width=55% src=https://hackmd.io/_uploads/SyPouS6po.png>
</center>
## Referenece
[16] Wang, Z., Bovik, A.: Mean squared error: Love it or leave it? A new
look at signal fidelity measures. IEEE Signal Processing Magazine 26(1)
(2009) 98–117
###### tags: `PCCE algorithm` `Oled`