Added a function for calculating covar matrix of a greyscale