<commit_before>import numpy as np
from scipy import ndimage
from . import peak


def harris(image, eps=1e-6, gaussian_deviation=1):
    """Compute Harris response image.

    Parameters
    ----------
    image : ndarray
        Input image.
    eps : float, optional
        Normalisation factor.
    gaussian_deviation : integer, optional
        Standard deviation used for the Gaussian kernel.

    Returns
    -------
    response : ndarray
        Moravec response image.

    Examples
    -------
    >>> from skimage.feature import harris, peak_local_max
    >>> square = np.zeros([10, 10])
    >>> square[2:8,2:8] = 1
    >>> square
    array([[ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
           [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
           [ 0.,  0.,  1.,  1.,  1.,  1.,  1.,  1.,  0.,  0.],
           [ 0.,  0.,  1.,  1.,  1.,  1.,  1.,  1.,  0.,  0.],
           [ 0.,  0.,  1.,  1.,  1.,  1.,  1.,  1.,  0.,  0.],
           [ 0.,  0.,  1.,  1.,  1.,  1.,  1.,  1.,  0.,  0.],
           [ 0.,  0.,  1.,  1.,  1.,  1.,  1.,  1.,  0.,  0.],
           [ 0.,  0.,  1.,  1.,  1.,  1.,  1.,  1.,  0.,  0.],
           [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
           [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.]])
    >>> peak_local_max(harris(square), min_distance=1)
    array([[3, 3],
           [3, 6],
           [6, 3],
           [6, 6]])

    """

    if image.ndim == 3:
        image = rgb2grey(image)

    # derivatives
    image = ndimage.gaussian_filter(image, gaussian_deviation, mode='constant',
                                    cval=0)
    imx = ndimage.sobel(image, axis=0, mode='constant', cval=0)
    imy = ndimage.sobel(image, axis=1, mode='constant', cval=0)

    Wxx = ndimage.gaussian_filter(imx * imx, 1.5, mode='constant', cval=0)
    Wxy = ndimage.gaussian_filter(imx * imy, 1.5, mode='constant', cval=0)
    Wyy = ndimage.gaussian_filter(imy * imy, 1.5, mode='constant', cval=0)

    # determinant and trace
    Wdet = Wxx * Wyy - Wxy**2
    Wtr = Wxx + Wyy

    # Alternate formula for Harris response.
    # <NAME>, "Descriptions of Image Surfaces", PhD thesis (1989)
    harris = Wdet / (Wtr + eps)

    return harris<commit_msg>Fix missing sigma for gaussian filter in harris operator<commit_after>import numpy as np
from scipy import ndimage
from . import peak


def harris(image, eps=1e-6, sigma=1):
    """Compute Harris response image.

    Parameters
    ----------
    image : ndarray
        Input image.
    eps : float, optional
        Normalisation factor.
    sigma : float, optional
        Standard deviation used for the Gaussian kernel.

    Returns
    -------
    response : ndarray
        Moravec response image.

    Examples
    -------
    >>> from skimage.feature import harris, peak_local_max
    >>> square = np.zeros([10, 10])
    >>> square[2:8,2:8] = 1
    >>> square
    array([[ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
           [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
           [ 0.,  0.,  1.,  1.,  1.,  1.,  1.,  1.,  0.,  0.],
           [ 0.,  0.,  1.,  1.,  1.,  1.,  1.,  1.,  0.,  0.],
           [ 0.,  0.,  1.,  1.,  1.,  1.,  1.,  1.,  0.,  0.],
           [ 0.,  0.,  1.,  1.,  1.,  1.,  1.,  1.,  0.,  0.],
           [ 0.,  0.,  1.,  1.,  1.,  1.,  1.,  1.,  0.,  0.],
           [ 0.,  0.,  1.,  1.,  1.,  1.,  1.,  1.,  0.,  0.],
           [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.],
           [ 0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.,  0.]])
    >>> peak_local_max(harris(square), min_distance=1)
    array([[3, 3],
           [3, 6],
           [6, 3],
           [6, 6]])

    """

    if image.ndim == 3:
        image = rgb2grey(image)

    # derivatives
    image = ndimage.gaussian_filter(image, sigma, mode='constant', cval=0)
    imx = ndimage.sobel(image, axis=0, mode='constant', cval=0)
    imy = ndimage.sobel(image, axis=1, mode='constant', cval=0)

    Wxx = ndimage.gaussian_filter(imx * imx, sigma,
                                  mode='constant', cval=0)
    Wxy = ndimage.gaussian_filter(imx * imy, sigma,
                                  mode='constant', cval=0)
    Wyy = ndimage.gaussian_filter(imy * imy, sigma,
                                  mode='constant', cval=0)

    # determinant and trace
    Wdet = Wxx * Wyy - Wxy**2
    Wtr = Wxx + Wyy

    # Alternate formula for Harris response.
    # <NAME>, "Descriptions of Image Surfaces", PhD thesis (1989)
    harris = Wdet / (Wtr + eps)

    return harris
{'fraction_non_alphanumeric': 0.1928697962798937, 'fraction_numerical': 0.061558901682905225, 'mean_word_length': 1.4791437980241493, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4411398', 'n_tokens_mistral': 1812, 'n_tokens_neox': 1722, 'n_words': 479}