Hi,
In the question you write that we do not have to handle in the function local_operator pixels near the edges of the picture. The expression "not to handle" is not clear. They are several options:
(1) we don't have to change them. If they are white, in the end they should be white, and if they are black they should remain black. We simply ignore the pixels in the edges. We don't change them and they don't influence pixels that are not near the edges.
(2) we should change the pixels in the edges and they influence pixels that are not in the edges.
(3) we should not change pixels near the edges but they influence the pixels that are not near the edges.
To make it clear:
Consider the case that pixel [4,4] is black and pixel [7,7] is white, and k=5, do we need to change pixel [4,4] to white or not to handle it because it is in the edges?
Same as above. If pixel [4,4] os white and pixel [7,7] is black (and k=5). Do we need to change pixel [7,7]?
Thank you for making it clearer.