msd function

Median scaled difference