in solving the problem, you can use the exact values in the matrix of the brush.
Then, examining the amount received for each cell in the figure, we can find the actual slope and location of the analyzed edges and center.
But to my task, it was necessary to obtain high speed and the approximate location of the center. Integers have helped increase the speed for large matrices.
a good picture!
perfectly illustrates the algorithm.
So, I created a 3D surface to visualize the results. Z - the amount for each cell