change all ImageGray to Matrix
change all ImageGray to Matrix