Added function image2matrix