To add solid code, I needed the equivalent imfilter(A, B)in python for a simple two-dimensional image and filter (kernel). I found that the following gives the same result as MATLAB:
import scipy.ndimage
import numpy as np
scipy.ndimage.correlate(A, B, mode='constant').transpose()
For this question, this will work:
scipy.ndimage.correlate(A, B, mode='replicate').transpose()
, - MATLAB .
. .
1:
MATLAB , . , 'conv', MATLAB ():
imfilter(x, f, 'replicate', 'conv')
:
scipy.ndimage.convolve(x, f, mode='nearest')
, 'replicate' MATLAB 'nearest' SciPy python.