def _crop_filter(input_filter, scale, radius=None):
    """
    Crop an image domain filter
    """
    ndim = input_filter.ndim
    if radius is None:
        radius = 4 * 2 ** scale
    if ndim == 2:
        nx, ny = input_filter.shape
        output_filter = input_filter[int(nx / 2 - radius):int(nx / 2 +
            radius + 1), int(ny / 2 - radius):int(ny / 2 + radius + 1)]
    elif ndim == 3:
        nx, ny, nz = input_filter.shape
        output_filter = input_filter[int(nx / 2 - radius):int(nx / 2 +
            radius + 1), int(ny / 2 - radius):int(ny / 2 + radius + 1), int
            (nz / 2 - radius):int(nz / 2 + radius + 1)]
    else:
        raise RuntimeError(
            'Unsupported number of dimensions {}. We only supports 2 or 3D arrays.'
            .format(ndim))
    return output_filter
