calculating gravity center and doing Komodakis clustering