newIm = Image.new('1', im.size) newIm.putdata([i[0] == i[1] for i inzip(imdata[1:], imdata_trans[:-1])]) newIm.save('out27.png') #这里有点奇怪,直接show()得到的是全黑图像。要用save才有内容
diff = filter(lambda p: p[0] != p[1], zip(imdata[1:], imdata_trans[:-1])) diff = [''.join(p[i] for p in diff) for i inrange(2)] text = bz2.decompress(diff[0])