Data granulation through optimization of similarity measure