import numpy as np
from PIL import Image
a_num = np.array(Image.open('1.png'))
a_num
转化的数组:
array([[[181, 179, 193],
[180, 177, 194],
[186, 183, 200],
...,
[190, 193, 210],
[183, 186, 203],
[183, 186, 203]],
...,
[206, 177, 173],
[194, 164, 162],
[191, 163, 160]]], dtype=uint8)
取反
b = 255 - a_num
im = Image.fromarray(b.astype('uint8'))
im
im_2 = a_num**2
Image.fromarray(im_2.astype('uint8'))