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.
|
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
|
|
|
|
|