Rate-distortion based sparse coding for image set compression