C ++将图像放在特定位置的另一个图像上 [英] C++ Place an image on top of another image in a certain location

查看:182
本文介绍了C ++将图像放在特定位置的另一个图像上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法将图像放置在设定位置的另一张图像上。

I'm looking for a way to place on image on top of another image at a set location.

我已经能够将图像放在每个图像的顶部其他使用 cv :: addWeighted 但是当我搜索这个特定问题时,我找不到任何与 C ++

I have been able to place images on top of each other using cv::addWeighted but when I searched for this particular problem, there wasn't any posts that I could find relating to C++.

快速示例:

200x200 红场& 100x100 蓝色方块

200x200 Red Square & 100x100 Blue Square

&

红场的蓝色广场 70x70 (从左上角Pixel of蓝色广场)

Blue Square on the Red Square at 70x70 (From top left corner Pixel of Blue Square)

推荐答案

您还可以创建指向原始图像的矩形区域的Mat并将蓝色图像复制到该区域:

You can also create a Mat that points to a rectangular region of the original image and copy the blue image to that:

Mat bigImage = imread("redSquare.png", -1);
Mat lilImage = imread("blueSquare.png", -1);

Mat insetImage(bigImage, Rect(70, 70, 100, 100));
lilImage.copyTo(insetImage);

imshow("Overlay Image", bigImage);

这篇关于C ++将图像放在特定位置的另一个图像上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆