def structure_tensor(image, sigma=1, mode='constant', cval=0):
 image = _prepare_grayscale_input_2D(image)
 (imx, imy) = _compute_derivatives(image, mode=mode, cval=cval)
 Axx = ndi.gaussian_filter((imx * imx), sigma, mode=mode, cval=cval)
 Axy = ndi.gaussian_filter((imx * imy), sigma, mode=mode, cval=cval)
 Ayy = ndi.gaussian_filter((imy * imy), sigma, mode=mode, cval=cval)
 return (Axx, Axy, Ayy)

def structure_tensor ( image , sigma = 1 , mode = 'constant' , cval = 0 ) : image = _prepare_grayscale_input_2D ( image ) ( imx , imy ) = _compute_derivatives ( image , mode = mode , cval = cval ) Axx = ndi . gaussian_filter ( ( imx * imx ) , sigma , mode = mode , cval = cval ) Axy = ndi . gaussian_filter ( ( imx * imy ) , sigma , mode = mode , cval = cval ) Ayy = ndi . gaussian_filter ( ( imy * imy ) , sigma , mode = mode , cval = cval ) return ( Axx , Axy , Ayy )
compute structure tensor using sum of squared differences .