Python更改图像的RGB值并保存为imag

2024-05-17 08:09:26 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经可以读取图像的每个像素的RGB,但是我不知道如何将RGB的值更改为一半并保存为图像。提前谢谢。

from PIL  import *

def half_pixel(jpg):
  im=Image.open(jpg)
  img=im.load()
  print(im.size)
  [xs,ys]=im.size  #width*height

# Examine every pixel in im
  for x in range(0,xs):
     for y in range(0,ys):
        #get the RGB color of the pixel
        [r,g,b]=img[x,y] 

Tags: theinfrom图像imgforsizerange