import numpy as np


def rgb2gray(image):
    if image.shape[2] == 4:
        return image.dot(np.array([0.2627, 0.6780, 0.0593, 0]) / 255)
    else:
        return image.dot(np.array([0.2627, 0.6780, 0.0593]) / 255)

def rgb2gray_value(image):
    image = image[:, :, :3]
    maxc = np.maximum(np.maximum(image[:, :, 0], image[:, :, 1]), image[:, :, 2])/255
    minc = np.minimum(np.minimum(image[:, :, 0], image[:, :, 1]), image[:, :, 2])/255

    return maxc - minc
