Read image by cv2 module.

    Args:
        path (str or 'file object'): File path or object to read.
        grayscale (bool):
        size (tupple of int):
            (width, height).
            If None, output img shape depends on the files to read.
        channel_first (bool):
            This argument specifies the shape of img is whether (height, width, channel) or (channel, height, width).
            Default value is False, which means the img shape is (height, width, channel).
        interpolate (str):
            must be one of ["nearest", "box", "bilinear", "hamming", "bicubic", "lanczos"].
        as_uint16 (bool):
            If True, this function reads image as uint16.
        num_channels (int):
            channel size of output array.
            Default is -1 which preserves raw image shape.

    Returns:
         numpy.ndarray

def imread(path, grayscale=False, size=None, interpolate="bilinear",
           channel_first=False, as_uint16=False, num_channels=-1):
    """
    Read image by cv2 module.

    Args:
        path (str or 'file object'): File path or object to read.
        grayscale (bool):
        size (tupple of int):
            (width, height).
            If None, output img shape depends on the files to read.
        channel_first (bool):
            This argument specifies the shape of img is whether (height, width, channel) or (channel, height, width).
            Default value is False, which means the img shape is (height, width, channel).
        interpolate (str):
            must be one of ["nearest", "box", "bilinear", "hamming", "bicubic", "lanczos"].
        as_uint16 (bool):
            If True, this function reads image as uint16.
        num_channels (int):
            channel size of output array.
            Default is -1 which preserves raw image shape.

    Returns:
         numpy.ndarray
    """

    _imread_before(grayscale, num_channels)

    r_mode = cv2.IMREAD_GRAYSCALE if grayscale else cv2.IMREAD_UNCHANGED
    img = _imread_helper(path, r_mode)

    if as_uint16 and img.dtype != np.uint16:
        if img.dtype == np.uint8:
            logger.warning("You want to read image as uint16, but the original bit-depth is 8 bit."
                           "All pixel values are simply increased by 256 times.")
            img = img.astype(np.uint16) * 256
        else:
            raise ValueError(
                "casting {} to uint16 is not safe.".format(img.dtype))

    img = _cvtColor_helper(img, num_channels)

    img = _imread_after(img, size, interpolate, channel_first, imresize)

    return img