finding mean minimum and maximum values

I am trying to write a function that finds the mean maximum and minimum values for an image yes an image, Which is nothing to extraordinarily because it is just a two d matrix of pixel values. So here it was i have so far two for loops that go through the row and column coordinates of the for loop what i am confused on is how to get the mean min and maxium value i know kind of how to do it in words but now so much code

so here are the for loops

for(r=0; r < no_of_rows; r++) {

for(c=0; c < no_of_cols; c++) {

}

}

these will cycle through the row and collum coordinates but how i find the values of the maximum and minim i do not know

please hlep