我正在尝试使用Python Pillow进行图像叠加。 我想做的是获取大量图片(比如10张),然后对于每个像素,取中间值,就像这样:http://petapixel.com/2013/05/29/a-look-at-reducing-noise-in-photographs-using-median-blending/。
目前,我可以用一种非常原始的方式(使用getpixel和putpixel)来实现它,但需要花费很长时间。
以下是我迄今为止所拥有的:
目前,我可以用一种非常原始的方式(使用getpixel和putpixel)来实现它,但需要花费很长时间。
以下是我迄今为止所拥有的:
import os
from PIL import Image
files = os.listdir("./")
new_im = Image.new('RGB', (4000,3000))
ims={}
for i in range(10,100):
ims[i]={}
im=Image.open("./"+files[i])
for x in range(400):
ims[i][x]={}
for y in range(300):
ims[i][x][y]=im.getpixel((x,y))
for x in range(400):
for y in range(300):
these1=[]
these2=[]
these3=[]
for i in ims:
these1.append(ims[i][x][y][0])
these2.append(ims[i][x][y][1])
these3.append(ims[i][x][y][2])
these1.sort()
these2.sort()
these3.sort()
new_im.putpixel((x,y),(these1[len(these1)/2],these2[len(these2)/2],these3[len(these3)/2]))
new_im.show()