Exercise: Noise Estimation Program Formula for mean

Below is the algorithm that can be used to calculate the mean. You should put it in real code and also do the same for the standard deviation in addition to the code to read in an input image, and ask the user for the sub-region location and dimensions.

mean = 0;
n = number pixels in the sub-region

for (each pixel in the sub-region) 
{
     mean = mean + pixel_value;
}

mean = 1/n * mean;