在 OpenCV 中显示时叠加图像
我有两个图像,我想将它们显示在彼此之上。第一个图像是单通道图像,第二个图像是 RGB 图像,但大部分区域是透明的。
这两个图像是如何在不同的函数中生成的。我知道只是将它们显示在彼此之上,我可以在调用 cvShowImage()
时使用相同的窗口名称,但是当它们是从不同的函数绘制时,这不起作用。尝试此操作时,我使用 cvCvtcolor()
将二进制图像从单通道转换为 RGB,然后显示来自另一个函数的第二个图像。但这没有用。两个图像具有相同的尺寸、深度和通道数(转换后)。
我想避免将一张图像传递到第二个函数中,然后绘制它们。所以我正在寻找一种快速的肮脏技巧来重叠显示这两个图像。
谢谢
编辑:
I have two images that I want to display on top of each other. one image a single channel image and the second image is a RGB image but with most of the area being transparent.
How these two images are generated in different functions. I know to just display these on top of each other, i can use the same window name when calling cvShowImage()
but this doesn't work when they are drawn from different functions. When trying this, I used cvCvtcolor()
to convert he binary image from single channel to RGB and then displaying the second image from another function. But this didn't work. Both images are same dimension, depth and number of channels (after conversion).
I want to avoid passing in one image into the second function and then draw them. So I'm looking for a quick dirty trick to display these two images overlapped.
Thank you
EDIT:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为这是不可能的。您必须创建一个新图像或修改现有图像。这里有一篇文章展示了如何执行此操作: 透明图像叠加OpenCV
I don't think that's possible. You'll have to create a new image or modify an existing one. Here's an article that shows how to do this: Transparent image overlays in OpenCV
无法“覆盖”图像。
cvShowImage()
显示内存中的单个图像。您需要将它们混合/组合在一起。有几种方法可以做到这一点。您可以将一个通道复制到另一个通道的 1 或 2 个通道中,可以使用 AND、OR 或 XOR 等逻辑运算,可以使用 Add、Multiply 和 MultiplyScale 等算术运算(这些运算将使大于 255 的值饱和)。所有这些也可以通过可选的遮罩图像(例如斑点图像)来完成。
当然,您可能希望在第三个缓冲区中执行此操作,以免覆盖原始缓冲区。
There is no way to "overlay" images.
cvShowImage()
displays a single image from memory. You'll need to blend/combine them together. There are several ways to do this.You can copy one into 1 or 2 channels of the other, you can use logical operations like AND, OR or XOR, you can use arithmetic operations like Add, Multiply and MultiplyScale (these operations will saturate values larger than 255). All these can also be done with an optional mask image like your blob image.
Naturally, you may want to do this into a third buffer so as not to overwrite your originals.
显然现在可以使用 OpenCV 2.1 版本来完成
http://opencv.willowgarage.com/documentation/cpp/highgui_qt_new_functions.html #cv-displayoverlay
Apparently now it can be done using OpenCV 2.1 version
http://opencv.willowgarage.com/documentation/cpp/highgui_qt_new_functions.html#cv-displayoverlay