//两幅图像的像素比较
#include <stdio.h>
#include <iostream>
#include <string>
#include <opencv2\opencv.hpp>
using namespace std;
using namespace cv;
int main()
{
//system("color F0");//改变输出界面的颜色,白色
Mat word_img = cv::imread("word.jpeg");
Mat people_img = cv::imread("picture.jpeg");
Mat result;
int people_img_row = people_img.rows;
int people_img_col = people_img.cols;
cout << "rows" << people_img_row << endl;
cout << "cols" << people_img_col << endl;
resize(word_img, result, people_img.size());//使得两张图像的尺寸大小一致
cv::imwrite("word.jpeg", word_img);//保存图片
//合并图片
cv::min(result, people_img, result);//保留最小值,由于文字图片除了文字都是白色(高像素值),所以可以保留小黄人图片,同时小黄人背景为白色,可以保留文字
namedWindow("people", WINDOW_NORMAL);
namedWindow("word", WINDOW_NORMAL);
namedWindow("word_result", WINDOW_NORMAL);
imshow("people", word_img);
imshow("word", people_img);
imshow("word_result", result);
waitKey(0);
return 0;
}
两幅图像的像素比较
最新推荐文章于 2024-05-11 09:41:07 发布