@staticmethod
def convert2gray(img):
    '\n        图片转为灰度图，如果是3通道图则计算，单通道图则直接返回\n        :param img:\n        :return:\n        '
    if (len(img.shape) > 2):
        (r, g, b) = (img[:, :, 0], img[:, :, 1], img[:, :, 2])
        gray = (((0.2989 * r) + (0.587 * g)) + (0.114 * b))
        return gray
    else:
        return img
图片转为灰度图，如果是3通道图则计算，单通道图则直接返回
:param img:
:return:
@staticmethod
def convert2gray(img):
    '\n        图片转为灰度图，如果是3通道图则计算，单通道图则直接返回\n        :param img:\n        :return:\n        '
    if (len(img.shape) > 2):
        (r, g, b) = (img[:, :, 0], img[:, :, 1], img[:, :, 2])
        gray = (((0.2989 * r) + (0.587 * g)) + (0.114 * b))
        return gray
    else:
        return img