void Test_ROIWith2Image() { Mat g_srcImage=imread("D:\\OpenCV Projects\\OpenCV_Test_Image\\6.jpg"); Mat g_srcImagelogo=imread("D:\\OpenCV Projects\\OpenCV_Test_Image\\logo1.jpg"); //在原图上创建一个ROI区域(left,top,width,height) Mat g_roiImage=g_srcImage(Rect(100,50,g_srcImagelogo.cols,g_srcImagelogo.rows)); //以灰度存储图像 Mat g_mask=imread("D:\\OpenCV Projects\\OpenCV_Test_Image\\logo1.jpg",0); //将mask合并到ROI区域 g_srcImagelogo.copyTo(g_roiImage,g_mask); imshow("原图",g_srcImage); imshow("ROI原图",g_srcImagelogo); }
时间: 2024-10-10 02:19:39