Learning from pairwise similarity for visual categorization