def __desaturate(src):
"""Converts a color image into shades of gray.
Args:
src: A color numpy.ndarray.
Returns:
A gray scale numpy.ndarray.
"""
(a, b, channels) = src.shape
if(channels == 1):
return numpy.copy(src)
elif(channels == 3):
return cv2.cvtColor(src, cv2.COLOR_BGR2GRAY)
elif(channels == 4):
return cv2.cvtColor(src, cv2.COLOR_BGRA2GRAY)
else:
raise Exception("Input to desaturate must have 1, 3 or 4 channels")
评论列表
文章目录