104. 运动模糊退化模型
2025-08-27 本文已影响0人
大龙10
一、 模型法估计退化函数
-
估计图像复原中所用的退化函数,主要有三种方法:观察法、试验法和数学建模方法。
-
分析导致退化的原因,根据基本原理提出退化模型,如湍流导致的模糊、匀速运动导致的模糊,可以基于模型更加准确地估计退化函数。
下面以运动模糊和大气湍流模型为例,采用退化模型对图像的退化建模。
二、运动模糊退化模型
-
运动模糊是相机,物体,背景间相对运动造成的效果,通常由于长时间曝光或场景内的物体快速移动导致,在摄影中可以借助移动镜头追踪移动的物体来避免。
-
对匀速线性运动模糊建模,假设图像 f(x,y) 做平面运动,运动在 x、y 方向的时变分量分别为
。记录介质上任意点的总曝光量是瞬时曝光量的积分,可以建立运动模糊退化函数模型:
三、例程
- 9.18:运动模糊退化模型
import cv2
import numpy as np
from matplotlib import pyplot as plt
# 9.18: 运动模糊退化图像 (Motion blur degradation)
def motionBlur(image, degree=10, angle=45):
image = np.array(image)
center = (degree/2, degree/2) # 旋转中心
M = cv2.getRotationMatrix2D(center, angle, 1) # 无损旋转
kernel = np.diag(np.ones(degree) / degree) # 运动模糊内核
kernel = cv2.warpAffine(kernel, M, (degree, degree))
blurred = cv2.filter2D(image, -1, kernel) # 图像卷积
blurredNorm = np.uint8(cv2.normalize(blurred, None, 0, 255, cv2.NORM_MINMAX)) # 归一化为 [0,255]
return blurredNorm
# 运动模糊图像
img = cv2.imread(r"E:/OpenCV/Fig0507b.tif", 0) # flags=0 读取为灰度图像
imgBlur1 = motionBlur(img, degree=30, angle=45)
imgBlur2 = motionBlur(img, degree=40, angle=45)
imgBlur3 = motionBlur(img, degree=60, angle=45)
plt.figure(figsize=(9, 6))
plt.subplot(131), plt.title("degree=20"), plt.axis('off'), plt.imshow(imgBlur1, 'gray')
plt.subplot(132), plt.title("degree=40"), plt.axis('off'), plt.imshow(imgBlur2, 'gray')
plt.subplot(133), plt.title("degree=60"), plt.axis('off'), plt.imshow(imgBlur3, 'gray')
plt.tight_layout()
plt.show()
四、资料
youcans_的博客:
https://blog.csdn.net/youcans/article/details/123027195