opencv和C++创建Mat的方法,二维卷积kernel,通道分离

#include <opencv2\opencv.hpp>
#include <iostream>
#include <math.h>
#include <vector>

using namespace cv;
using namespace std;
int main()
{

 Mat M(2, 2, CV_8UC3, Scalar(0, 0, 255));
 cout << "M = " << endl << M << endl;
 Mat M;
 M.create(4, 4, CV_8UC(2));
 cout << "M = " << endl << M << endl;
 Mat M = (Mat_<double>(3, 3) << 0, 1, 2, 3, 4, 5, 6, 7, 8);
 cout << "M = " << endl << M << endl;
 Mat e = Mat::eye(4, 4, CV_64F);
 Mat o = Mat::ones(2, 2, CV_32F);
 Mat z = Mat::zeros(3, 3, CV_8UC1);

 system("pause");
 return 1;

}


void sharpen2D(const Mat &image, Mat &result)
{
Mat kernel(3,3,CV_32F,Scalar(0));
kernel.at<float>(1,1) = 5.0;
kernel.at<float>(0,1) = -1.0;
kernel.at<float>(2,1) = -1.0;
kernel.at<float>(1,0) = -1.0;
kernel.at<float>(1,2) = -1.0;
filter2D(image,result,image.depth(),kernel);
}

//两个图像相加
addWeighted(image,0.7,image2,0.9,0,result);
//通道分割
vector<Mat>planes;
split(image1,planes);
planes[0]

merge(planes,result);



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值