, , "".
numpy :
def colorswap(pixel):
"""Shifts the channels of the image."""
return (pixel[1], pixel[2], pixel[0])
def npoint(img, func):
import numpy as np
a = np.asarray(img).copy()
r = a[:,:,0]
g = a[:,:,1]
b = a[:,:,2]
r[:],g[:],b[:] = func((r,g,b))
return Image.fromarray(a,img.mode)
img = Image.open('test.png')
img2 = npoint(img, colorswap)
img2.save('test2.png')
: , Image , , npoint point ( , ):
Image.Image.npoint = npoint
img = Image.open('test.png')
img2 = img.npoint(colorswap)