Introduction - If you have any usage issues, please Google them yourself
Achieve a grayscale image and further control for video surveillance, Using matlab to calculate the Mahalanobis distance for the image, Code, there are very complete notes and explanation.