as the title says, I'm trying to rotate an image in Python, using the Scipy package. I receive as an input an image, with an specific size, for example, 512 x 512, and I have to perform some rotations over it and to crop a proportion of it. So, this is my code so far:
for i in range(0, 90, 10):
image_base = Dt.Data(open_image=True, rotation=i)
Dv.DataVisualization.plot_data(image_base, '../Visualizations/ProcessedImages/'+str(i))
def plot_data(data, file_path):
"""
Plot the data
:param data : the data to be plotted
:param file_path : the name of the file
"""
output = Image.fromarray(numpy.uint8(data.data * 255))
output.save(file_path + '.png', 'PNG')
class Data(object):
def __init__(self, open_image=False, rotation=None):
"""
The Data constructor
"""
self.data = misc.imread('../TestImages/board.jpg', flatten=True)
self.data /= 255.0
x, y = self.data.shape
if rotation != 0:
self.data = ndimage.rotate(self.data, rotation, reshape=False)
self.data = self.data[x / 4: - x / 4, y / 4: - y / 4]
This is my original image (256x256):
And these are some outputs there I got (128x128):
As you can see, the edges are pretty bad, and this is not acceptable for what I have to do. I'm wondering why this happens and if there is a way to get rid of it.
Thank you in advance.
Ok, I was able to solve this using the parameter:
order : int, optional
The order of the spline interpolation, default is 3. The order has to be in the range 0-5.
Thank you for your time. (: