Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Red color enhancement
#1
So I wrote this code and my goal is to increase the red intensity by 50% in every pixel, help?
from PIL import Image
im= Image.open('monkey.jpg')
img = im.copy()
width, height = img.size
red, green, blue = (0,0,0)
for i in range(width):
    for j in range(height):
        pixel = img.getpixel((i,j))
        red += pixel[0]
        green += pixel[1]
        blue += pixel[2]
        newpixel = img.putpixel((i,j),(red*2,green,blue))
Reply
#2
#python
from PIL import Image

img  = Image.open('monkey.jpg')
width, height = img.size

for i in range(width):
    for j in range(height):
        pixel = img.getpixel((i,j))
        red   = pixel[0]
        green = pixel[1]
        blue  = pixel[2]
        newpixel = img.putpixel((i,j), (red*2,green,blue))

img.save("test.jpg", "jpeg")
Reply
#3
Doesnt red*2 increase red intensity by 100%?
I would try with red*1.5 to gain 50% increase.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Turtle Star Fill Color Yellow-White Interchanging Color Effect codelab 9 3,220 Oct-25-2023, 09:09 AM
Last Post: codelab
  Performance enhancement fimmu 0 2,003 Feb-12-2020, 02:42 PM
Last Post: fimmu

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020