0

我想模拟逼真的运动模糊。我不想在整个图像中产生模糊效果,而只想在移动的物体上产生模糊效果。我知道我可以使用滤镜,但是模糊效果会扩散到整个图像中。我想使用光流,但我不确定它是否会起作用,因为结果很大程度上取决于提取的特征。

我的主要想法是组合连续帧以产生运动模糊。

谢谢

4

2 回答 2

2

没那么容易。

您确实可以尝试使用光流。估计每对帧之间的流量。模糊运动方向的帧(例如各向异性高斯),过滤器范围与位移等效。最后,通过形成一个加权平均来混合模糊图像和背景,其中每帧移动得越多,权重就越大。

于 2018-09-13T15:20:02.207 回答
0

您需要为对象设置 [0,1] alpha 蒙版。然后,您可以使用定向过滤器来模糊对象及其蒙版,例如,如下所示: https ://www.packtpub.com/mapt/book/application_development/9781785283932/2/ch02lvl1sec21/motion-blur

然后使用模糊蒙版将模糊对象 alpha 混合回原始未模糊或其他场景:

 #Blend the alpha_mask region of the foreground over the image background
 #fg is foreground, alpha_mask is a [0,255] mask, image is background scene
    foreground = fg.astype(float)
    background = image.astype(float)
    #Normalize alpha_mask
    alpha = alpha_mask.astype(float) / 255
    # Multiply the foreground with the alpha_mask
    foreground = cv2.multiply(alpha, foreground)
    # Multiply the background with ( 1 - alpha )
    background = cv2.multiply(1.0 - alpha, background)
    # Add the masked foreground and background, turn back to byte image
    composit_image = cv2.add(foreground, background).astype(np.uint8)
于 2018-11-12T21:52:16.000 回答