ROI是
图像的感兴趣区域
在边缘和轮廓提取中有很重要的作用,往往可以大幅缩短运算时间。
中文网站上大多都是c程序,opencv c++ interface没有了
cvSetImageROI 这样的函数
这里总结一下。
使用ROI的流程如下
-> Load image
-> SetImageRoi
-> Do some processing on ROI region
-> Reset ROI
-> Do some operation on entire image
用c++写的话
// Load image
cv::Mat image = cv::imread("image_filname");
// SetImageRoi
cv::Rect roi(x, y, width, height);
cv::Mat image_roi = image(roi);
// note: this assignment does not copy data
// image and image_roi now share data
// Do some processing on ROI region
process(image_roi);
// any changes to image_roi will also be in image
// Reset ROI
// -- nothing required
// Do some operation on entire image
operations(image);