forked from pn2q95w37/XL
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
243 B
15 lines
243 B
2 years ago
|
from numpy import uint8
|
||
|
|
||
|
def rgbToGray(img):
|
||
|
|
||
|
# 得到(r,g,b)三通道
|
||
|
b = img[:, :, 0].copy()
|
||
|
g = img[:, :, 1].copy()
|
||
|
r = img[:, :, 2].copy()
|
||
|
# 灰度化
|
||
|
out = 0.2126 * r + 0.7152 * g + 0.0722 * b
|
||
|
out = out.astype(uint8)
|
||
|
return out
|
||
|
|
||
|
|