Rect函数参数列表如下:

Rect(int _x,int _y,int _width,int _height);

int_x和int_y: 代表左上角点的坐标。

int_width和int_height:代表需要裁剪区域的尺寸 。

#include "opencv.hpp"
using namespace std;
using namespace cv;
int main()
{
	Mat image = imread("Lena.png");
	imshow("cLena.png", image);
	Rect rect(10, 10, 150, 100);   //区域的左上角点的坐标为(10,10)
	                               //区域宽为150,高为100
	Mat image_ori = image(rect);
	namedWindow("结果", 1);
	imshow("结果",image_ori);
	waitKey(0);
    return 0;
}

运行结果:

Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐