def extract_patch(image, pshape, r, c):
    """
    Extract a patch of given shape, centered at r,c of given shape from image.

    Note that there is no checking if the patch region is inside the image.

    >>> image = np.reshape(np.arange(16, dtype='uint8'), (4, 4))
    >>> extract_patch(image, (2, 3), 2, 2)
    array([[ 5,  6,  7],
           [ 9, 10, 11]], dtype=uint8)

    :param numpy array image: Numpy array with range [0,255] and dtype 'uint8'.
       Can be of shapes MxN, MxNxC.
    :param tuple pshape: Shape of patch. #Dimensions must match image.
    :param int r: Row for center of patch
    :param int c: Column for center of patch
    :return: numpy array with shape pshape
    :rtype: numpy array with range [0,255] and dtype 'uint8'
    """
    h, w = pshape[0], pshape[1]
    r, c = int(r - h // 2), int(c - w // 2)
    return image[r:r + h, c:c + w]
