1.API和相关知识
1. rectangele 绘制矩形
void QuickDemo::bitwise_demo(Mat& image) {
Mat m1 = Mat::zeros(Size(256, 256), CV_8UC3);
Mat m2 = Mat::zeros(Size(256, 256), CV_8UC3);
//rectangle有两种传参方式,这里分别进行了示范
rectangle(m1, Point(100, 100), Point(180, 180), Scalar(255, 255, 0), -1, LINE_8,0);
rectangle(m2, Rect(150, 150, 80, 80), Scalar(0, 255, 255), -1, LINE_8, 0);
imshow("m1", m1);
imshow("m2", m2);
}
2.位运算
在opencv中,图像的为运算有4种
- 与
- 或
- 非
- 异或
2.实例代码
void QuickDemo::bitwise_demo(Mat& image) {
Mat m1 = Mat::zeros(Size(256, 256), CV_8UC3);
Mat m2 = Mat::zeros(Size(256, 256), CV_8UC3);
rectangle(m1, Point(100, 100), Point(180, 180), Scalar(255, 255, 0), -1, LINE_4,0);
rectangle(m2, Rect(150, 150, 80, 80), Scalar(0, 255, 255), -1, 0);
Mat dst;
bitwise_and(m1, m2, dst);
//bitwise_or(m1, m2, dst);
//bitwise_not(m1, dst);
//bitwise_xor(m1, m2, dst);
imshow("位运算",dst);
}