from numpy import generic
import cv2


def copy_and_normalize_channels(image):

    image = image.copy()
    try:
        image = cv2.cvtColor(image, cv2.COLOR_GRAY2BGR)
    except cv2.error:
        pass

    return image


def npconvert(ob):
    if isinstance(ob, generic):
        return ob.item()
    raise TypeError
