Python作业5

from PIL import Image

import numpy as np

im = np.array(Image.open('D:\image\coffee.jpg'))

print(im.shape,im.dtype)

b = [255, 255, 255] - im

new_im = Image.fromarray(b.astype('uint8')) 

new_im.save('D:\image\coffee-new.jpg') 

b = [255, 255, 255] + im

new_im = Image.fromarray(b.astype('uint8')) 

new_im.save('D:\image\coffee-new-1.jpg') 


你可能感兴趣的:(Python作业5)