How can I get the result of filter2d is equivalent to filter2 in Matlab

Hello,
The filter2 in Matlab gives an option ‘same’ to Return the central part of the filtered data, which is the same size as X .
filter2() usage in Matlab
Y = filter2(H,X,shape)