After seeing this image on the Facebook page of a friend of mine, I thought it would be more convenient to make my own version with a python script rather than open photoshop and start to copy and paste. I was wrong, but now I can share with you my result and comment on the difficulties encountered in this simple image processing.
Unfortunately the whole article was based on a wrong assumption because of a wrong test. you can skip to the end to read the correct version
-------------------BEGIN--------------------
The initial plan was to gradually change the brightness level of the image and then compose the output.
- PIL.ImageEnhance.Brightness (image)
Second option, generating two empty pictures, one white and one black, and superimpose them gradually to correct the brightness.
- PIL.Image.blend(image1, image2, alpha)
Third option, the one followed, generating 50 images in grayscale and overlay the original image.
good, how can I generate these images?
- PIL.Image.new("L", (width, height), '#greyHexValue')
Solution, create intermediate values of gray by mixing them gradually. instead of 33, we now have 65 shades.
this allows us to do more, then choose a range of shades depending on the brightness of the original image, for better result.
this is the code -> downlaod
$python toGrey.py inputimage
and there is some example
---------------------END----------------------
The plan is simple: gradually change the brightness level of the image and then compose the output.
from PIL import Image
from PIL import ImageEnhance
import sys
inputImageName = sys.argv[1]
outputImageName = '50ShadesOf_ ' + inputImageName
pilImage=Image.open(inputImageName)
width = pilImage.size[0]
height = pilImage.size[1]
out = Image.new("L", (width*10, height*5), "white")
img = []
enhancer = ImageEnhance.Brightness(pilImage)
for i in range(0,50):
pilImage=Image.open(inputImageName)
ppilImage = enhancer.enhance((50-i)/50.0)
img.append(ppilImage)
for y in range(0,5):
for x in range(0,10):
out.paste(img[(y*10) + x], (width*x,height*y))
out.save(outputImageName)
from PIL import ImageEnhance
import sys
inputImageName = sys.argv[1]
outputImageName = '50ShadesOf_ ' + inputImageName
pilImage=Image.open(inputImageName)
width = pilImage.size[0]
height = pilImage.size[1]
out = Image.new("L", (width*10, height*5), "white")
img = []
enhancer = ImageEnhance.Brightness(pilImage)
for i in range(0,50):
pilImage=Image.open(inputImageName)
ppilImage = enhancer.enhance((50-i)/50.0)
img.append(ppilImage)
for y in range(0,5):
for x in range(0,10):
out.paste(img[(y*10) + x], (width*x,height*y))
out.save(outputImageName)
you can download the code -> here
Good job Gurzo! Good job!! :D
RispondiElimina