nadia, you forgot to post the image. We don't know what it looks like, or how big the blocks are relative to the total image size. Please post the image in your original post.
In the meantime, I suggest you try sdtfilt() and take the mean and see if that works for you.
sdImage = stdfilt(grayImage, true(5));
smoothnessMetric = mean2(sdImage)
If it doesn't work well for you, then we can discuss other metrics, after we see the image(s).