How do you define it? Is it just the max minus the min?
image_contrast = max(grayImage(:)) - min(grayImage(:));
or do you want some other definition? Maybe like the ratio of the mean to the standard deviation or something? It might help if you said what you are going to do with this information if you can get it.