//图形像素的逻辑操作voidbitwise_demo(Mat &image){
Mat m1 = mat::zeros)(Size(256,256),CV_8UC3);
Mat m2 = mat::zeros)(Size(256,256),CV_8UC3);rectangle(m1,Rect(100,100,80,80),Scalor(255,255,0),-1,LINE_8,0);//-1表示填充矩形,小于0为填充,大于0为绘制rectangle(m2,Rect(150,150,80,80),Scalor(0,255,255),-1,LINE_8,0);imshow("m1",m1);imshow("m2",m2);
Mat dst;bitwise_and(m1,m2,dst);//与操作,bitwise_or(m1,m2,dst)或操作,bitwise_not(m1,dst)非操作,bitwise_xor(m1,m2,dst)//异或操作imshow("像素位操作",dst)}
//图像色彩空间转换voidinrange_demo(Mat& image){
Mat hsv;cvtColor(image,hsv,COLOR_BGR2HSV);
Mat mask;inRange(hsv,Scarlor(35,43,46),Scarlor(77,255,255),mask);
Mat redback =Mat::zeros(image.size(), image.type());
redback =Scalor(40,40,200);bitwise_not(mask,mask);imshow("mask",mask);
image.copyTo(redback,mask);imshow("roi区域提取",redback);}