OPENCV学习笔记1-7_定义感兴趣区域

  Sometimes, a processing function(处理函数) needs to be applied only to a portion(部分) of an image. OpenCV incorporates (内嵌)an elegant(精致) and simple mechanism(机制) to define a subregion(子区域) in an image and manipulate(操作) it as a regular image(普通图像).

  The key(关键在于) is that the ROI is indeed(实际上) a cv::Mat object that points to the same data buffer as its parent image(指向与父图像相同的数据缓冲区) and has a header that specifies the coordinates(指定坐标) of the ROI.

#include <iostream>
#include <opencv2/opencv.hpp>
using namespace cv;
int main() {
    namedWindow("YunFung Image");
    Mat image = imread("test.jpg");
    Mat logo  = imread("yunfung.png");
    // define image ROI at image top-right
    Mat imageROI(image,    Rect(image.cols - logo.cols, 0,        // ROI coordinates
                                logo.cols, logo.rows));           // ROI size
    // insert logo
    logo.copyTo(imageROI);
    // not imwrite
    imshow("YunFung Image", image);
    waitKey(0);
    return 0;
}

 

转载于:https://www.cnblogs.com/yunfung/p/7551443.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值