replaced deprecated drawImage function
guarantee double types in matrix calculation