# coding=UTF-8
import Image
import ImageOps
# 画像をセピア調に変換する
img1 = Image.open("sf.jpg")
#img2 = ImageOps.grayscale(img1)
for ly in range(img1.size[1]):
for lx in range(img1.size[0]):
pv = img1.getpixel((lx, ly))
pv2 = (pv[0]+pv[1]+pv[2])/3
pr = int(pv2 *0xd0/0xff)
pg = int(pv2 *0xa0/0xff)
pb = int(pv2 *0x50/0xff)
img1.putpixel((lx,ly), (pr,pg,pb))
img1.save("sample701a.png")
元画像(sf.jpg)
出力画像(sample701a.png)

関連情報
Python Imaging Libraryまとめ
No comments:
Post a Comment