感兴趣的区域opencv python [英] Region of Interest opencv python

查看:552
本文介绍了感兴趣的区域opencv python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用opencv python获取图像区域(ROI)。使用的opencv版本是2.4.3。但是,当我尝试调用API

I am trying to get a region of an image (ROI) using opencv python. THe version of opencv used is 2.4.3. However when I try to call the API

cv2.SetImageROI

它返回错误

AttributeError: 'module' object has no attribute 'SetImageROI'

此外,在检查文档时,似乎建议这个api是遗留的python函数。
http://docs.opencv.org/2.4.3 /search.html?q=setimageroi

Also on checking the documentation it seems to suggest this api is a legacy python function. http://docs.opencv.org/2.4.3/search.html?q=setimageroi

我不知道如何在python中使用当前版本的opencv获取ROI。有人可以建议如何解决这个问题吗?

I am not sure how to go about getting the ROI using this current version of opencv in python. Could some one please suggest how to go about this?

谢谢

推荐答案

好的,进一步的分析认识到cv2因为它一直支持numpy数组结构,所以不再需要一个API,整个图像可以在数组本身中进行操作。
例如:

Okay, On further analysis realized that the cv2 since it has been supporting numpy array structure, there is no longer any need for a API, the entire image can be manipulated in the array itself. eg:

img = cv2.imread('image.png')
img = img[c1:c1+25,r1:r1+25]

这里c1是左侧列像素位置,r1是对应的行位置。 img现在将像素中指定的图像作为ROI。

Here c1 is the left side column pixel location, and r1 is the corresponding row location. And img now has the image specified within the pixels as the ROI.

编辑:
这里非常好地解释,如何在python中使用opencv复制图像区域?

这篇关于感兴趣的区域opencv python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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