Skip to content Skip to sidebar Skip to footer

Numpy Matrix Rotation For Any Degrees

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 sh

Solution 1:

Have you tried rotate function from scipy.ndimage.interpolation?

import numpy as np
from scipy.ndimage.interpolationimport rotate

x = np.random.randint(800, 1000, size=[100, 100, 3])
rotated = rotate(x, angle=45)

It does rotate matrix without scaling the values.

Solution 2:

You might want to try open CV's warpAffine(). It allows for rotation and translation of the image.

Depending on your choice of interpolation method you might have some changes to your values thoug.

Post a Comment for "Numpy Matrix Rotation For Any Degrees"