Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8019387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:22:36+00:00 2026-06-04T21:22:36+00:00

I am trying to change the RGB values in a photo with the Python

  • 0

I am trying to change the RGB values in a photo with the Python Imaging Library. I have been using the function Image.point and it does what I want except I want to be able to implement a different function on the R the G and the B values. Anyone know how I can do this?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T21:22:37+00:00Added an answer on June 4, 2026 at 9:22 pm

    You’re better off using numpy in addition to PIL for doing math of the individual bands of an image.

    As a contrived example that is not meant to look good in any way:

    import Image
    import numpy as np
    
    im = Image.open('snapshot.jpg')
    
    # In this case, it's a 3-band (red, green, blue) image
    # so we'll unpack the bands into 3 separate 2D arrays.
    r, g, b = np.array(im).T
    
    # Let's make an alpha (transparency) band based on where blue is < 100
    a = np.zeros_like(b)
    a[b < 100] = 255
    
    # Random math... This isn't meant to look good...
    # Keep in mind that these are unsigned 8-bit integers, and will overflow.
    # You may want to convert to floats for some calculations.
    r = (b + g) * 5
    
    # Put things back together and save the result...
    im = Image.fromarray(np.dstack([item.T for item in (r,g,b,a)]))
    
    im.save('output.png')
    

    Input
    enter image description here


    Output
    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to change the font size using python's ImageDraw library. You can
Im trying to change my ul li list to use it with background image
Just trying to change the value of an input using jQuery. Seems to work,
I am trying to convert a PIL image into an array using NumPy. I
I have an image, <img src=/meAndMy/face.jpg /> . I am trying to get the
I am trying to change a part of an image with another image I
I have a file format I'm trying to write to using C#. The format
I'm trying to write a function to shift the hue of an RGB color.
I am trying to change the color of the function swapFE() below and I
I am trying to change the color of my navigation bar. The following rgb

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.