I try to find a way to apply a matrix rotation of any degrees on my matrix that contains three bands like RGB but values are bigger than (0-255).
It is an example of my data its shape is (100, 100, 3):
[[ 847.5 877. 886. ... 821.5 856.5 898. ]
[ 850. 883. 969.5 ... 885. 878.5 947.5]
[ 982. 968.5 927.5 ... 909.5 958. 1037. ]
...
[ 912. 827. 893. ... 1335. 1180. 1131. ]
[ 954. 855.5 882. ... 1252. 1266. 1335. ]
[ 984. 916. 930. ... 1080.5 1278. 1385.5]]
I found a function scipy.misc.imrotate(image_array, 20) but the problem is this function rescales my data to the range (0-255), thus I loose information of my original matrix. Is there a function that does the same job as the previous one without rescaling data ?
Have you tried rotate function from scipy.ndimage?
import numpy as np
from scipy.ndimage import rotate
x = np.random.randint(800, 1000, size=[100, 100, 3])
rotated = rotate(x, angle=45)
It does rotate matrix without scaling the values.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With