1 | initial version |
copyMakeBorder() is the answer. You can add surrounding borders for your picture. In this case, as your "kernel" is 3x3, adding a 2pixel-border would do the trick (at most 2 pixels can be outside the picture). After processing the image, you can crop the extra border to get the image to its original size