Ow can I compute the magnitude of edges of an image?

I have an image with 11x11 pixels. In the center of the image is a square of 5x5 pixels. The gray level of the background is 0 and the gray level of the square is 50. How can I compute the result of the magnitude of edges given by the compass operator for this image taking into account that the image is not noisy?