def METHOD_NAME(data, c, r, mask=None, uncd=None, oob=0):
    """
    Extracts a rectangular area of an image masking out of bound pixels.
    Parameters
    ----------
    data  : 2D ndarray
        Image from where extract a sub image.
    c: 2-elements tuple
        yc, xc. Position in data, where the extracted image will be centered.
        yc and xc must have integer values.
    r : 2-elements tuple
        yr, xr. Semi-length of the extracted image. Integer values.
    mask : 2D ndarray
        If specified, this routine will extract the mask subimage
        as well. out of bound pixels values will have value oob.
    uncd : 2D ndarray
        If specified, this routine will extract the uncd subimage
        as well.
    oob : scalar
        Value for out of bound pixels in the mask. Default is 0.
    Returns
    -------
    Tuple, up to 3 2D-ndarray images containing the extracted image,
    its mask (if specified) and a uncd array (if specified). The shape
    of each array is (2*yr+1, 2*xr+1).
    Examples
    --------
    .. highlight:: python
    .. code-block:: python
        >>> from imageedit import *
        >>> import numpy as np
        >>> # Create  a data image and its mask
        >>> data  = np.arange(25).reshape(5,5)
        >>> print(data)
        [[ 0  1  2  3  4]
        [ 5  6  7  8  9]
        [10 11 12 13 14]
        [15 16 17 18 19]
        [20 21 22 23 24]]
        >>> msk  = np.ones(np.shape(data))
        >>> msk[1:4,2] = 0
        >>> # Extract a subimage centered on (3,1) of shape (3,5)
        >>> dyc,dxc = 3,1
        >>> subim, mask = trimimage(data, (dyc,dxc), (1,2), mask=msk)
        >>> print(subim)
        [[  0.  10.  11.  12.  13.]
        [  0.  15.  16.  17.  18.]
        [  0.  20.  21.  22.  23.]]
        >>> print(mask)
        [[ 0.  1.  1.  0.  1.]
        [ 0.  1.  1.  0.  1.]
        [ 0.  1.  1.  1.  1.]]
        >>> # Set out of bound pixels in the mask to -1:
        >>> subim, mask = trimimage(data, (dyc,dxc), (1,2), mask=msk, oob=-1)
        >>> print(mask)
        [[-1.  1.  1.  0.  1.]
        [-1.  1.  1.  0.  1.]
        [-1.  1.  1.  1.  1.]]
    Notes
    -----
    History:
    - 2010-07-11  patricio, pcubillos@fulbrightmail.org
        Added documentation.
    """
    (yc, xc) = c
    (yr, xr) = r
    # Shape of original data
    ny, nx = np.shape(data)
    # The extracted image and mask
    im = np.zeros((2 * int(yr) + 1, 2 * int(xr) + 1))
    # coordinates of the limits of the extracted image
    uplim = int(yc + yr + 1)  # upper limit
    lolim = int(yc - yr)  # lower limit
    rilim = int(xc + xr + 1)  # right limit
    lelim = int(xc - xr)  # left  limit
    # Ranges (in the original image):
    bot = np.amax((0, lolim))  # bottom
    top = np.amin((ny, uplim))  # top
    lft = np.amax((0, lelim))  # left
    rgt = np.amin((nx, rilim))  # right
    im[bot - lolim:top - lolim, lft - lelim:rgt - lelim] = data[bot:top,
                                                                lft:rgt]
    ret = im
    if mask is not None:
        # The mask is initialized to oob
        ma = np.zeros((2 * int(yr) + 1, 2 * int(xr) + 1)) + oob
        ma[bot - lolim:top - lolim, lft - lelim:rgt - lelim] = mask[bot:top,
                                                                    lft:rgt]
        ret = (ret, ma)
    if uncd is not None:
        un = np.zeros((2*int(yr)+1, 2*int(xr)+1)) + np.amax(uncd[bot:top,
                                                                 lft:rgt])
        un[bot - lolim:top-lolim, lft-lelim:rgt-lelim] = uncd[bot:top,
                                                              lft:rgt]
        ret = (ret, un) if mask is None else ret + (un,)
    return ret