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 6f4e3ff

Browse files
committed
2 parents 03807f0 + d000895 commit 6f4e3ff

File tree

6 files changed

+42
-15
lines changed

6 files changed

+42
-15
lines changed
1.92 KB
Binary file not shown.

‎ch04-Image/4.1_imread_imshow.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
print(cv2.__version__)
99

1010

11-
# img = cv2.imread('messi5.jpg',cv2.IMREAD_COLOR)#读入一副彩色图像。图像的透明度会被忽略 默认参数。
12-
#img = cv2.imread('messi5.jpg', cv2.IMREAD_GRAYSCALE)# Load an color image in grayscale 灰度
13-
img = cv2.imread('messi5.jpg',cv2.IMREAD_UNCHANGED)#包括图像的 alpha 通道
11+
img = cv2.imread('data/messi5.jpg',cv2.IMREAD_COLOR)#Read in a color image. The transparency of the image will be ignored. Default parameters.
12+
#img = cv2.imread('data/messi5.jpg', cv2.IMREAD_GRAYSCALE)# Load an color image in grayscale 灰度
13+
#img = cv2.imread('data/messi5.jpg',cv2.IMREAD_UNCHANGED) # Load an color image in grayscale 灰度
1414

1515
img = cv2.resize(img, (640, 480))
1616

@@ -19,8 +19,8 @@
1919

2020
#
2121
rows,cols,ch=img.shape
22-
print('行/高:',rows,'列/宽:',cols,'通道:',ch)
23-
#图像的宽对应的是列数, 高对应的是行数。
22+
print('Row/High:',rows,'Column/wide:',cols,'channel:',ch)
23+
#The width of the image corresponds to the number of columns, and the height corresponds to the number of rows.
2424

2525
cv2.namedWindow('image', cv2.WINDOW_NORMAL)#可以调整窗口大小
2626
# cv2.namedWindow('image', cv2.WINDOW_AUTOSIZE)#自动调整

‎ch04-Image/4.imread_imshow_imwrite.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
import numpy as np
22
import cv2
33

4-
<<<<<<<HEAD:ch04-Image/4.imread_imshow_imwrite.py
4+
55
img = cv2.imread('data/messi5.jpg', 0) #Edit path from missi5.jpg to data/missi5.jpg
6-
=======
76
img = cv2.imread('data/messi5.jpg', 0) # edit by Anucha from messi5.jpg to data/messi5.jpg
8-
>>>>>>>698971afc5b6779082ec6294047f15e525c2d03b:ch04-图片/4.imread_imshow_imwrite.py
7+
98
cv2.imshow('image', img)
109

1110
k = cv2.waitKey(0)
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()

‎ch10-图像上的算术运算/10.addWeighted.py‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22
import cv2
33
import numpy as np
44

5-
# 学习图像上的算术运算 加法 减法 位运算等
5+
# Learn arithmetic operations on images, addition, subtraction, bit operations, etc.
66

7-
# 你可以使用函数 cv2.add() 将两幅图像进行加法运算 当然也可以直接使 用 numpy ,
7+
# You can use the function cv2.add() to add two images. Of course, you can also use numpy directly.
88
# res=img1+img
9-
# 两幅图像的大小 类型必须一致 ,或者第二个 图像可以使一个简单的标量值。
10-
9+
# The size and type of the two images must be the same, or the second image can be a simple scalar value.
1110

1211
x = np.uint8([250])
1312
y = np.uint8([10])
@@ -17,11 +16,11 @@
1716
# [4]
1817

1918

20-
# 图像混合
19+
# Image mixing
2120
img1 = cv2.imread('../data/ml.png')
2221
img2 = cv2.imread('../data/opencv_logo.jpg')
2322

24-
dst = cv2.addWeighted(img1, 0.7, img2, 0.3, 0) # 第一幅图的权重是 0.7 第二幅图的权重是 0.3
23+
dst = cv2.addWeighted(img1, 0.7, img2, 0.3, 0) # The weight of the first image is 0.7 and the weight of the second image is 0.3
2524

2625
cv2.imshow('dst', dst)
2726
cv2.waitKey(0)

‎ch18-图像梯度/18.Sobel.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import numpy as np
2424
from matplotlib import pyplot as plt
2525

26-
img = cv2.imread('../data/sudoku.jpg', 0)
26+
img = cv2.imread('data/sudoku.jpg', 0)
2727
# cv2.CV_64F 出图像的深度 数据类型 可以使用 -1, 与原图像保持一致 np.uint8
2828
laplacian = cv2.Laplacian(img, cv2.CV_64F)
2929
# 参数 1,0 为只在 x 方向求一 导数 最大可以求 2 导数。

0 commit comments

Comments
(0)

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