当前位置:网站首页>图像像素的逻辑操作
图像像素的逻辑操作
2022-07-24 17:05:00 【什么时候上岸?】
示例代码:
void demo::bitwise_demo(Mat& image)
{
Mat m1 = Mat::zeros(Size(255, 255), CV_8UC3);
Mat m2 = Mat::zeros(Size(255, 255), CV_8UC3);
rectangle(m1, Rect(100, 100, 80, 80), Scalar(255, 255, 0), -1, 8, 0);
rectangle(m2, Rect(150, 150, 80, 80), Scalar(0, 255, 255), -1, 8, 0);
imshow("m1", m1);
imshow("m2", m2);
Mat dsc;
bitwise_or(m1, m2, dsc);
imshow("像素位操作", dsc);
}
rectangle()函数可以在图像上面绘制矩形,声明在imgproc.hpp
CV_EXPORTS_W void rectangle(InputOutputArray img, Rect rec,
const Scalar& color, int thickness = 1,
int lineType = LINE_8, int shift = 0);
参数一img:被处理的图像;
参数二rec:由四个数字组成,前两个数是矩形左上角像素点的坐标,后两个数是矩形的长和宽;
参数三color:矩形的颜色;
参数四thickness:线宽,负数表示填充;
参数五line Type:线段的类型;
参数六shift:像素点小数点位数。
line Type有以下几类:
enum LineTypes {
FILLED = -1,
LINE_4 = 4, //!< 4-connected line
LINE_8 = 8, //!< 8-connected line
LINE_AA = 16 //!< antialiased line
};
逻辑操作
bitwise_and //逻辑与
bitwise_or //逻辑或
bitwise_xor //逻辑异或
bitwise_not //逻辑非bitwise是对像素点进行逻辑操作的,如bitwise_and(m1,m2,dsc),m1=Scalar(255,255,0),m2=Scalar(0,255,255),则是像素点对应位上进行与操作,255与0为0,255与255是255,255与0是0,所以在两个矩形重合的地方为绿色。
效果展示:

over!!!
边栏推荐
- 2022-07-21 Daily: Wu Enda wrote: how to establish projects suitable for AI career
- 剑指 Offer 25. 合并两个排序的链表
- Amd Ruilong 7000 is expected to be available on September 15, and the 3D cache version will have to wait
- Digital transformation must have digital thinking
- [technology] online seat selection demo of uniapp
- EF LINQ Miscellany
- 【时序逻辑电路】——计数器
- The third edition of New Horizon College English reading and Writing Tutorial 4 graduation examination site (units 1,2,3,5,6)
- 【GNN报告】腾讯AI lab 徐挺洋:图生成模型及其在分子生成中的应用
- Qsqldatabase: solution of qmmysql driver not loaded
猜你喜欢

Axi protocol (2): five channels and two transactions of Axi architecture

Still developing games with unity? Then you're out. Try unity to build an answer system

AI opportunities for operators: expand new tracks with large models

电脑监控是真的吗?4个实验一探究竟

IP day 13 notes

Kernel development

ArcGIS create vector

内核开发

自定义类型:枚举

Apachecon Asia 2022 opens registration: pulsar technology issues make a big debut
随机推荐
CPU comparison
我们为什么要推出Getaverse?
小端格式和大端格式(Little-Endian&Big-Endian)
PAT甲级——A + B 格式
MySQL addition, deletion, modification, retrieval and constraint (detailed teaching)
[数组]NC143 矩阵乘法-简单
安全的证券公司有哪些?我想在手机上买股票
什么是模糊理论,基础,流程
量化框架backtrader之一文读懂Indicator指标
EF miscellaneous
Mysql增删改查、检索与约束(详细教学)
What should we pay attention to in the resume of software testing?
Sword finger offer 48. the longest substring without repeated characters
CANN训练营学习2022第二季 模型系列 动漫风格化和AOE ATC调优
709. Convert to lowercase letters
Coldplay weekly issue 10
The third edition of New Horizon College English reading and Writing Tutorial 4 graduation examination site (units 1,2,3,5,6)
What is the meaning of void 0? Is undefined changeable?
Why can't sizeof (ARR) / size (arr[0]) be used to calculate the array length inside the called function?
Still shocked by the explosion in the movie? Then you must not miss this explosive plug-in of unity