There are several ways to convert RGB
to Grayscale, the average of the channels mentioned is one of them. Using the Y
channel from the colorspace YCbCr
is also a common option, as well the L
channel from LAB
, among other options.
Converting CMYK
to RGB
is cheap according to the formulas in http://www.easyrgb.com/index.php?X=MATH, and then you can convert to grayscale using well known approaches. Supposing the c
, m
, y
, and k
in range [0, 1], we can convert it to grayscale luma as in:
def cmyk_to_luminance(c, m, y, k):
c = c * (1 - k) + k
m = m * (1 - k) + k
y = y * (1 - k) + k
r, g, b = (1 - c), (1 - m), (1 - y)
y = 0.299 * r + 0.587 * g + 0.114 * b
return y
See also http://en.wikipedia.org/wiki/Grayscale for a bit more about this conversion to grayscale.