如何组合许多连续的图像来模拟逼真的运动模糊?
How to combine many successive image to simulate a realistic motion blurring?
我想模拟逼真的运动模糊。我不想在整个图像中产生模糊效果,而只想在移动的物体上产生模糊效果。我知道我可以使用滤镜,但模糊效果会在整个图像中传播。我想使用光流,但我不确定它是否会起作用,因为结果在很大程度上取决于提取的特征。
我的主要想法是组合连续帧以生成运动模糊。
谢谢
没那么容易。
您确实可以尝试使用光流。估计每对帧之间的流量。在运动方向上模糊帧(例如各向异性高斯(,滤镜范围等效于位移。最后,通过形成加权平均值来混合模糊的图像和背景,其中每一帧在移动更多的地方都会获得更多权重。
你需要为对象提供一个 [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)
相关文章:
- 如何使用Google Mock来模拟gettimeofday()
- G锁定铸造到基础上会释放模拟行为
- 在决定是通过参考还是通过价值时,尺寸真的是一个问题吗
- 有什么好的方法可以让系统调用代理允许在单元测试中进行模拟
- 落砂模拟碰撞检测C++和SFML
- 在gtest.中使用fff.h模拟系统API
- 谷歌模拟和覆盖关键字
- 用C#中的并集模拟C++嵌套结构
- 在同一模拟中使用静脉和静脉_ inet内容时出现运行时错误
- 在模拟器中使用并集来模拟CPU寄存器有多合适
- 我写了一个C++程序来模拟Enigma机器.我没有得到输出
- 字节真的是最小可寻址单元吗
- 如果我真的真的想从 STL 容器继承,并且我继承构造函数并删除新运算符,会发生什么?
- 如何在 std::vector 中找到<bool>哪些索引是真的?
- std::string 的对象真的可以移动吗?
- 如何模拟不同边数的骰子滚动?
- 在这种情况下,我真的复制了字节还是复制了字符?
- 模拟持久按键
- 使用SIR模型的疾病爆发模拟
- 在 c++ 中模拟输入并在 JAVA 中读取它?