void OpencvExample::Example_LogiclOpt(Mat &image)
{
Mat anddst, ordst, srcnotdst, xordst;
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), Scalar(255, 0, 0), -1, LINE_8, 0);
rectangle(m2, Rect(150, 150, 80, 80), Scalar(0, 0, 255), -1, LINE_8, 0);
imshow("m1", m1);
imshow("m2", m2);
bitwise_and(m1, m2, anddst);//位操作与
bitwise_or(m1, m2, ordst);//位操作或
bitwise_not(image, srcnotdst);//取反操作
bitwise_xor(m1, m2, xordst);//异或操作
imshow("anddst", anddst);
imshow("ordst", ordst);
imshow("notdst", srcnotdst);
imshow("xordst", xordst);
}
OpenCV入门(九):图像像素逻辑操作
最新推荐文章于 2024-07-21 23:54:09 发布