【youcans 的 OpenCV 例程 200 篇】105. 湍流模糊退化模型
歡迎關注 『youcans 的 OpenCV 例程 200 篇』 系列,持續更新中
歡迎關注 『youcans 的 OpenCV學習課』 系列,持續更新中
【youcans 的 OpenCV 例程 200 篇】105. 湍流模糊退化模型
5.3 模型法估計退化函數
估計圖像復原中所用的退化函數,主要有三種方法:觀察法、試驗法和數學建模方法。
分析導致退化的原因,根據基本原理提出退化模型,如湍流導致的模糊、勻速運動導致的模糊,可以基于模型更加準確地估計退化函數。
下面以運動模糊和大氣湍流模型為例,采用退化模型對圖像的退化建模。
例程 9.19:湍流模糊退化模型
湍流是自然界中普遍存在的一種復雜的流動現象。物體通過湍流大氣成像時,受到湍流效應的影響,出現光強閃爍、光束方向漂移、光束寬度擴展及接收面上相位的起伏,造成圖像模糊和抖動,甚至扭曲變形。
Hufnagel and Stanley 根據大氣湍流的物理特性提出一種退化模型:
H(u,v)=e?k(u2+v2)5/6H(u,v) = e^{-k (u^2+v^2)^{5/6}} H(u,v)=e?k(u2+v2)5/6
k 是湍流常數,反映湍流的強烈程度。
# 9.19: 湍流模糊退化模型 (turbulence blur degradation model)def getDegradedImg(image, Huv): # 根據退化模型生成退化圖像rows, cols = image.shape[:2] # 圖片的高度和寬度# (1) 中心化, centralized 2d array f(x,y) * (-1)^(x+y)mask = np.ones((rows, cols))mask[1::2, ::2] = -1mask[::2, 1::2] = -1imageCen = image * mask# (2) 快速傅里葉變換dftImage = np.zeros((rows, cols, 2), np.float32)dftImage[:, :, 0] = imageCencv2.dft(dftImage, dftImage, cv2.DFT_COMPLEX_OUTPUT) # 快速傅里葉變換 (rows, cols, 2)# (4) 構建 頻域濾波器傳遞函數:Filter = np.zeros((rows, cols, 2), np.float32) # (rows, cols, 2)Filter[:, :, 0], Filter[:, :, 1] = Huv, Huv# (5) 在頻率域修改傅里葉變換: 傅里葉變換 點乘 濾波器傳遞函數dftFilter = dftImage * Filter# (6) 對修正傅里葉變換 進行傅里葉逆變換,并只取實部idft = np.ones((rows, cols), np.float32) # 快速傅里葉變換的尺寸cv2.dft(dftFilter, idft, cv2.DFT_REAL_OUTPUT + cv2.DFT_INVERSE + cv2.DFT_SCALE) # 只取實部# (7) 中心化, centralized 2d array g(x,y) * (-1)^(x+y)mask2 = np.ones(dftImage.shape[:2])mask2[1::2, ::2] = -1mask2[::2, 1::2] = -1idftCen = idft * mask2 # g(x,y) * (-1)^(x+y)# (8) 截取左上角,大小和輸入圖像相等imgDegraded = np.uint8(cv2.normalize(idftCen, None, 0, 255, cv2.NORM_MINMAX)) # 歸一化為 [0,255]# print(image.shape, dftFilter.shape, imgDegraded.shape)return imgDegradeddef turbulenceBlur(img, k=0.001): # 湍流模糊傳遞函數# H(u,v) = exp(-k(u^2+v^2)^5/6)M, N = img.shape[1], img.shape[0]u, v = np.meshgrid(np.arange(M), np.arange(N))radius = (u - M//2)**2 + (v - N//2)**2kernel = np.exp(-k * np.power(radius, 5/6))return kernel# 讀取原始圖像img = cv2.imread("../images/Fig0525a.tif", 0) # flags=0 讀取為灰度圖像# 生成湍流模糊圖像HBlur1 = turbulenceBlur(img, k=0.001) # 湍流模糊傳遞函數imgBlur1 = getDegradedImg(img, HBlur1) # 生成湍流模糊圖像HBlur2 = turbulenceBlur(img, k=0.0025)imgBlur2 = getDegradedImg(img, HBlur2)plt.figure(figsize=(9, 6))plt.subplot(131), plt.title("origin"), plt.axis('off'), plt.imshow(img, 'gray')plt.subplot(132), plt.title("turbulence blur(k=0.001)"), plt.axis('off'), plt.imshow(imgBlur1, 'gray')plt.subplot(133), plt.title("turbulence blur(k=0.0025)"), plt.axis('off'), plt.imshow(imgBlur2, 'gray')plt.tight_layout()plt.show()(本節完)
版權聲明:
youcans@xupt 原創作品,轉載必須標注原文鏈接:(https://blog.csdn.net/youcans/article/details/123027287)
Copyright 2022 youcans, XUPT
Crated:2022-2-15
歡迎關注 『youcans 的 OpenCV 例程 200 篇』 系列,持續更新中
歡迎關注 『youcans 的 OpenCV學習課』 系列,持續更新中
【youcans 的 OpenCV 例程200篇】01. 圖像的讀取(cv2.imread)
【youcans 的 OpenCV 例程200篇】02. 圖像的保存(cv2.imwrite)
【youcans 的 OpenCV 例程200篇】03. 圖像的顯示(cv2.imshow)
【youcans 的 OpenCV 例程200篇】04. 用 matplotlib 顯示圖像(plt.imshow)
【youcans 的 OpenCV 例程200篇】05. 圖像的屬性(np.shape)
【youcans 的 OpenCV 例程200篇】06. 像素的編輯(img.itemset)
【youcans 的 OpenCV 例程200篇】07. 圖像的創建(np.zeros)
【youcans 的 OpenCV 例程200篇】08. 圖像的復制(np.copy)
【youcans 的 OpenCV 例程200篇】09. 圖像的裁剪(cv2.selectROI)
【youcans 的 OpenCV 例程200篇】10. 圖像的拼接(np.hstack)
【youcans 的 OpenCV 例程200篇】11. 圖像通道的拆分(cv2.split)
【youcans 的 OpenCV 例程200篇】12. 圖像通道的合并(cv2.merge)
【youcans 的 OpenCV 例程200篇】13. 圖像的加法運算(cv2.add)
【youcans 的 OpenCV 例程200篇】14. 圖像與標量相加(cv2.add)
【youcans 的 OpenCV 例程200篇】15. 圖像的加權加法(cv2.addWeight)
【youcans 的 OpenCV 例程200篇】16. 不同尺寸的圖像加法
【youcans 的 OpenCV 例程200篇】17. 兩張圖像的漸變切換
【youcans 的 OpenCV 例程200篇】18. 圖像的掩模加法
【youcans 的 OpenCV 例程200篇】19. 圖像的圓形遮罩
【youcans 的 OpenCV 例程200篇】20. 圖像的按位運算
【youcans 的 OpenCV 例程200篇】21. 圖像的疊加
【youcans 的 OpenCV 例程200篇】22. 圖像添加非中文文字
【youcans 的 OpenCV 例程200篇】23. 圖像添加中文文字
【youcans 的 OpenCV 例程200篇】24. 圖像的仿射變換
【youcans 的 OpenCV 例程200篇】25. 圖像的平移
【youcans 的 OpenCV 例程200篇】26. 圖像的旋轉(以原點為中心)
【youcans 的 OpenCV 例程200篇】27. 圖像的旋轉(以任意點為中心)
【youcans 的 OpenCV 例程200篇】28. 圖像的旋轉(直角旋轉)
【youcans 的 OpenCV 例程200篇】29. 圖像的翻轉(cv2.flip)
【youcans 的 OpenCV 例程200篇】30. 圖像的縮放(cv2.resize)
【youcans 的 OpenCV 例程200篇】31. 圖像金字塔(cv2.pyrDown)
【youcans 的 OpenCV 例程200篇】32. 圖像的扭變(錯切)
【youcans 的 OpenCV 例程200篇】33. 圖像的復合變換
【youcans 的 OpenCV 例程200篇】34. 圖像的投影變換
【youcans 的 OpenCV 例程200篇】35. 圖像的投影變換(邊界填充)
【youcans 的 OpenCV 例程200篇】36. 直角坐標與極坐標的轉換
【youcans 的 OpenCV 例程200篇】37. 圖像的灰度化處理和二值化處理
【youcans 的 OpenCV 例程200篇】38. 圖像的反色變換(圖像反轉)
【youcans 的 OpenCV 例程200篇】39. 圖像灰度的線性變換
【youcans 的 OpenCV 例程200篇】40. 圖像分段線性灰度變換
【youcans 的 OpenCV 例程200篇】41. 圖像的灰度變換(灰度級分層)
【youcans 的 OpenCV 例程200篇】42. 圖像的灰度變換(比特平面分層)
【youcans 的 OpenCV 例程200篇】43. 圖像的灰度變換(對數變換)
【youcans 的 OpenCV 例程200篇】44. 圖像的灰度變換(伽馬變換)
【youcans 的 OpenCV 例程200篇】45. 圖像的灰度直方圖
【youcans 的 OpenCV 例程200篇】46. 直方圖均衡化
【youcans 的 OpenCV 例程200篇】47. 圖像增強—直方圖匹配
【youcans 的 OpenCV 例程200篇】48. 圖像增強—彩色直方圖匹配
【youcans 的 OpenCV 例程200篇】49. 圖像增強—局部直方圖處理
【youcans 的 OpenCV 例程200篇】50. 圖像增強—直方圖統計量圖像增強
【youcans 的 OpenCV 例程200篇】51. 圖像增強—直方圖反向追蹤
【youcans 的 OpenCV 例程200篇】52. 圖像的相關與卷積運算
【youcans 的 OpenCV 例程200篇】53. Scipy 實現圖像二維卷積
【youcans 的 OpenCV 例程200篇】54. OpenCV 實現圖像二維卷積
【youcans 的 OpenCV 例程200篇】55. 可分離卷積核
【youcans 的 OpenCV 例程200篇】56. 低通盒式濾波器
【youcans 的 OpenCV 例程200篇】57. 低通高斯濾波器
【youcans 的 OpenCV 例程200篇】58. 非線性濾波—中值濾波
【youcans 的 OpenCV 例程200篇】59. 非線性濾波—雙邊濾波
【youcans 的 OpenCV 例程200篇】60. 非線性濾波—聯合雙邊濾波
【youcans 的 OpenCV 例程200篇】61. 導向濾波(Guided filter)
【youcans 的 OpenCV 例程200篇】62. 圖像銳化——鈍化掩蔽
【youcans 的 OpenCV 例程200篇】63. 圖像銳化——Laplacian 算子
【youcans 的 OpenCV 例程200篇】64. 圖像銳化——Sobel 算子
【youcans 的 OpenCV 例程200篇】65. 圖像銳化——Scharr 算子
【youcans 的 OpenCV 例程200篇】66. 圖像濾波之低通/高通/帶阻/帶通
【youcans 的 OpenCV 例程200篇】67. 空間域圖像增強的綜合應用
【youcans 的 OpenCV 例程200篇】68. 空間域圖像增強的綜合應用
【youcans 的 OpenCV 例程200篇】69. 連續非周期信號的傅立葉系數
【youcans 的 OpenCV 例程200篇】70. 一維連續函數的傅里葉變換
【youcans 的 OpenCV 例程200篇】71. 連續函數的取樣
【youcans 的 OpenCV 例程200篇】72. 一維離散傅里葉變換
【youcans 的 OpenCV 例程200篇】73. 二維連續傅里葉變換
【youcans 的 OpenCV 例程200篇】74. 圖像的抗混疊
【youcans 的 OpenCV 例程200篇】75. Numpy 實現圖像傅里葉變換
【youcans 的 OpenCV 例程200篇】76. OpenCV 實現圖像傅里葉變換
【youcans 的 OpenCV 例程200篇】77. OpenCV 實現快速傅里葉變換
【youcans 的 OpenCV 例程200篇】78. 頻率域圖像濾波基礎
【youcans 的 OpenCV 例程200篇】79. 頻率域圖像濾波的基本步驟
【youcans 的 OpenCV 例程200篇】80. 頻率域圖像濾波詳細步驟
【youcans 的 OpenCV 例程200篇】81. 頻率域高斯低通濾波器
【youcans 的 OpenCV 例程200篇】82. 頻率域巴特沃斯低通濾波器
【youcans 的 OpenCV 例程200篇】83. 頻率域低通濾波:印刷文本字符修復
【youcans 的 OpenCV 例程200篇】84. 由低通濾波器得到高通濾波器
【youcans 的 OpenCV 例程200篇】85. 頻率域高通濾波器的應用
【youcans 的 OpenCV 例程200篇】86. 頻率域濾波應用:指紋圖像處理
【youcans 的 OpenCV 例程200篇】87. 頻率域鈍化掩蔽
【youcans 的 OpenCV 例程200篇】88. 頻率域拉普拉斯高通濾波
【youcans 的 OpenCV 例程200篇】89. 帶阻濾波器的傳遞函數
【youcans 的 OpenCV 例程200篇】90. 頻率域陷波濾波器
【youcans 的 OpenCV 例程200篇】91. 高斯噪聲、瑞利噪聲、愛爾蘭噪聲
【youcans 的 OpenCV 例程200篇】92. 指數噪聲、均勻噪聲、椒鹽噪聲
【youcans 的 OpenCV 例程200篇】93. 噪聲模型的直方圖
【youcans 的 OpenCV 例程200篇】94. 算術平均濾波器
【youcans 的 OpenCV 例程200篇】95. 幾何均值濾波器
【youcans 的 OpenCV 例程200篇】96. 諧波平均濾波器
【youcans 的 OpenCV 例程200篇】97. 反諧波平均濾波器
【youcans 的 OpenCV 例程200篇】98. 統計排序濾波器
【youcans 的 OpenCV 例程200篇】99. 修正阿爾法均值濾波器
【youcans 的 OpenCV 例程200篇】100. 自適應局部降噪濾波器
【youcans 的 OpenCV 例程200篇】101. 自適應中值濾波器
【youcans 的 OpenCV 例程200篇】102. 陷波帶阻濾波器的傳遞函數
【youcans 的 OpenCV 例程200篇】103. 陷波帶阻濾波器消除周期噪聲干擾
【youcans 的 OpenCV 例程200篇】104. 運動模糊退化模型
【youcans 的 OpenCV 例程200篇】105. 湍流模糊退化模型
總結
以上是生活随笔為你收集整理的【youcans 的 OpenCV 例程 200 篇】105. 湍流模糊退化模型的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 隐式形状模型
- 下一篇: 孕妇能长期在计算机屏幕前工作吗,怀孕了在