def rgb2xyz(rgb):

    """
    Convert RGB to XYZ color space

    input:   image as a numpy array with 3 channels (RGB)
    outputs: X, Y, and Z channels
    """

    x = 0.49*rgb[:,:,0] + 0.31*rgb[:,:,1] + 0.2*rgb[:,:,2]
    y = 0.177*rgb[:,:,0] + 0.812*rgb[:,:,1] + 0.011*rgb[:,:,2]
    z = 0.*rgb[:,:,0] + 0.01*rgb[:,:,1] + 0.99*rgb[:,:,2]

    return x,y,z