标签:style class blog c code java
ROI的用法:1、直接相加;2、掩码法
#include <opencv2\highgui\highgui.hpp> #include <opencv2\imgproc\imgproc.hpp> #include <opencv2\core\core.hpp> int main() { cv::Mat img_original = cv::imread("F:\\images\\boldt.jpg"); cv::Mat logo = cv::imread("F:\\images\\logo.bmp"); cv::Mat imageROI = img_original(cv::Rect(385, 270, logo.cols, logo.rows)); addWeighted(imageROI, 1.0, logo, 0.3, 0.0, imageROI); cv::namedWindow("方法1:直接相加"); cv::imshow("方法1:直接相加", img_original); cv::Mat img_original2 = cv::imread("F:\\images\\boldt.jpg"); cv::Mat logo2 = cv::imread("F:\\images\\logo.bmp"); cv::Mat imageROI2 = img_original2(cv::Rect(385, 270, logo2.cols, logo2.rows)); cv::Mat mask = cv::imread("F:\\images\\logo.bmp", 0); logo2.copyTo(imageROI2, mask); cv::namedWindow("方法2:掩码法,直接替换"); cv::imshow("方法2:掩码法,直接替换", img_original2); cv::waitKey(); return 0; }
opencv学习笔记(04)——ROI,布布扣,bubuko.com
标签:style class blog c code java
原文地址:http://www.cnblogs.com/takeaction/p/3747660.html