最佳答案
为了实现这种效果,您可以将图像与线段状内核(或 PSF,点扩散函数)进行卷积,如下所示:
img = cv2.imread("Lenna.png")
psf = np.zeros((50, 50, 3))
psf = cv2.ellipse(psf,
(25, 25), # center
(22, 0), # axes -- 22 for blur length, 0 for thin PSF
15, # angle of motion in degrees
0, 360, # ful ellipse, not an arc
(1, 1, 1), # white color
thickness=-1) # filled
psf /= psf[:,:,0].sum() # normalize by sum of one channel
# since channels are processed independently
imfilt = cv2.filter2D(img, -1, psf)
为了更真实,您需要在线性域中执行模糊(即反转然后重新应用 sRGB gamma,请参阅 here ,这是另一堆蠕虫),但这个简单的代码可以为您提供以下结果:
来源:
结果:
关于python-3.x - OpenCV:如何向整个图像添加人工涂抹/运动模糊效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40817634/