当前位置:网站首页>Logical operation of image pixels
Logical operation of image pixels
2022-07-24 17:08:00 【When will we get ashore?】
Sample code :
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(" Pixel bit operation ", dsc);
}
rectangle() Function to draw a rectangle on top of an image , The statement in imgproc.hpp
CV_EXPORTS_W void rectangle(InputOutputArray img, Rect rec,
const Scalar& color, int thickness = 1,
int lineType = LINE_8, int shift = 0);
Parameter one img: The processed image ;
Parameter two rec: It's made up of four numbers , The first two numbers are the coordinates of the pixels in the upper left corner of the rectangle , The last two numbers are the length and width of the rectangle ;
Parameter 3 color: The color of the rectangle ;
Parameter 4 thickness: Line width , Negative numbers indicate padding ;
Parameter 5 line Type: The type of line segment ;
Parameter 6 shift: The number of pixels and decimal places .
line Type There are the following categories :
enum LineTypes {
FILLED = -1,
LINE_4 = 4, //!< 4-connected line
LINE_8 = 8, //!< 8-connected line
LINE_AA = 16 //!< antialiased line
};
Logical operation
bitwise_and // Logic and
bitwise_or // Logic or
bitwise_xor // Logical XOR
bitwise_not // Logic is not bitwise It is the logical operation of pixels , Such as bitwise_and(m1,m2,dsc),m1=Scalar(255,255,0),m2=Scalar(0,255,255), It is the pixel point corresponding to the bit to carry out and operation ,255 And 0 by 0,255 And 255 yes 255,255 And 0 yes 0, So the place where the two rectangles coincide is green .
Effect display :

over!!!
边栏推荐
- What exactly is API?
- 【零基础】充分理解WebGL(八)
- Exception handling - a small case that takes you to solve NullPointerException
- [zero basis] fully understand webgl (VIII)
- What is fuzzy theory, foundation and process
- 小端格式和大端格式(Little-Endian&Big-Endian)
- 快速入门
- JVM class loading subsystem
- Bring 120W goods in 15 seconds. You can also shoot such a popular video
- CDN (content delivery network) content distribution network from entry to practice
猜你喜欢

Why should we launch getaverse?

自定义类型:枚举
![为什么被调函数内部不能用 sizeof(arr) / size(arr[0]) 计算数组长度?](/img/e6/1d2213f3eb9bd0ff537a66d2b01f98.png)
为什么被调函数内部不能用 sizeof(arr) / size(arr[0]) 计算数组长度?

Jing Wei PS tutorial: basic part a
![[matlab]: basic knowledge learning](/img/8c/d13597e402c55df6cbd5e008aef0a5.png)
[matlab]: basic knowledge learning

Duplicate content in lookup table

Meeting OA project progress (II)

什么是模糊理论,基础,流程
[redis] -1. two ways of setting up environment based on docker

MySQL basic commands
随机推荐
[GNN report] Tencent AI Lab Xu TingYang: graph generation model and its application in molecular generation
What is the meaning of void 0? Is undefined changeable?
EF combined with sqlbulkcopy batch insert data
Code random notes_ Linked list_ 707 design linked list
regular expression
CPU comparison
ShardingSphere数据库读写分离
Kernel development
为什么被调函数内部不能用 sizeof(arr) / size(arr[0]) 计算数组长度?
Bring 120W goods in 15 seconds. You can also shoot such a popular video
Long awaited full platform support - Open Source im project uniapp update of openim
Pull and load more on wechat applet list rendering
Amd Ruilong 7000 is expected to be available on September 15, and the 3D cache version will have to wait
Is it safe for Mr. qiniu to open a securities account? Can I drive it?
GDB online debugging of work notes
Zcmu--5023: family division (C language)
Rare earth Developer Conference | Apache pulsar committee Liu Dezhi shares the way of cloud native technology transformation
EF LINQ Miscellany
JS, call in the for loop is asynchronously converted to synchronous execution
安全:如何为行人提供更多保护