c++ opencv 基本操作
【摘要】 opencv4可以多通道计算,opencv3.4只能计算单通道图像。
Mat image1, image3; image1 = imread("D:\\zhengjian.jpg"); if (!image1.data) { return 0; } double minv = 0.0, maxv = 0.0; minMaxIdx(image1, &minv, &...
opencv4可以多通道计算,opencv3.4只能计算单通道图像。
-
Mat image1, image3;
-
image1 = imread("D:\\zhengjian.jpg");
-
if (!image1.data)
-
{
-
return 0;
-
}
-
-
double minv = 0.0, maxv = 0.0;
-
minMaxIdx(image1, &minv, &maxv);
-
-
cout << "Mat minv = " << minv << endl;
-
cout << "Mat maxv = " << maxv << endl;
-
-
-
//归一化
-
image_new = (image_new - minVal) / (maxVal - minVal)*255;
-
-
//转化类型
-
Mat dst = Mat::zeros(image_new.size(), CV_8U);
-
image_new.convertTo(dst, CV_8U);// , NULL, 0);
-
//image_new.convertTo(image_new, CV_8U, 255.0 / (maxVal - minVal), 0);
//建立空的黑图
Mat atom_image = Mat::zeros(w, w, CV_8UC3);
乘法
-
#include<opencv2/core/core.hpp>
-
#include<opencv2/highgui/highgui.hpp>
-
#include<opencv2/imgproc/imgproc.hpp>
-
#include<vector>
-
#include<iostream>
-
-
using namespace std;
-
using namespace cv;
-
-
int main()
-
{
-
Mat image1, image2, image3;
-
image1 = imread("C:\\Users\\Dell\\Desktop\\5.jpg");
-
if (!image1.data)
-
{
-
return 0;
-
}
-
image2 = imread("C:\\Users\\Dell\\Desktop\\4.jpg");
-
if (!image2.data)
-
{
-
return 0;
-
}
-
resize(image2, image3, image1.size());
-
namedWindow("Image 1");
-
imshow("Image 1", image1);
-
namedWindow("Image 3");
-
imshow("Image 3", image3);
-
Mat result;
-
image3 = image3 * 0.3;
-
image1 = image1 * 0.9;
-
add(image1, image3, result);
-
namedWindow("result");
-
imshow("result", result);
-
waitKey(0);
-
return 0;
-
}
除法:
-
Mat result1;
-
imshow("result_o", image1);
-
image1 = image1 / 2;
-
imshow("result", image1);
文章来源: blog.csdn.net,作者:网奇,版权归原作者所有,如需转载,请联系作者。
原文链接:blog.csdn.net/jacke121/article/details/110144885
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)