Sep 20, 2009

python 之 图像处理

有多个选择
1. 安装 The Image Module (PIL),参见其 Manual
2. wxpython 的 wx.Image, 可能功能较少
3. opencv python portal

PIL
import sys
import os
import subprocess
from PIL import Image

dir = r'F:\100NCD50\New Folder\small'

box = (20,0,340,240)

dirList=os.listdir(dir)

for i in range(len(dirList)):
    if dirList[i].endswith('.jpg'):
        me = os.path.join(dir, dirList[i])
        im = Image.open(me)
        out  = im.crop(box)
        out.save(str(i)+'.png')

0 comments: