There may be a pure-PIL method for this; I dont know. However, if not, then you can do it with numpy:
import numpy as np
import Image
import ImageFilter
def dodge(front,back):
result=back*256.0/(256.0-front)
result[result>255]=255
result[front==255]=255
return result.astype('uint8')
img = Image.open(fname,'r').convert('RGB')
arr = np.asarray(img)
img_blur = img.filter(ImageFilter.BLUR)
blur = np.asarray(img_blur)
result=dodge(front=blur, back=arr)
result = Image.fromarray(result, 'RGB')
result.show()
source
share