Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d3ed80a

Browse files
committed
Commit
1 parent 3872090 commit d3ed80a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# -*- coding: utf-8 -*-
2+
import cv2
3+
import numpy as np
4+
5+
# Learn arithmetic operations on images, addition, subtraction, bit operations, etc.
6+
7+
# You can use the function cv2.add() to add two images. Of course, you can also use numpy directly.
8+
# res=img1+img
9+
# The size and type of the two images must be the same, or the second image can be a simple scalar value.
10+
11+
12+
x = np.uint8([250])
13+
y = np.uint8([10])
14+
print(cv2.add(x, y)) # 250+10 = 260 => 255
15+
# [[255]]
16+
print(x + y) # 250+10=260%256=4
17+
# [4]
18+
19+
20+
# 图像混合 # Image mixing
21+
img1 = cv2.imread('data/ml.png')
22+
img2 = cv2.imread('data/opencv_logo.jpg')
23+
24+
dst = cv2.addWeighted(img1, 0.7, img2, 0.3, 0) # 第一幅图的权重是 0.7 第二幅图的权重是 0.3
25+
# The weight of the first image is 0.7 and the weight of the second image is 0.3
26+
27+
cv2.imshow('dst', dst)
28+
cv2.waitKey(0)
29+
cv2.destroyAllWindows()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /