defcolor2gray(img, convertor, weight=[1, 1, 1]): assertlen(weight) == 3, "Weight must be a 3-element list" assertsum(weight) != 0, "Weight must not be all zeros" assertlen(img.shape) == 3, "Input image must be a 3D array" assert convertor in [ "3c2gray", "hsv2gray", ], f"Convertor {convertor} is not supported"