def __log_gabor_2d(image, num_scales=4, num_orientations=6,
                   min_wavelength=3, scaling_constant=2, center_sigma=0.65,
                   d_phi_sigma=1.3):
    # Allocate space for return structures
    bandpass = np.empty([num_scales, image.shape[0], image.shape[1]],
                        dtype=np.complex)
    log_gabor = np.empty([num_scales, image.shape[0], image.shape[1]])
    S = np.zeros(image.shape)
    complex_conv = np.empty([num_scales, num_orientations, image.shape[0],
                             image.shape[1]], dtype=np.complex)
    tmp_complex_conv = np.empty([num_scales, image.shape[0], image.shape[1]],
                                dtype=np.complex)

    # Pre-compute phi sigma
    phi_sigma = np.pi / num_orientations / d_phi_sigma

    # Pre-compute fourier values
    image_fft = np.fft.fft2(image)

    axis0, axis1 = __adjusted_meshgrid(image.shape)

    radius = np.sqrt(axis0 ** 2 + axis1 ** 2)
    phi = np.arctan2(axis0, axis1)

    radius = np.fft.ifftshift(radius)
    radius[0][0] = 1.0
    phi = np.fft.ifftshift(phi)

    sin_phi = np.sin(phi)
    cos_phi = np.cos(phi)

    # Compute the lowpass filter
    butterworth_filter = __frequency_butterworth_filter(image.shape, 0.45, 15)

    # Compute radial component of filter
    for s in range(num_scales):
        wavelength = min_wavelength * scaling_constant ** s
        fo = 1.0 / wavelength

        l = np.exp((-(np.log(radius / fo)) ** 2) /
                   (2.0 * np.log(center_sigma) ** 2))
        l = l * butterworth_filter
        l[0][0] = 0.0

        log_gabor[s, :, :] = l
        bandpass[s, :, :] = np.fft.ifft2(image_fft * l)

    # Computer angular component of filter
    for o in range(num_orientations):
        # Pre-compute filter data specific to this orientation
        filter_angle = o * np.pi / num_orientations

        ds = (sin_phi * np.cos(filter_angle) -
              cos_phi * np.sin(filter_angle))
        dc = (cos_phi * np.cos(filter_angle) +
              sin_phi * np.sin(filter_angle))

        d_phi = np.abs(np.arctan2(ds, dc))

        # Calculate the standard deviation of the angular Gaussian
        # function used to construct filters in the freq. plane.
        spread = np.exp((-d_phi ** 2.0) / (2.0 * phi_sigma ** 2))

        # For each scale, multiply by the angular spread
        for s in range(0, num_scales):
            filter_bank = log_gabor[s] * spread

            shifted_filter = np.fft.fftshift(filter_bank)
            S += shifted_filter * np.conjugate(shifted_filter)

            tmp_complex_conv[s, :, :] = np.fft.ifft2(image_fft * filter_bank)

        complex_conv[:, o, :, :] = tmp_complex_conv[None, ...]

    # TODO: Why is this done??
    return complex_conv, bandpass, np.flipud(S)
dataset/ETHPy150Open menpo/menpo/menpo/math/convolution.py/__log_gabor_2d/original