OpenCv图像裁剪指点区域_roi
两种方式Range和ROI
#include <opencv2/opencv.hpp> using namespace std; using namespace cv; void testrange(Mat &img) { int m = img.rows; int n = img.cols; Mat temp = img(Range(0,m*0.8), Range(0,n*0.8)); namedWindow("Range"); imshow("Range", temp); } void testroi(Mat &img) { int m = img.rows; int n = img.cols; Rect rect(0,0,n*0.8, m*0.8); Mat temp(img, rect); namedWindow("roi"); imshow("roi", temp); } void main() { Mat img = imread("lena.jpg",0); namedWindow("src"); imshow("src", img); testroi(img); testrange(img); waitKey(0); }