opencv的逻辑运算bitwise详解
·
官网介绍
http://docs.opencv.org/2.4/modules/core/doc/operations_on_arrays.html#
代码
#include <windows.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include "opencv2/objdetect/objdetect.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat srcimage = imread("pic.jpg");
Mat dstimage = imread("pic.jpg");
Mat outnot,outxor, outor, outand;
bitwise_not(srcimage, outnot);
bitwise_xor(srcimage, dstimage, outxor);
bitwise_or(srcimage, dstimage, outor);
bitwise_and(srcimage, dstimage, outand);
imshow("not", outnot);
imshow("xor", outxor);
imshow("or", outor);
imshow("and", outand);
waitKey(0);
}
效果图
原图
运算后
bitwise_not bitwise_xor
bitwise_or bitwise_and
颜色对照表
http://jingyan.baidu.com/article/425e69e69690f0be15fc168a.html
逻辑运用表
逻辑运用详解
https://baike.baidu.com/item/逻辑运算/7224729?fr=aladdin
"∨" 表示"或" (逻辑加法)
"∧" 表示"与". (逻辑乘法)
"┐"表示"非". (逻辑否定)
"=" 表示"等价".
1和0表示"真"和"假"
(还有一种表示,"+"表示"或", "·"表示"与")
逻辑运算又称布尔运算 布尔用数学方法研究逻辑问题,成功地建立了逻辑演算。他用等式表示判断,把推理看作等式的变换。这种变换的有效性不依赖人们对符号的解释,只依赖于符号的组合规律 。这一逻辑理论人们常称它为布尔代数。20世纪30年代,逻辑代数在电路系统上获得应用,随后,由于电子技术与计算机的发展,出现各种复杂的大系统,它们的变换规律也遵守布尔所揭示的规律。逻辑运算 (logical operators) 通常用来测试真假值。最常见到的逻辑运算就是循环的处理,用来判断是否该离开循环或继续执行循环内的指令。
更多推荐


所有评论(0)