To convert the data type of the matrix, it's necessary to use the astype function of NumPy Array. The function takes desired type as input and returns converted array.
To scale the values of the matrix, you can use an algebraic operation with the matrix itself: for example, just divide the matrix by some value (255, in the preceding code) to divide each element of the matrix by the specified value. The result of scaling the values of the input images should appear as follows (the left image is the original, the right image is the scaled version):