The filter2 in Matlab gives an option ‘same’ to Return the central part of the filtered data, which is the same size as
filter2() usage in Matlab
Y = filter2(H,X,shape)
opencv’s filter2D will always return a Mat with the same size as the input.
(depending on what BORDER_TYPE you use, it will get padded internally with Ksize/2, but the result gets cropped back to original size)