可能重复:
了解openCV 2.4中感兴趣的区域
我想从图像(Mat格式)获得一个子图像(由下面的红框限定).我该怎么做呢?

这是我目前的进展:
include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat imgray, thresh;
vector<vector<Point> >contours;
vector<Point> cnt;
vector<Vec4i> hierarchy;
Point leftmost;
Mat im = imread("igoy1.jpg");
cvtColor(im, imgray, COLOR_BGR2GRAY);
threshold(imgray, thresh, 127, 255, 0);
findContours(thresh, contours, hierarchy, RETR_TREE,CHAIN_APPROX_SIMPLE);
}
Run Code Online (Sandbox Code Playgroud) 我想声明,填充,访问与命名空间cv兼容的OpenCV(C++)中的多维矩阵.我发现没有快速简单的例子.你能帮帮我吗?