def pixel_perfect_figsize(image, dpi=80):
    """Return the Matplotlib figure size tuple (w, h) for given image and dpi.

    Parameters
    ----------
    image : array, shape (M, N[, 3])
        The image to be plotted.
    dpi : int, optional
        The desired figure dpi.

    Returns
    -------
    figsize : tuple of float
        The desired figure size.

    Examples
    --------
    >>> image = np.empty((768, 1024))
    >>> pixel_perfect_figsize(image)
    (12.8, 9.6)
    """
    hpix, wpix = image.shape[:2]
    return wpix/dpi, hpix/dpi