convolve¶
-
fft_psd_tools.convolve(array, kernel, boundary='fill', fill_value=0, crop=True, return_fft=False, fftshift=True, fft_pad=True, psf_pad=False, interpolate_nan=False, quiet=False, ignore_edge_zeros=False, min_wt=0.0, normalize_kernel=False, use_numpy_fft=True, nthreads=1, complextype=<type 'numpy.complex128'>, use_rfft=False) [edit on github]¶ Convolve an ndarray with an nd-kernel. Returns a convolved image with shape = array.shape. Assumes image & kernel are centered.
Parameters: array: `numpy.ndarray`
Array to be convolved with kernel
kernel: `numpy.ndarray`
Will be normalized if normalize_kernel is set. Assumed to be centered (i.e., shifts may result if your kernel is asymmetric)
Returns: default:
arrayconvolved withkernelif return_fft: fft(
array) * fft(kernel)- if fftshift: Determines whether the fft will be shifted before returning
if not(`crop`) : Returns the image, but with the fft-padded size
instead of the input size
Examples
>>> convolvend([1,0,3],[1,1,1]) array([ 1., 4., 3.])
>>> convolvend([1,np.nan,3],[1,1,1],quiet=True) array([ 1., 4., 3.])
>>> convolvend([1,0,3],[0,1,0]) array([ 1., 0., 3.])
>>> convolvend([1,2,3],[1]) array([ 1., 2., 3.])
>>> convolvend([1,np.nan,3],[0,1,0], interpolate_nan=True) array([ 1., 0., 3.])
>>> convolvend([1,np.nan,3],[0,1,0], interpolate_nan=True, min_wt=1e-8) array([ 1., nan, 3.])
>>> convolvend([1,np.nan,3],[1,1,1], interpolate_nan=True) array([ 1., 4., 3.])
>>> convolvend([1,np.nan,3],[1,1,1], interpolate_nan=True, normalize_kernel=True, ignore_edge_zeros=True) array([ 1., 2., 3.])