#region 矩形绘制以及图像位操作
static void Main(string[] args)
{
Mat m1 = Mat.Zeros(256, 256, MatType.CV_8UC3);
Mat m2 = Mat.Zeros(256, 256, MatType.CV_8UC3);
Cv2.Rectangle(m1,new Rect(100,100,80,80),new Scalar(255,255,0),-1,LineTypes.Link8,0);//thickness : 线宽小于0时为填充效果,大于等于0为画线效果
Cv2.Rectangle(m2, new Rect(150,150, 80, 80), new Scalar(0, 255, 255), -1, LineTypes.Link8, 0);
Cv2.ImShow("m1", m1);
Cv2.ImShow("m2", m2);
Mat And = new Mat();
Cv2.BitwiseAnd(m1, m2,And);
Cv2.ImShow("And", And);
Mat Not = new Mat();
Cv2.BitwiseNot(m1, Not);
Cv2.ImShow("Not", Not);
Mat Or = new Mat();
Cv2.BitwiseOr(m1, m2, Or);
Cv2.ImShow("Or", Or);
Mat Xor = new Mat();
Cv2.BitwiseXor(m1, m2, Xor);
Cv2.ImShow("Xor", Xor);
Cv2.WaitKey();
Cv2.DestroyAllWindows();
}
#endregion
结果如下: