Image and video classification and image similarity measurement by learning sparse representation