def apply_mask(img, mask):
    """
    Applies a boolean mask to a 2d image

    Parameters
    ----------
    img: 2darray
        values of Gaussian source
    mask: bool
        mask for sampling frequencies

    Returns
    -------
    out: 2darray
        array with sampled frequencies
    """
    img = img.copy()
    img[~mask.astype(bool)] = 0
    return img