compute mean shape impl-d