fixed bug (division by 0), also fixed meanshift to fit algorithm from wikipedia