Few statistical measures for an image

I'm not sure which section it belongs to, so I thought I should post in "others". The thing is I have a 3x3 matrix which represents a nine pixel square from grayscale image, so let's say the matrix can have values from 0 to 255. Now I need to make few statistical measures for the square based on this matrix, but whenever I tried to google any of them it always showed solutions that use some dedicated programs (like Matlab) or C++ libraries etc., while I only want pure mathematical formulas so I could calculate everything by myself based on the said matrix. The measures I need to calculate are:

- measure of smoothness

- measure of uniformity

- average gray level

- average contrast

- thrid moment

- entropy

Is there anyone who knows how to get these from the matrix? Any help will be apreciated.