import numpy as np
from PIL import Image
from scipy.ndimage import rotate


img = Image.open('1.png')
img_matrix = np.array(img)
print(f"img_matrix0: {img_matrix}")
r, g, b = img.split()
ag = 45
r_rotated = rotate(r, angle=ag, reshape=True)
g_rotated = rotate(g, angle=ag, reshape=True)
b_rotated = rotate(b, angle=ag, reshape=True)

r = Image.fromarray(r_rotated).convert('L')
g = Image.fromarray(g_rotated).convert('L')
b = Image.fromarray(b_rotated).convert('L')

img = Image.merge("RGB", (r, g, b))
img_matrix = np.array(img)
print(f"img_matrix1: {img_matrix}")
img.save("3.png", 'png')

Last modification:October 13, 2022
如果觉得我的文章对你有用,请随意赞赏