def demo_normalize():
    img = Image.open(FILENAME).convert('RGBA')
arr = np.array(img)
new_img = Image.fromarray(normalize(arr).astype('uint8'), 'RGBA')
new_img.save('/tmp/normalized.png')
Intensity normalization of image using Python+PIL - Speed issues