在 OpenCV 中显示时叠加图像

发布于 2024-10-10 15:15:43 字数 418 浏览 6 评论 0原文

我有两个图像,我想将它们显示在彼此之上。第一个图像是单通道图像,第二个图像是 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:
alt text

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我爱人 2024-10-17 15:15:43

我认为这是不可能的。您必须创建一个新图像或修改现有图像。这里有一篇文章展示了如何执行此操作: 透明图像叠加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

尸血腥色 2024-10-17 15:15:43

无法“覆盖”图像。 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文