如何替换Mat图像的矩形区域 [英] How to replace a rectangular region of Mat image
本文介绍了如何替换Mat图像的矩形区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用opencv图像处理库.我只想用另一个小图像替换原始Mat图像的矩形区域(小于原始图像).我找不到执行此操作的方向
I am working with opencv image processing library. I just want to replace rectangular region(smaller than the original image) of my original Mat image with another small image. I couldn't find a direction to do this
有人可以帮助我吗?预先感谢
Can anybody help me please. Thanks in advance
推荐答案
这是一种方法,而不是最佳方法.
Here's a way, not claiming its the best way.
Mat m = ... // your smaller mat
Mat submat= matOrig.submat(new Rect(x,y, m.cols(), m.rows()) );
m.copyTo(submat);
假设m不超出matOrig的范围,这应该可以工作.当您获得子垫时,它仍然链接到其源Mat.
That should work assuming m doesn't go out of bounds inside matOrig. When you get a submat, it is still linked to its source Mat.
这篇关于如何替换Mat图像的矩形区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文