[PIL] Modification image, tuples
Bonjour, désolé pour le titre pas très explicite, mais je ne trouvai rien.
Je suis en trin de faire un petit programme qui augmente les contraste d'une image :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| from PIL import Image
im=Image.open("Moustique.jpeg")
#im.show()
w,h=im.size
im2 = Image.new("RGB", (w,h))
for y in range (h):
for x in range(w):
p = im.getpixel((x,y))
for i in range (0,3):
if p[i]<30:
p[i]=0
if p[i]>225:
p[i]=255
else :
p[i] = int((255.0 / 195.0) * (p[i] - 30) + 0.5)
im2.putpixel((x,y),(p[0],p[1],p[2]))
#endif
#endfor
#endfor
im2.save("im_contrast.jpg")
im2.show() |
J'ai trouvé les formules inférieur a 30, supérieur a 225 et le calcul sur ce site : http://www.apprendre-en-ligne.net/in...ges/index.html
Donc je lance le programme et j'obtient :
Code:
http://www.apprendre-en-ligne.net/info/codage/images/index.html
:calim2:
Pourtant je ne modifie pas mon tuple directement, mais chacune de ses composantes une à une.
Alors si quelqu'un pouvait m’éclaircir un peu, ça serait très gentil :ccool: