Mean Shift algorithm implementation