batch image processing by Python

#!/usr/bin/python
import os
import re
from scipy import ndimage, misc

images = []
for root, dirnames, filenames in os.walk("."):
   for filename in filenames:
     if re.search("\.(jpg|jpeg|png)$", filename):
       filepath = os.path.join(root, filename)
       image = ndimage.imread(filepath, mode="L")
       image_resized = misc.imresize(image, (256, 256))
       misc.imsave(filepath, image_resized)

댓글

이 블로그의 인기 게시물

Draw Circle on PictureBox when Button Click - Winform

2D FFT of Gray Image by AForge