遮罩/将指定 ROI 之外的区域归零

发布于 2024-09-11 18:43:28 字数 121 浏览 1 评论 0原文

我正在开发一个使用 OpenCV 进行模板匹配的项目,并且我想限制图像上的搜索区域。图像是从相机连续捕获的。

有没有办法对定义的 ROI 之外的图像进行归零/屏蔽,以便模板匹配过程可以针对剩余区域,更快、更准确?

I'm working on a project using OpenCV on template matching, and I want to limit the search region on an image. Image is captured continuously from a camera.

Is there any way to Zero / mask out image outside ROI defined, so that template matching process can be specific on remaining region, faster and accurate?

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

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

发布评论

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

评论(2

过度放纵 2024-09-18 18:43:28

看一下 cvSetImageROI 函数。

void cvSetImageROI(IplImage* 图像,
CvRect 矩形)

为给定矩形设置图像感兴趣区域 (ROI)。
参数:

  • image – 指向图像标题的指针
  • 矩形 - ROI 矩形

如果原始图像 ROI 为 NULL 并且
矩形不是整个图像,
ROI结构已分配。

大多数OpenCV函数都支持使用
ROI 并处理图像矩形
作为单独的图像。例如,所有
计算像素坐标的
从左上角(或左下角)
ROI 的一角,而不是原始的
图片。

Take a look at the cvSetImageROI function.

void cvSetImageROI(IplImage* image,
CvRect rect)

Sets an image Region Of Interest (ROI) for a given rectangle.
Parameters:

  • image – A pointer to the image header
  • rect – The ROI rectangle

If the original image ROI was NULL and
the rect is not the whole image, the
ROI structure is allocated.

Most OpenCV functions support the use
of ROI and treat the image rectangle
as a separate image. For example, all
of the pixel coordinates are counted
from the top-left (or bottom-left)
corner of the ROI, not the original
image.

梦冥 2024-09-18 18:43:28

您可以使用 cvSetImageROI 来设置感兴趣的区域。模板匹配函数仅使用您设置的 ROI(并忽略其之外的任何内容)

You use cvSetImageROI to set the region of interest. The template matching functions use only the ROI you set (and ignore whatever is outside it)

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