完整搜尋頁面 →

以區域直方圖統計量增強影像

選讀・IP 03・強度轉換與空間濾波 的補充資料(第 3/5 則)。主線不依賴這則補充;引用編號對應本頁底部的參考文獻。

導覽:本頁與本系列: 導覽:本頁與本系列

直方圖是一個分布,因此可以用動差(moment)來描述它。令 p(rk)p(r_k) 為正規化直方圖,平均與變異數為

m=∑k=0L−1rk p(rk),σ2=∑k=0L−1(rk−m)2 p(rk),m = \sum_{k=0}^{L-1} r_k\, p(r_k), \qquad \sigma^2 = \sum_{k=0}^{L-1} (r_k - m)^2\, p(r_k),

其中 mm 衡量平均亮度,σ\sigma(標準差)衡量對比。若改在以 (x,y)(x, y) 為中心的鄰域 SxyS_{xy} 上計算,就得到區域平均 mSxym_{S_{xy}} 與區域標準差 σSxy\sigma_{S_{xy}}。

這給了我們一條簡單又有針對性的增強規則。假設只想增強偏暗、而且有一些但不太多對比的區域(同時跳過平坦背景與強烈邊緣)。令全域平均為 mGm_G、全域標準差為 σG\sigma_G,只有在下列條件成立時,才把像素乘上增益 E>1E > 1,否則保持不變:

mSxy≤k0 mG且k1 σG≤σSxy≤k2 σG,m_{S_{xy}} \le k_0\, m_G \quad \text{且} \quad k_1\, \sigma_G \le \sigma_{S_{xy}} \le k_2\, \sigma_G ,

其中 k0,k1,k2k_0, k_1, k_2 是使用者選定的比例(例如 0.5,0.02,0.50.5, 0.02, 0.5)。區域統計量只需要兩次方框濾波,一次作用在 II、一次作用在 I2I^2,再利用 σ2=E[I2]−(E[I])2\sigma^2 = \mathbb{E}[I^2] - (\mathbb{E}[I])^2:

程式碼 · Python · 10 行
import numpy as np
from scipy.ndimage import uniform_filter
from skimage import data, img_as_float

f = img_as_float(data.moon())
m = uniform_filter(f, size=3)                                     # local mean
sd = np.sqrt(np.maximum(uniform_filter(f**2, size=3) - m**2, 0))  # local std
mG, sG = f.mean(), f.std()
mask = (m <= 0.5 * mG) & (sd >= 0.02 * sG) & (sd <= 0.5 * sG)
g = np.where(mask, np.clip(3.0 * f, 0, 1), f)                     # gain E = 3

同樣「用方框濾波器求區域平均與區域變異數」的模式,也出現在導引濾波器(guided filter)[8] 中(見下一則筆記),它是「現代觀點」會談到的保邊濾波器之一。

參考文獻

  1. R. C. Gonzalez and R. E. Woods, Digital Image Processing, 4th ed., Pearson, 2018, Ch. 3. publisher page
  2. S. M. Pizer, E. P. Amburn, J. D. Austin, R. Cromartie, A. Geselowitz, T. Greer, B. ter Haar Romeny, J. B. Zimmerman and K. Zuiderveld, “Adaptive histogram equalization and its variations,” Computer Vision, Graphics, and Image Processing, 1987. doi
  3. K. Zuiderveld, “Contrast limited adaptive histogram equalization,” in P. S. Heckbert (ed.), Graphics Gems IV, Morgan Kaufmann, 1994, pp. 474–485. entry
  4. A. M. Reza, “Realization of the contrast limited adaptive histogram equalization (CLAHE) for real-time image enhancement,” Journal of VLSI Signal Processing, 2004. doi
  5. D. Coltuc, P. Bolon and J.-M. Chassery, “Exact histogram specification,” IEEE Transactions on Image Processing, 2006. doi
  6. C. Tomasi and R. Manduchi, “Bilateral filtering for gray and color images,” in Proc. IEEE International Conference on Computer Vision (ICCV), 1998. pdf
  7. S. Paris, P. Kornprobst, J. Tumblin and F. Durand, “Bilateral filtering: Theory and applications,” Foundations and Trends in Computer Graphics and Vision, vol. 4, no. 1, pp. 1–73, 2009. doi
  8. K. He, J. Sun and X. Tang, “Guided image filtering,” IEEE Transactions on Pattern Analysis and Machine Intelligence, 35(6):1397–1409, 2013 (first presented at ECCV 2010). doi
  9. P. Milanfar, “A tour of modern image filtering,” IEEE Signal Processing Magazine, vol. 30, no. 1, pp. 106–128, 2013. IEEE Xplore
  10. S. Gingichashvili and D. Lischinski, “Evaluation and comparison of edge-preserving filters,” arXiv:2012.13778, 2020. arXiv
  11. Y. Qi, Z. Yang, W. Sun et al., “A comprehensive overview of image enhancement techniques,” Archives of Computational Methods in Engineering, 2021. doi
  12. C. Li, C. Guo, L. Han, J. Jiang, M.-M. Cheng, J. Gu and C. C. Loy, “Low-light image and video enhancement using deep learning: A survey,” IEEE Transactions on Pattern Analysis and Machine Intelligence, 2021 (arXiv:2104.10729). arXiv
  13. C. Guo, C. Li, J. Guo, C. C. Loy, J. Hou, S. Kwong and R. Cong, “Zero-reference deep curve estimation for low-light image enhancement,” in Proc. IEEE/CVF CVPR, 2020. arXiv
  14. H. Zeng, J. Cai, L. Li, Z. Cao and L. Zhang, “Learning image-adaptive 3D lookup tables for high performance photo enhancement in real-time,” IEEE Transactions on Pattern Analysis and Machine Intelligence, 2020. arXiv
  15. M. Gharbi, J. Chen, J. T. Barron, S. W. Hasinoff and F. Durand, “Deep bilateral learning for real-time image enhancement,” ACM Transactions on Graphics (SIGGRAPH), 2017. arXiv
  16. H. Wu, S. Zheng, J. Zhang and K. Huang, “Fast end-to-end trainable guided filter,” in Proc. IEEE/CVF CVPR, 2018. arXiv
  17. Y. Cai, H. Bian, J. Lin, H. Wang, R. Timofte and Y. Zhang, “Retinexformer: One-stage Retinex-based transformer for low-light image enhancement,” in Proc. IEEE/CVF ICCV, 2023. arXiv
  18. S. Paris and F. Durand, “A fast approximation of the bilateral filter using a signal processing approach,” International Journal of Computer Vision, vol. 81, no. 1, pp. 24–52, 2009 (first presented at ECCV 2006). doi