Dec-06-2018, 05:22 AM
Hello again,
Currently I'm having an issue with an assignment where I must change the value of pixels to brighten an image.
Here is the full question;
"If we increase the value of each pixel in the image by the same amount, the image will appear brighter.
Write a program to add 50 to the value of each pixel in a given image.
Your program should ask the user to type in the name of the image file to read, and then create a new output file called output.png which contains the brightened image.
Here's an example where the user selects the given yawn.png.
File name: yawn.png"
Here is my current answer code;
The image should look like this;
![[Image: Qi5RlCe.png]](https://i.imgur.com/Qi5RlCe.png)
Unfortunately, I am getting this; Basically the default or a little darker;
![[Image: cBl9s08.png]](https://i.imgur.com/cBl9s08.png)
Would love some tips as I've exhausted a few code variations with no solution thus far
, thanks in advance
Currently I'm having an issue with an assignment where I must change the value of pixels to brighten an image.
Here is the full question;
"If we increase the value of each pixel in the image by the same amount, the image will appear brighter.
Write a program to add 50 to the value of each pixel in a given image.
Your program should ask the user to type in the name of the image file to read, and then create a new output file called output.png which contains the brightened image.
Here's an example where the user selects the given yawn.png.
File name: yawn.png"
Here is my current answer code;
from PIL import Image file = input("File name: ") img = Image.open(file) for y in range(img.height): for x in range(img.width): pixel = img.getpixel((x,y)) value = img.getpixel((x,y)) img.putpixel((x,y), value + 50) img.save("output.png")I'm not getting any changes whatsoever in my output image. It just looks the same instead of brighter.
The image should look like this;
![[Image: Qi5RlCe.png]](https://i.imgur.com/Qi5RlCe.png)
Unfortunately, I am getting this; Basically the default or a little darker;
![[Image: cBl9s08.png]](https://i.imgur.com/cBl9s08.png)
Would love some tips as I've exhausted a few code variations with no solution thus far
