from PIL import Image
from numpy import zeros
import time
#file=raw_input('Enter file name ')
im=Image.open('sourceimage.jpg')
im=im.convert("L")
pix=im.load()
N=1
t1=time.time()
for k in range(N):
for i in range(1,im.size[0]-1):
for j in range(1,im.size[1]-1):
sum=(pix[i-1,j]+pix[i+1,j]+pix[i,j-1]+pix[i,j+1])
pix[i,j]=int(0.25*sum)
t2=time.time()
print t2-t1
im.save('smoothenedimage.jpg')
No comments:
Post a Comment